Ace::B...AceSubs(3pm)

✨ NAME ✨

okay so bestie πŸ’–, this is the manual page for Ace::Browser::AceSubs β€” Subroutines for AceBrowser. The header out there calls it Ace::B...AceSubs(3pm) under User Contributed Perl Documentation, so that's the vibe. We're about to make these routines make sense, no cap.


🌸 SYNOPSIS 🌸

use Ace;
use Ace::Browser::AceSubs;
use CGI qw(:standard);
use CGI::Cookie;

my $obj = GetAceObject() || AceNotFound();
PrintTop($obj);
print $obj->asHTML;
PrintBottom();

πŸ’– DESCRIPTION πŸ’–

Ace::Browser::AceSubs exports a set of routines that are useful for creating search pages and displays for AceBrowser CGI pages. See http://stein.cshl.org/AcePerl/AceBrowser. It's giving toolkit, bestie. ✨

The following subroutines are exported by default (they just show up, no invitation needed):

  • AceError
  • AceMissing
  • AceNotFound
  • Configuration
  • DoRedirect
  • GetAceObject
  • Object2URL
  • ObjectLink
  • OpenDatabase
  • PrintTop
  • PrintBottom
  • Url

The following subroutines are exported if explicitly requested (you gotta ask for these, iykyk):

  • AceAddCookie
  • AceInit
  • AceHeader
  • AceMultipleChoices
  • AceRedirect
  • DB_Name
  • Footer
  • Header
  • ResolveUrl
  • Style
  • Toggle
  • TypeSelector

To load the default subroutines load the module with:

use Ace::Browser::AceSubs;

To bring in a set of optionally routines, load the module with:

use Ace::Browser::AceSubs qw(AceInit AceRedirect);

To bring in all the default subroutines, plus some of the optional ones:

use Ace::Browser::AceSubs qw(:DEFAULT AceInit AceRedirect);

There are two main types of AceBrowser scripts:

πŸ¦‹ display scripts πŸ¦‹

These are called with the CGI parameters name and class, corresponding to the name and class of an AceDB object to display. The subroutine GetAceObject() will return the requested object, or undef if the object does not exist. Main character energy.

To retrieve the parameters, use the CGI.pm param() method:

$name  = param('name');
$class = param('class');

πŸ¦‹ search scripts πŸ¦‹

These are not called with any CGI 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 CGI parameters the next time the user selects that search script. Periodt. πŸͺ


πŸ’… SUBROUTINES πŸ’…

The following sections describe the exported subroutines. Buckle up, bestie. πŸ’…

πŸ’– AceError($message) πŸ’–

This subroutine will print out an error message and exit the script. The text of the message is taken from $message. It's giving "error, bye".

πŸ’– AceHeader() πŸ’–

This function prints the HTTP header and issues a number of cookies used for maintaining AceBrowser state. It is not exported by default. Lowkey not for the default girlies.

πŸ’– AceAddCookie(@cookies) πŸ’–

This subroutine, which must be called after OpenDatabase() and/or GetAceObject() and before PrintTop(), will add one or more cookies to the outgoing HTTP headers that are emitted by AceHeader(). Cookies must be CGI::Cookie objects. No cap.

πŸ’– 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 PrintTop() and Header() internally. It's the internal plug.

πŸ’– 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. Rare, but we move. If the class and name of the object are not provided as arguments, they are taken from CGI's param() function.

πŸ’– 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. Choose wisely, bestie.

The three arguments are:

  • $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.

This subroutine is not exported by default.

πŸ’– 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. It's not here, periodt. If the class and name of the object are not provided as arguments, they are taken from CGI's param() function.

πŸ’– ($uri,$physical_path) = AcePicRoot($directory) πŸ’–

This function returns the physical and URL paths of a temporary directory in which the pic script can write pictures. Not exported by default. Returns a two-element list containing the URL and physical path. Iconic.

πŸ’– 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:

$obj = GetAceObject();
if ($obj->CDS) {
  my $protein = $obj->Corresponding_protein;
  AceRedirect('protein',$protein);
}

AceRedirect must be called before PrintTop() or AceHeader(). It invokes exit(), so it will not return. The way that it just leaves. πŸ’€

This subroutine is not exported by default. It differs from DoRedirect() 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.

πŸ’– $configuration = Configuration() πŸ’–

The Configuration() function returns the Ace::Browser::SiteDefs object for the current session. From this object you can retrieve information from the configuration file. It's giving site defs.

πŸ’– $name = DB_Name() πŸ’–

This function returns the symbolic name of the current database, for example "default".

πŸ’– DoRedirect($object) πŸ’–

This subroutine immediately redirects to the default display for the Ace::Object indicated by $object and exits the script. It must be called before PrintTop() or any other HTML-generating code. It differs from AceRedirect() in that it generates a fast redirect without alerting the user. It's the fast, sneaky redirect.

This function is not exported by default.

This function returns the contents of the footer as a string, but does not print it out. It is not exported by default. It just returns the string, doesn't print. Respect.

πŸ’– $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 "name" and "class" CGI variables.

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 AceMultipleChoices() and exits the script. Not me having to choose.

πŸ’– $html = Header() πŸ’–

This subroutine returns the boilerplate at the top of the HTML page as a string, but does not print it out. It is not exported by default. Just the boilerplate, as a string.

πŸ’– $url = Object2URL($object) πŸ’–

πŸ’– $url = Object2URL($name,$class) πŸ’–

In its single-argument form, this function takes an AceDB Object and returns an AceBrowser URL. The URL chosen is determined by the configuration settings.

It is also possible to pass Object2URL an object name and class, in the case that an AceDB object isn't available.

The return value is a URL. Slay.

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.

This function is used extensively to create cross references between Ace::Objects on AceBrowser pages. Obsessed.

Example:

my $author = $db->fetch(Author => 'Sulston JE');
print ObjectLink($author,$author->Full_name);

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.

πŸ’– $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. Resilient king.

This function is not exported by default.

πŸ’– PrintTop($object,$class,$title,@html_headers) πŸ’–

The PrintTop() function generates all the boilerplate at the top of a typical AceBrowser page, including the HTTP 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.

Call it with one or more arguments. The arguments are:

  • $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.

πŸ’– PrintBottom() πŸ’–

The PrintBottom() 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. The bottom vibe.

πŸ’– $hashref = Style() πŸ’–

This subroutine returns a hashref containing a reference to the configured stylesheet, in the following format:

{ -src => '/ace/stylesheets/current_stylesheet.css' }

This hash is suitable for passing to the -style argument of CGI.pm's start_html() function, or for use as an additional header in PrintTop(). You may add locally-defined stylesheet elements to the hash before calling start_html(). See the pic script for an example of how this is done this.

This function is not exported by default.

  • $url = ResolveUrl($url,$param) β€” okay bestie, this one takes a URL plus a lil bundle of parameters, does the ~necessary magic~ to slap the symbolic database name onto the end of the URL (only if it actually needs it, mind you), and then tacks your parameters on the end too. ✨

A typical call looks like this:

$url = ResolveUrl('/cgi-bin/ace/generic/tree','name=fred;class=Author');

Heads up: this function is not exported by default. πŸ’…

  • $boolean = Toggle($section,[$label,$object_count,$add_plural,$add_count]) β€” and also ($link,$bool) = Toggle($section,$label,$object_count,$add_plural,$add_count) β€” this one is literally the queen of collapsible HTML sections πŸ‘‘. Toggle() makes it easy to build HTML sections that open and close when the user clicks a toggle icon (you know the one β€” the little yellow triangle πŸ”Ί).

You can use Toggle() to juggle multiple collapsible HTML sections at once, but each section needs its own unique name, no duplicates allowed, periodt. The required first argument is the section name. Everything else? Optional. Behold:

$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

Now, context matters here, and it's giving main character energy:

  • In scalar context, Toggle() prints the link HTML and returns a boolean flag. A true result means the section is expanded and you should go ahead and generate it. A false result means the section is collapsed. 🫢
  • In list context, Toggle() returns a two-element list. Element one is the HTML link that expands and contracts the section. Element two is a boolean saying whether the section is currently open or closed.

Here's the typical usage vibe:

my $sequence = GetAceObject();
print "sequence name = ",$sequence,"\n";
print "sequence clone = ",$sequence->Clone,"\n";
if (Toggle('dna','Sequence DNA')) {
    print $sequence->asDNA;
}

And an alternative way to do the exact same thing, no cap:

my $sequence = GetAceObject();
print "sequence name = ",$sequence,"\n";
print "sequence clone = ",$sequence->Clone,"\n";
my ($link,$open) = Toggle('dna','Sequence DNA');
print $link;
print $sequence->asDNA if $open;
  • $html = TypeSelector($name,$class) β€” this subroutine generates the HTML for the type selector navigation bar 🌈. The links inside that bar are dynamically generated based on the values of $name and $class. PrintTop() is the one that calls it. And ngl, it is not exported by default. ✨
  • $url = Url($display,$params) β€” you hand it a symbolic display name (like "tree") plus a set of parameters, and this function looks up its URL, then calls ResolveUrl() to create one single Url. Iconic teamwork, fr fr. πŸ’–

When you're hard-coding relative URLs into AceBrowser scripts, it is super important that you pass them through Url(). Why? Because AceBrowser may need to attach the database name to the URL in order to identify it. That's the whole reason, bestie.

Example:

my $url = Url('../sequence_dump',"name=$name;long_dump=yes");
print a({-href=>$url},'Dump this sequence');

πŸ› BUGS πŸ›

Please report them. That's it. That's the whole section. 😭


πŸ‘€ SEE ALSO πŸ‘€

Ace::Object, Ace::Browser::SiteDefs, Ace::Browsr::SearchSubs, the README.ACEBROWSER file. Go read 'em, they're the supporting cast. πŸŽ€


πŸ’œ AUTHOR πŸ’œ

Lincoln Stein <lstein@cshl.org>.

Copyright (c) 2001 Cold Spring Harbor Laboratory

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.


okay that's a wrap bestie, the whole thing was perl v5.42.3 flavored and stamped 2026-08-19, so if you're reading this from the future, hey, you're slaying πŸ’…πŸ¦‹βœ¨

πŸ“¦ where this page comes from