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

Diff of /FigWebServices/link.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Mon Oct 2 03:03:08 2006 UTC revision 1.2, Wed Oct 25 21:03:07 2006 UTC
# Line 12  Line 12 
12    
13  =item id  =item id
14    
15  ID of the desired feature. This can be a FIG ID or an alias.  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  =item Trace  by C<sv|>, then we will try to force the Seed Viewer.
   
 Trace level and list of trace modules to turn on, space-delimited. The  
 default is no tracing.  
   
 =item TF  
   
 C<1> to trace to a file, C<0> to trace to the web page itself. The  
 default is C<0>.  
18    
19  =back  =back
20    
# Line 31  Line 23 
23  use strict;  use strict;
24  use Tracer;  use Tracer;
25  use CGI;  use CGI;
 use Sprout;  
26  use URI::Escape;  use URI::Escape;
27    
28  my ($cgi, $varHash) = ScriptSetup();  my $cgi = CGI->new();
29    ETracing($cgi);
30  eval {  eval {
31      # Get the protein ID.      # Get the protein ID.
32      my $pegID = $cgi->param('id');      my $pegID = $cgi->param('id');
# Line 42  Line 34 
34          # No protein ID, so we fail.          # No protein ID, so we fail.
35          Confess("No ID specified.");          Confess("No ID specified.");
36      } else {      } else {
37          # Escape the incoming ID.          # The code will compute a redirection URL and put it in the variable below.
38          my $protID = uri_escape($pegID);          my $url;
39          # Determine the correct mode (seed or SPROUT).          # 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');          my $mode = $cgi->param('SPROUT');
63          if (! defined $mode) {          if (! defined $mode) {
64              $mode = ($FIG_Config::sproutDB ? 1 : 0);                  $mode = ($FIG_Config::nmpdr_site_url ? 1 : 0);
65                }
66                my $escapedID = uri_escape($pegID);
67                $url = "protein.cgi?prot=$escapedID;SPROUT=$mode";
68          }          }
         my $url = "protein.cgi?SPROUT=1;prot=$protID;SPROUT=$mode";  
         # Redirect to the protein page.  
69          print $cgi->redirect(-uri => $url);          print $cgi->redirect(-uri => $url);
70      }      }
71  };  };
# Line 60  Line 75 
75      Trace("Script Error: $errorMessage") if T(0);      Trace("Script Error: $errorMessage") if T(0);
76      # Display the error message. Note that unlike most situations,      # Display the error message. Note that unlike most situations,
77      # we have to write a content header. This is because we have a      # we have to write a content header. This is because we have a
78      # redirection script ratherh than a standard CGI script.      # redirection script rather than a standard CGI script.
     $varHash->{results} = $cgi->h3("Script Error: $errorMessage");  
79      print "CONTENT-TYPE: text/html\n\n";      print "CONTENT-TYPE: text/html\n\n";
80      ScriptFinish("Simple_tmpl.php", $varHash);      print "<html><body>\n";
81        print $cgi->h3("Error in redirection: $errorMessage") . "\n";
82        print "</body></html>\n\n";
83  }  }
84    
85  1;  1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3