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

Annotation of /FigWebServices/link.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (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 :     } elsif ($pegID =~ /^sv\|(.+)$/) {
51 :     # Escape the PEG found.
52 :     my $escapedID = uri_escape($1);
53 :     # If we have a SEED Viewer defined, use it.
54 :     if ($FIG_Config::seed_viewer_url) {
55 :     $url = "$FIG_Config::seed_viewer_url/protein.cgi?prot=$escapedID";
56 :     } else {
57 :     # No SEED viewer, so we ask for a protein page.
58 :     $url = "protein.cgi?prot=$escapedID";
59 :     }
60 :     } else {
61 :     # Go to a protein page, but try to decide whether we should be SEED or Sprout.
62 :     my $mode = $cgi->param('SPROUT');
63 :     if (! defined $mode) {
64 :     $mode = ($FIG_Config::nmpdr_site_url ? 1 : 0);
65 :     }
66 :     my $escapedID = uri_escape($pegID);
67 :     $url = "protein.cgi?prot=$escapedID;SPROUT=$mode";
68 : parrello 1.1 }
69 :     print $cgi->redirect(-uri => $url);
70 :     }
71 :     };
72 :     if ($@) {
73 :     # Get the error message.
74 :     my $errorMessage = $@;
75 :     Trace("Script Error: $errorMessage") if T(0);
76 :     # Display the error message. Note that unlike most situations,
77 :     # we have to write a content header. This is because we have a
78 : parrello 1.2 # redirection script rather than a standard CGI script.
79 : parrello 1.1 print "CONTENT-TYPE: text/html\n\n";
80 : parrello 1.2 print "<html><body>\n";
81 :     print $cgi->h3("Error in redirection: $errorMessage") . "\n";
82 :     print "</body></html>\n\n";
83 : parrello 1.1 }
84 :    
85 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3