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

Annotation of /FigWebServices/link.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (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 : disz 1.4 my $url;
29 :    
30 : parrello 1.2 my $cgi = CGI->new();
31 :     ETracing($cgi);
32 : parrello 1.1 eval {
33 : disz 1.4 #check for SOP
34 :     my $sopID = $cgi->param('sop');
35 :     if ($sopID) {
36 :     if ($sopID =~ /SOP010/i) {
37 :     $url = "http://www.theseed.org/w/images/2/23/Annotation_sop.pdf";
38 :     print $cgi->redirect(-uri => $url);
39 :     } else {
40 :     Confess("Invalid SOP number");
41 :     }
42 :    
43 :     } else {
44 : parrello 1.1 # Get the protein ID.
45 :     my $pegID = $cgi->param('id');
46 :     if (! $pegID) {
47 :     # No protein ID, so we fail.
48 :     Confess("No ID specified.");
49 :     } else {
50 : parrello 1.2 # The code will compute a redirection URL and put it in the variable below.
51 :     # Check for an NMPDR or SEED viewer ID.
52 :     if ($pegID =~ /^nmpdr\|(.+)$/) {
53 :     # Escape the PEG found.
54 :     my $escapedID = uri_escape($1);
55 :     # If we have an NMPDR defined, use it.
56 :     if ($FIG_Config::nmpdr_site_url) {
57 :     $url = "$FIG_Config::nmpdr_site_url/FIG/protein.cgi?SPROUT=1;prot=$escapedID";
58 :     } else {
59 :     # No NMPDR, so we ask for a protein page.
60 :     $url = "protein.cgi?prot=$escapedID";
61 :     }
62 :     } else {
63 :     # Go to a protein page, but try to decide whether we should be SEED or Sprout.
64 :     my $mode = $cgi->param('SPROUT');
65 :     if (! defined $mode) {
66 :     $mode = ($FIG_Config::nmpdr_site_url ? 1 : 0);
67 :     }
68 :     my $escapedID = uri_escape($pegID);
69 :     $url = "protein.cgi?prot=$escapedID;SPROUT=$mode";
70 : parrello 1.1 }
71 :     print $cgi->redirect(-uri => $url);
72 :     }
73 : disz 1.4 }
74 : parrello 1.1 };
75 :     if ($@) {
76 :     # Get the error message.
77 :     my $errorMessage = $@;
78 :     Trace("Script Error: $errorMessage") if T(0);
79 :     # Display the error message. Note that unlike most situations,
80 :     # we have to write a content header. This is because we have a
81 : parrello 1.2 # redirection script rather than a standard CGI script.
82 : parrello 1.1 print "CONTENT-TYPE: text/html\n\n";
83 : parrello 1.2 print "<html><body>\n";
84 :     print $cgi->h3("Error in redirection: $errorMessage") . "\n";
85 :     print "</body></html>\n\n";
86 : parrello 1.1 }
87 :    
88 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3