[Bio] / FigWebServices / link.cgi Repository:
ViewVC logotype

View of /FigWebServices/link.cgi

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.5 - (download) (annotate)
Tue Apr 10 04:00:31 2007 UTC (12 years, 9 months ago) by parrello
Branch: MAIN
Changes since 1.4: +39 -38 lines
Added documentation for the SOP support.

#!/usr/bin/perl -w

=head1 Protein Page Link

This is a simple redirection script that takes a string as input and opens
the appropriate page.

This script supports the following CGI query parameters.

=over 4

=item id

ID of the desired feature. This can be a FIG ID or an alias. If it is preceded
by C<nmpdr|>, then we will try to force the Sprout protein page.

=item sop

ID of a procedure in the SEED wiki.



use strict;
use Tracer;
use CGI;
use URI::Escape;

my $url;

my $cgi = CGI->new();
eval {
    #check for SOP
    my $sopID = $cgi->param('sop');
    if ($sopID) {
        if ($sopID =~ /SOP010/i) {
                $url = "http://www.theseed.org/w/images/2/23/Annotation_sop.pdf";
                print $cgi->redirect(-uri => $url);
        } else {
                Confess("Invalid SOP number");
    } else {
        # Get the protein ID.
        my $pegID = $cgi->param('id');
        if (! $pegID) {
            # No protein ID, so we fail.
            Confess("No ID specified.");
        } else {
            # The code will compute a redirection URL and put it in the variable below.
            # Check for an NMPDR or SEED viewer ID.
            if ($pegID =~ /^nmpdr\|(.+)$/) {
                # Escape the PEG found.
                my $escapedID = uri_escape($1);
                # If we have an NMPDR defined, use it.
                if ($FIG_Config::nmpdr_site_url) {
                    $url = "$FIG_Config::nmpdr_site_url/FIG/protein.cgi?SPROUT=1;prot=$escapedID";
                } else {
                    # No NMPDR, so we ask for a protein page.
                    $url = "protein.cgi?prot=$escapedID";
            } else {
                # Go to a protein page, but try to decide whether we should be SEED or Sprout.
                my $mode = $cgi->param('SPROUT');
                if (! defined $mode) {
                    $mode = ($FIG_Config::nmpdr_site_url ? 1 : 0);
                my $escapedID = uri_escape($pegID);
                $url = "protein.cgi?prot=$escapedID;SPROUT=$mode";
            print $cgi->redirect(-uri => $url);
if ($@) {
    # Get the error message.
    my $errorMessage = $@;
    Trace("Script Error: $errorMessage") if T(0);
    # Display the error message. Note that unlike most situations,
    # we have to write a content header. This is because we have a
    # redirection script rather than a standard CGI script.
    print "CONTENT-TYPE: text/html\n\n";
    print "<html><body>\n";
    print $cgi->h3("Error in redirection: $errorMessage") . "\n";
    print "</body></html>\n\n";


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3