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

Annotation of /FigWebServices/link.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (view) (download)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     =head1 Protein Page Link
4 :    
5 :     This is a simple redirection script that takes a feature name as input and opens
6 :     the appropriate protein page. The feature name can be a FIG feature ID or
7 :     an external alias.
8 :    
9 :     This script supports the following CGI query parameters.
10 :    
11 :     =over 4
12 :    
13 :     =item id
14 :    
15 : parrello 1.2 ID of the desired feature. This can be a FIG ID or an alias. If it is preceded
16 :     by C<nmpdr|>, then we will try to force the Sprout protein page. If it is preceded
17 :     by C<sv|>, then we will try to force the Seed Viewer.
18 : parrello 1.1
19 :     =back
20 :    
21 :     =cut
22 :    
23 :     use strict;
24 :     use Tracer;
25 :     use CGI;
26 :     use URI::Escape;
27 :    
28 : parrello 1.2 my $cgi = CGI->new();
29 :     ETracing($cgi);
30 : parrello 1.1 eval {
31 :     # Get the protein ID.
32 :     my $pegID = $cgi->param('id');
33 :     if (! $pegID) {
34 :     # No protein ID, so we fail.
35 :     Confess("No ID specified.");
36 :     } else {
37 : parrello 1.2 # The code will compute a redirection URL and put it in the variable below.
38 :     my $url;
39 :     # Check for an NMPDR or SEED viewer ID.
40 :     if ($pegID =~ /^nmpdr\|(.+)$/) {
41 :     # Escape the PEG found.
42 :     my $escapedID = uri_escape($1);
43 :     # If we have an NMPDR defined, use it.
44 :     if ($FIG_Config::nmpdr_site_url) {
45 :     $url = "$FIG_Config::nmpdr_site_url/FIG/protein.cgi?SPROUT=1;prot=$escapedID";
46 :     } else {
47 :     # No NMPDR, so we ask for a protein page.
48 :     $url = "protein.cgi?prot=$escapedID";
49 :     }
50 :     } else {
51 :     # Go to a protein page, but try to decide whether we should be SEED or Sprout.
52 :     my $mode = $cgi->param('SPROUT');
53 :     if (! defined $mode) {
54 :     $mode = ($FIG_Config::nmpdr_site_url ? 1 : 0);
55 :     }
56 :     my $escapedID = uri_escape($pegID);
57 :     $url = "protein.cgi?prot=$escapedID;SPROUT=$mode";
58 : parrello 1.1 }
59 :     print $cgi->redirect(-uri => $url);
60 :     }
61 :     };
62 :     if ($@) {
63 :     # Get the error message.
64 :     my $errorMessage = $@;
65 :     Trace("Script Error: $errorMessage") if T(0);
66 :     # Display the error message. Note that unlike most situations,
67 :     # we have to write a content header. This is because we have a
68 : parrello 1.2 # redirection script rather than a standard CGI script.
69 : parrello 1.1 print "CONTENT-TYPE: text/html\n\n";
70 : parrello 1.2 print "<html><body>\n";
71 :     print $cgi->h3("Error in redirection: $errorMessage") . "\n";
72 :     print "</body></html>\n\n";
73 : parrello 1.1 }
74 :    
75 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3