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

View of /FigWebServices/link.cgi

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.3 - (download) (annotate)
Wed Oct 25 21:06:09 2006 UTC (13 years, 2 months ago) by parrello
Branch: MAIN
Changes since 1.2: +0 -10 lines
*** empty log message ***

#!/usr/bin/perl -w

=head1 Protein Page Link

This is a simple redirection script that takes a feature name as input and opens
the appropriate protein page. The feature name can be a FIG feature ID or
an external alias.

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. If it is preceded
by C<sv|>, then we will try to force the Seed Viewer.



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

my $cgi = CGI->new();
eval {
    # 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.
        my $url;
        # 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