.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Ace::Browser::AceSubs 3pm" .TH Ace::Browser::AceSubs 3pm "2018-11-01" "perl v5.28.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Ace::Browser::AceSubs \- Subroutines for AceBrowser .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& use Ace; \& use Ace::Browser::AceSubs; \& use CGI qw(:standard); \& use CGI::Cookie; \& \& my $obj = GetAceObject() || AceNotFound(); \& PrintTop($obj); \& print $obj\->asHTML; \& PrintBottom(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Ace::Browser::AceSubs exports a set of routines that are useful for creating search pages and displays for AceBrowser \s-1CGI\s0 pages. See http://stein.cshl.org/AcePerl/AceBrowser. .PP The following subroutines are exported by default: .PP .Vb 12 \& AceError \& AceMissing \& AceNotFound \& Configuration \& DoRedirect \& GetAceObject \& Object2URL \& ObjectLink \& OpenDatabase \& PrintTop \& PrintBottom \& Url .Ve .PP The following subroutines are exported if explicitly requested: .PP .Vb 12 \& AceAddCookie \& AceInit \& AceHeader \& AceMultipleChoices \& AceRedirect \& DB_Name \& Footer \& Header \& ResolveUrl \& Style \& Toggle \& TypeSelector .Ve .PP To load the default subroutines load the module with: .PP .Vb 1 \& use Ace::Browser::AceSubs; .Ve .PP To bring in a set of optionally routines, load the module with: .PP .Vb 1 \& use Ace::Browser::AceSubs qw(AceInit AceRedirect); .Ve .PP To bring in all the default subroutines, plus some of the optional ones: .PP .Vb 1 \& use Ace::Browser::AceSubs qw(:DEFAULT AceInit AceRedirect); .Ve .PP There are two main types of AceBrowser scripts: .IP "display scripts" 4 .IX Item "display scripts" These are called with the \s-1CGI\s0 parameters b and b, corresponding to the name and class of an AceDB object to display. The subroutine \fBGetAceObject()\fR will return the requested object, or undef if the object does not exist. .Sp To retrieve the parameters, use the \s-1CGI\s0.pm \fBparam()\fR method: .Sp .Vb 2 \& $name = param(\*(Aqname\*(Aq); \& $class = param(\*(Aqclass\*(Aq); .Ve .IP "search scripts" 4 .IX Item "search scripts" These are not called with any \s-1CGI\s0 parameters on their first invocation, but can define their own parameter lists by creating fill-out forms. The AceBrowser system remembers the last search performed by a search script in a cookie and regenerates the \s-1CGI\s0 parameters the next time the user selects that search script. .SH "SUBROUTINES" .IX Header "SUBROUTINES" The following sections describe the exported subroutines. .IP "AceError($message)" 4 .IX Item "AceError($message)" This subroutine will print out an error message and exit the script. The text of the message is taken from \f(CW$message\fR. .IP "\fBAceHeader()\fR" 4 .IX Item "AceHeader()" This function prints the \s-1HTTP\s0 header and issues a number of cookies used for maintaining AceBrowser state. It is not exported by default. .IP "AceAddCookie(@cookies)" 4 .IX Item "AceAddCookie(@cookies)" This subroutine, which must be called b \fBOpenDatabase()\fR and/or \&\fBGetAceObject()\fR and b \fBPrintTop()\fR, will add one or more cookies to the outgoing \s-1HTTP\s0 headers that are emitted by \fBAceHeader()\fR. Cookies must be CGI::Cookie objects. .IP "\fBAceInit()\fR" 4 .IX Item "AceInit()" This subroutine initializes the AcePerl connection to the configured database. If the database cannot be opened, it generates an error message and exits. This subroutine is not exported by default, but is called by \fBPrintTop()\fR and \fBHeader()\fR internally. .IP "AceMissing([$class,$name])" 4 .IX Item "AceMissing([$class,$name])" This subroutine will print out an error message indicating that an object is present in AceDB, but that the information the user requested is absent. It will then exit the script. This is infrequently encountered when following XREFed objects. If the class and name of the object are not provided as arguments, they are taken from \s-1CGI\s0's \fBparam()\fR function. .IP "AceMultipleChoices($symbol,$report,$objects)" 4 .IX Item "AceMultipleChoices($symbol,$report,$objects)" This function is called when a search has recovered multiple objects and the user must make a choice among them. The user is presented with an ordered list of the objects, and asked to click on one of them. .Sp The three arguments are: .Sp .Vb 2 \& $symbol The keyword or query string the user was searching \& on, undef if none. \& \& $report The symbolic name of the current display, or undef \& if none. \& \& $objects An array reference containing the Ace objects in \& question. .Ve .Sp This subroutine is not exported by default. .IP "AceNotFound([$class,$name])" 4 .IX Item "AceNotFound([$class,$name])" This subroutine will print out an error message indicating that the requested object is not present in AceDB, even as a name. It will then exit the script. If the class and name of the object are not provided as arguments, they are taken from \s-1CGI\s0's \fBparam()\fR function. .IP "($uri,$physical_path) = AcePicRoot($directory)" 4 .IX Item "($uri,$physical_path) = AcePicRoot($directory)" This function returns the physical and \s-1URL\s0 paths of a temporary directory in which the pic script can write pictures. Not exported by default. Returns a two-element list containing the \s-1URL\s0 and physical path. .IP "AceRedirect($report,$object)" 4 .IX Item "AceRedirect($report,$object)" This function redirects the user to a named display script for viewing an Ace object. It is used, for example, to convert a request for a sequence into a request for a protein: .Sp .Vb 5 \& $obj = GetAceObject(); \& if ($obj\->CDS) { \& my $protein = $obj\->Corresponding_protein; \& AceRedirect(\*(Aqprotein\*(Aq,$protein); \& } .Ve .Sp AceRedirect must be called b \fBPrintTop()\fR or \fBAceHeader()\fR. It invokes \fBexit()\fR, so it will not return. .Sp This subroutine is not exported by default. It differs from \&\fBDoRedirect()\fR in that it displays a message to the user for two seconds before it generates the new page. It also allows the display to be set explicitly, rather than determined automatically by the AceBrowser system. .ie n .IP "$configuration = \fBConfiguration()\fR" 4 .el .IP "\f(CW$configuration\fR = \fBConfiguration()\fR" 4 .IX Item "$configuration = Configuration()" The \fBConfiguration()\fR function returns the Ace::Browser::SiteDefs object for the current session. From this object you can retrieve information from the configuration file. .ie n .IP "$name = \fBDB_Name()\fR" 4 .el .IP "\f(CW$name\fR = \fBDB_Name()\fR" 4 .IX Item "$name = DB_Name()" This function returns the symbolic name of the current database, for example \*(L"default\*(R". .IP "DoRedirect($object)" 4 .IX Item "DoRedirect($object)" This subroutine immediately redirects to the default display for the Ace::Object indicated by \f(CW$object\fR and exits the script. It must be called before \fBPrintTop()\fR or any other HTML-generating code. It differs from \fBAceRedirect()\fR in that it generates a fast redirect without alerting the user. .Sp This function is not exported by default. .ie n .IP "$footer = \fBFooter()\fR" 4 .el .IP "\f(CW$footer\fR = \fBFooter()\fR" 4 .IX Item "$footer = Footer()" This function returns the contents of the footer as a string, but does not print it out. It is not exported by default. .ie n .IP "$object = \fBGetAceObject()\fR" 4 .el .IP "\f(CW$object\fR = \fBGetAceObject()\fR" 4 .IX Item "$object = GetAceObject()" This function is called by display scripts to return the Ace::Object.that the user wishes to view. It automatically opens or refreshes the database, and performs the request using the values of the \&\*(L"name\*(R" and \*(L"class\*(R" \s-1CGI\s0 variables. .Sp If a single object is found, the function returns it as the function result. If no objects are found, it returns undef. If more than one object is found, the function invokes \fBAceMultipleChoices()\fR and exits the script. .ie n .IP "$html = \fBHeader()\fR" 4 .el .IP "\f(CW$html\fR = \fBHeader()\fR" 4 .IX Item "$html = Header()" This subroutine returns the boilerplate at the top of the \s-1HTML\s0 page as a string, but does not print it out. It is not exported by default. .ie n .IP "$url = Object2URL($object)" 4 .el .IP "\f(CW$url\fR = Object2URL($object)" 4 .IX Item "$url = Object2URL($object)" .PD 0 .ie n .IP "$url = Object2URL($name,$class)" 4 .el .IP "\f(CW$url\fR = Object2URL($name,$class)" 4 .IX Item "$url = Object2URL($name,$class)" .PD In its single-argument form, this function takes an AceDB Object and returns an AceBrowser \s-1URL.\s0 The \s-1URL\s0 chosen is determined by the configuration settings. .Sp It is also possible to pass Object2URL an object name and class, in the case that an AceDB object isn't available. .Sp The return value is a \s-1URL.\s0 .ie n .IP "$link = ObjectLink($object [,$link_text])" 4 .el .IP "\f(CW$link\fR = ObjectLink($object [,$link_text])" 4 .IX Item "$link = ObjectLink($object [,$link_text])" This function converts an AceDB object into a hypertext link. The first argument is an Ace::Object. The second, optional argument is the text to use for the link. If not provided, the object's name becomes the link text. .Sp This function is used extensively to create cross references between Ace::Objects on AceBrowser pages. .Sp Example: .Sp .Vb 2 \& my $author = $db\->fetch(Author => \*(AqSulston JE\*(Aq); \& print ObjectLink($author,$author\->Full_name); .Ve .Sp This will print out a link to a page that will display details on the author page. The text of the link will be the value of the Full_name tag. .ie n .IP "$db = \fBOpenDatabase()\fR" 4 .el .IP "\f(CW$db\fR = \fBOpenDatabase()\fR" 4 .IX Item "$db = OpenDatabase()" This function opens the Acedb database designated by the configuration file. In modperl environments, this function caches database handles and reuses them, pinging and reopening them in the case of timeouts. .Sp This function is not exported by default. .IP "PrintTop($object,$class,$title,@html_headers)" 4 .IX Item "PrintTop($object,$class,$title,@html_headers)" The \fBPrintTop()\fR function generates all the boilerplate at the top of a typical AceBrowser page, including the \s-1HTTP\s0 header information, the page title, the navigation bar for searches, the web site banner, the type selector for choosing alternative displays, and a level-one header. .Sp Call it with one or more arguments. The arguments are: .Sp .Vb 2 \& $object An AceDB object. The navigation bar and title will be \& customized for the object. \& \& $class If no AceDB object is available, then you can pass \& a string containing the AceDB class that this page is \& designed to display. \& \& $title A title to use for the HTML page and the first level\-one \& header. If not provided, a generic title "Report for \& Object" is generated. \& \& @html_headers Additional HTML headers to pass to the the CGI.pm \& start_html. .Ve .IP "\fBPrintBottom()\fR" 4 .IX Item "PrintBottom()" The \fBPrintBottom()\fR function outputs all the boilerplate at the bottom of a typical AceBrowser page. If a user-defined footer is present in the configuration file, that is printed. Otherwise, the method prints a horizontal rule followed by links to the site home page, the AcePerl home page, the privacy policy, and the feedback page. .ie n .IP "$hashref = \fBStyle()\fR" 4 .el .IP "\f(CW$hashref\fR = \fBStyle()\fR" 4 .IX Item "$hashref = Style()" This subroutine returns a hashref containing a reference to the configured stylesheet, in the following format: .Sp .Vb 1 \& { \-src => \*(Aq/ace/stylesheets/current_stylesheet.css\*(Aq } .Ve .Sp This hash is suitable for passing to the \-style argument of \s-1CGI\s0.pm's \&\fBstart_html()\fR function, or for use as an additional header in \&\fBPrintTop()\fR. You may add locally-defined stylesheet elements to the hash before calling \fBstart_html()\fR. See the pic script for an example of how this is done this. .Sp This function is not exported by default. .ie n .IP "$url = ResolveUrl($url,$param)" 4 .el .IP "\f(CW$url\fR = ResolveUrl($url,$param)" 4 .IX Item "$url = ResolveUrl($url,$param)" Given a \s-1URL\s0 and a set of parameters, this function does the necessary magic to add the symbolic database name to the end of the \s-1URL\s0 (if needed) and then tack the parameters onto the end. .Sp A typical call is: .Sp .Vb 1 \& $url = ResolveUrl(\*(Aq/cgi\-bin/ace/generic/tree\*(Aq,\*(Aqname=fred;class=Author\*(Aq); .Ve .Sp This function is not exported by default. .ie n .IP "$boolean = Toggle($section,[$label,$object_count,$add_plural,$add_count])" 4 .el .IP "\f(CW$boolean\fR = Toggle($section,[$label,$object_count,$add_plural,$add_count])" 4 .IX Item "$boolean = Toggle($section,[$label,$object_count,$add_plural,$add_count])" .PD 0 .IP "($link,$bool) = Toggle($section,$label,$object_count,$add_plural,$add_count)" 4 .IX Item "($link,$bool) = Toggle($section,$label,$object_count,$add_plural,$add_count)" .PD The \fBToggle()\fR subroutine makes it easy to create \s-1HTML\s0 sections that open and close when the user selects a toggle icon (a yellow triangle). .Sp \&\fBToggle()\fR can be used to manage multiple collapsible \s-1HTML\s0 sections, but each section must have a unique name. The required first argument is the section name. Optional arguments are: .Sp .Vb 1 \& $label The text of the generated link, for example "sequence" \& \& $object_count The number of objects that opening the section will reveal \& \& $add_plural If true, the label will be pluralized when \& appropriate \& \& $add_count If true, the label will have the object count added \& when appropriate .Ve .Sp In a scalar context, \fBToggle()\fR prints the link \s-1HTML\s0 and returns a boolean flag. A true result indicates that the section is expanded and should be generated. A false result indicates that the section is collapsed. .Sp In a list context, \fBToggle()\fR returns a two-element list. The first element is the \s-1HTML\s0 link that expands and contracts the section. The second element is a boolean that indicates whether the section is currently open or closed. .Sp This example indicates typical usage: .Sp .Vb 6 \& my $sequence = GetAceObject(); \& print "sequence name = ",$sequence,"\en"; \& print "sequence clone = ",$sequence\->Clone,"\en"; \& if (Toggle(\*(Aqdna\*(Aq,\*(AqSequence DNA\*(Aq)) { \& print $sequence\->asDNA; \& } .Ve .Sp An alternative way to do the same thing: .Sp .Vb 6 \& my $sequence = GetAceObject(); \& print "sequence name = ",$sequence,"\en"; \& print "sequence clone = ",$sequence\->Clone,"\en"; \& my ($link,$open) = Toggle(\*(Aqdna\*(Aq,\*(AqSequence DNA\*(Aq); \& print $link; \& print $sequence\->asDNA if $open; .Ve .ie n .IP "$html = TypeSelector($name,$class)" 4 .el .IP "\f(CW$html\fR = TypeSelector($name,$class)" 4 .IX Item "$html = TypeSelector($name,$class)" This subroutine generates the \s-1HTML\s0 for the type selector navigation bar. The links in the bar are dynamically generated based on the values of \f(CW$name\fR and \f(CW$class\fR. This function is called by \fBPrintTop()\fR. It is not exported by default. .ie n .IP "$url = Url($display,$params)" 4 .el .IP "\f(CW$url\fR = Url($display,$params)" 4 .IX Item "$url = Url($display,$params)" Given a symbolic display name, such as \*(L"tree\*(R" and a set of parameters, this function looks up its \s-1URL\s0 and then calls \fBResolveUrl()\fR to create a single Url. .Sp When hard-coding relative URLs into AceBrowser scripts, it is important to pass them through \fBUrl()\fR. The reason for this is that AceBrowser may need to attach the database name to the \s-1URL\s0 in order to identify it. .Sp Example: .Sp .Vb 2 \& my $url = Url(\*(Aq../sequence_dump\*(Aq,"name=$name;long_dump=yes"); \& print a({\-href=>$url},\*(AqDump this sequence\*(Aq); .Ve .SH "BUGS" .IX Header "BUGS" Please report them. .SH "SEE ALSO" .IX Header "SEE ALSO" Ace::Object, Ace::Browser::SiteDefs, Ace::Browsr::SearchSubs, the \s-1README.ACEBROWSER\s0 file. .SH "AUTHOR" .IX Header "AUTHOR" Lincoln Stein . .PP Copyright (c) 2001 Cold Spring Harbor Laboratory .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See \s-1DISCLAIMER\s0.txt for disclaimers of warranty.