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

Annotation of /FigWebServices/link.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (view) (download)

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3