[Bio] / FigKernelPackages / HTML.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/HTML.pm

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

revision 1.81, Tue Jan 24 23:51:22 2006 UTC revision 1.130, Mon Mar 23 13:28:14 2009 UTC
# Line 17  Line 17 
17    
18  package HTML;  package HTML;
19    
20    use strict;
21  use Tracer;  use Tracer;
22  use FIG;  use FIG;
23    use FIGRules;
24  use Carp;  use Carp;
25  use Data::Dumper;  use Data::Dumper;
26  use LWP::UserAgent;  use LWP::UserAgent;
# Line 27  Line 29 
29  use URI::URL;  use URI::URL;
30  use HTTP::Request::Common;  use HTTP::Request::Common;
31  use POSIX;  use POSIX;
32    use CGI;
33    
34    #use raelib; # now used for the excel function, that should eventually end up in here. Way too experimental!
35    my $raelib;
36    
37    
38  my $top_link_cache;  my $top_link_cache;
# Line 53  Line 59 
59    
60      my @parts = split(/\//, $ENV{SCRIPT_NAME});      my @parts = split(/\//, $ENV{SCRIPT_NAME});
61      my $top;      my $top;
62      if ($parts[-2] eq 'FIG')      if (defined $parts[-2] && $parts[-2] eq 'FIG')
63      {      {
64          $top = '.';          $top = '.';
65  #       warn "toplevel @parts\n";  #       warn "toplevel @parts\n";
66      }      }
67      elsif ($parts[-3] eq 'FIG')      elsif (defined $parts[-3] && $parts[-3] eq 'FIG')
68      {      {
69          $top = '..';          $top = '..';
70  #       warn "subdir @parts\n";  #       warn "subdir @parts\n";
# Line 78  Line 84 
84      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
85      my($additional_insert, $user, %options ) = @_;      my($additional_insert, $user, %options ) = @_;
86    
87        local $/ = "\n";
88    
89      my $header_name = $options{header_name} ? $options{header_name} : "html.hdr";      my $header_name = $options{header_name} ? $options{header_name} : "html.hdr";
90      my $tail_name = $options{tail_name} ? $options{tail_name} : "html.tail";      my $tail_name = $options{tail_name} ? $options{tail_name} : "html.tail";
91    
# Line 156  Line 164 
164  sub show_page {  sub show_page {
165      #warn "SHOWPAGE: cgi=", Dumper(@_);      #warn "SHOWPAGE: cgi=", Dumper(@_);
166      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
167      my($cgi,$html,$no_home, $alt_header, $css, $javasrc, $cookie) = @_;      my($cgi,$html,$no_home, $alt_header, $css, $javasrc, $cookie, $options) = @_;
168      my $i;      my $i;
169        Trace("Setting top link.") if T(3);
170      my $top = top_link();      my $top = top_link();
171    
172      # ARGUMENTS:      # ARGUMENTS:
# Line 171  Line 179 
179      #               the sheet named "Sans Serif" is considered to the the first alternate, and if this is not set it points at $FIG_Config::HTML/css/sanserif.css      #               the sheet named "Sans Serif" is considered to the the first alternate, and if this is not set it points at $FIG_Config::HTML/css/sanserif.css
180      #     $javasrc is a reference to an array of URLs to javascripts to be included (e.g. "FIG/Html/css/styleswitcher.js")      #     $javasrc is a reference to an array of URLs to javascripts to be included (e.g. "FIG/Html/css/styleswitcher.js")
181      #     $cookie is the name and value of the cookie to set. Note that you should probably use raelib->cookie to get/set your cookies      #     $cookie is the name and value of the cookie to set. Note that you should probably use raelib->cookie to get/set your cookies
182        #     $options is a reference to a hash of options that you can pass around the pages
183      #      #
184      # Find the HTML header      # Find the HTML header
185      #      #
186        Trace("Reading tail.") if T(3);
187        my $tail_name = $options->{tail_name} ? $options->{tail_name} : "html.tail";
188      my $html_tail_file = "./Html/$tail_name";      my $html_tail_file = "./Html/$tail_name";
189      if (! -f $html_tail_file)      if (! -f $html_tail_file)
190      {      {
191          $html_tail_file = "$FIG_Config::fig/CGI/Html/$tail_name";          $html_tail_file = "$FIG_Config::fig/CGI/Html/$tail_name";
192      }      }
193        Trace("Extracting user name and header data.") if T(3);
194      my $user = $cgi->param('user') || "";      my $user = $cgi->param('user') || "";
195      my @html_hdr;      my @html_hdr;
196      if ($alt_header && ref($alt_header) eq "ARRAY")      if ($alt_header && ref($alt_header) eq "ARRAY")
# Line 189  Line 199 
199      }      }
200      else      else
201      {      {
202          @html_hdr = compute_html_header(undef,$user);          @html_hdr = compute_html_header(undef,$user,%$options);
203      }      }
204    
205      # RAE: I am offloading the handling of cookies to CGI.pm since I don't know how they are set up.      # RAE: I am offloading the handling of cookies to CGI.pm since I don't know how they are set up.
# Line 197  Line 207 
207    
208      # Note: 3/10/05 commented this line out pending the discussion of adding cookies into the seed that we are waiting to see about      # Note: 3/10/05 commented this line out pending the discussion of adding cookies into the seed that we are waiting to see about
209      # to add cookies back in replace these two header lines with each other      # to add cookies back in replace these two header lines with each other
210        #my $hdr_thing = $cgi->header(-cookie=>$cookie);
211      #print $cgi->header(-cookie=>$cookie);      my $hdr_thing = $cgi->header();
212      print $cgi->header();      Trace("Printing HTML header: $hdr_thing.") if T(3);
213        print $hdr_thing;
214        Trace("Header printed.") if T(3);
215      #      #
216      #  The SEED header file goes immediately after <BODY>.  Figure out      #  The SEED header file goes immediately after <BODY>.  Figure out
217      #  what parts of the HTML document skeleton are there, and fill in      #  what parts of the HTML document skeleton are there, and fill in
# Line 245  Line 256 
256      my $body_line = -1;      my $body_line = -1;
257      my $last_head_line = -1;  #  If no head tags are found, text goes at top.      my $last_head_line = -1;  #  If no head tags are found, text goes at top.
258      my $done = 0;      my $done = 0;
259        Trace("Processing special cases.") if T(3);
260      for ( $i = 0; $i < @$html; $i++ )      for ( $i = 0; $i < @$html; $i++ )
261      {      {
262          #  Some special cases:          #  Some special cases:
# Line 291  Line 302 
302    
303      if ( 1 )      if ( 1 )
304      {      {
305            Trace("Sanity checks in progress.") if T(3);
306          if ( $html_line >= 0 )          if ( $html_line >= 0 )
307          {          {
308              if ( ( $head_line >= 0 ) && ( $html_line > $head_line ) )              if ( ( $head_line >= 0 ) && ( $html_line > $head_line ) )
309              {              {
310                  print STDERR "<HTML> tag follows <HEAD> tag\n";                  Trace("<HTML> tag follows <HEAD> tag.") if T(1);
311              }              }
312              if ( ( $head_end_line >= 0 ) && ( $html_line > $head_end_line ) )              if ( ( $head_end_line >= 0 ) && ( $html_line > $head_end_line ) )
313              {              {
314                  print STDERR "<HTML> tag follows </HEAD> tag\n";                  Trace("<HTML> tag follows </HEAD> tag.") if T(1);
315              }              }
316          }          }
317          if ( $head_line >= 0 )          if ( $head_line >= 0 )
318          {          {
319              if ( ( $head_end_line >= 0 ) && ( $head_line > $head_end_line ) )              if ( ( $head_end_line >= 0 ) && ( $head_line > $head_end_line ) )
320              {              {
321                  print STDERR "<HEAD> tag follows </HEAD> tag\n";                  Trace("<HEAD> tag follows </HEAD> tag.") if T(1);
322              }              }
323          }          }
324      }      }
325        Trace("Sanity checks complete.") if T(3);
326      #      #
327      #  Okay.  Let's put in the html header file, and missing tags:      #  Okay.  Let's put in the html header file, and missing tags:
328      #      #
# Line 321  Line 333 
333      #  Note if no buttons are added we still (at the moment) add the script,      #  Note if no buttons are added we still (at the moment) add the script,
334      #  but it only adds a little text (495 characters) to the html and noone will notice!      #  but it only adds a little text (495 characters) to the html and noone will notice!
335      #  RAE: This is now deprecated because everything is in an external file, FIG.js, included later      #  RAE: This is now deprecated because everything is in an external file, FIG.js, included later
   
336      if ( $body_line < 0 )      if ( $body_line < 0 )
337      {      {
338          $body_line = $last_head_line + 1;          $body_line = $last_head_line + 1;
339            Trace("Splicing body line at $body_line.") if T(3);
340          splice( @$html, $body_line, 0, "<BODY>\n" );          splice( @$html, $body_line, 0, "<BODY>\n" );
341      }      }
342    
# Line 334  Line 346 
346    
347      if (@html_hdr)      if (@html_hdr)
348      {      {
349            Trace("Splicing SEED page header after $body_line.") if T(3);
350          splice( @$html, $body_line + 1, 0, @html_hdr );          splice( @$html, $body_line + 1, 0, @html_hdr );
351      }      }
352    
# Line 344  Line 357 
357      if ( $head_end_line < 0 )      if ( $head_end_line < 0 )
358      {      {
359          $head_end_line = $body_line;          $head_end_line = $body_line;
360            Trace("Splicing header terminater at $body_line.") if T(3);
361          splice( @$html, $body_line, 0, "</HEAD>\n" );          splice( @$html, $body_line, 0, "</HEAD>\n" );
362      }      }
363    
# Line 353  Line 367 
367      # be moved out, but I want to try it and see what happens.  css has the format:      # be moved out, but I want to try it and see what happens.  css has the format:
368      #      #
369      # <link rel='stylesheet' title='default' href='/css/default.css' type='text/css'>      # <link rel='stylesheet' title='default' href='/css/default.css' type='text/css'>
370        Trace("Formatting CSS.") if T(3);
371      # convert the default key to the right case. and eliminate dups      # convert the default key to the right case. and eliminate dups
372      foreach my $k (keys %$css) {if (lc($k) eq "default") {$css->{'Default'}=$css->{$k}}}      foreach my $k (keys %$css) {if (lc($k) eq "default") {$css->{'Default'}=$css->{$k}}}
373    
# Line 383  Line 397 
397    
398      # the file FIG.js contains most of the java script we use routinely. Every browser will just cache this and so      # the file FIG.js contains most of the java script we use routinely. Every browser will just cache this and so
399      # it will reduce our overhead.      # it will reduce our overhead.
400        Trace("Formatting javascript.") if T(3);
401      # $javasrc must be a ref to an array with urls (absolute or relative) to the javascripts      # $javasrc must be a ref to an array with urls (absolute or relative) to the javascripts
402      push @$javasrc, "Html/css/FIG.js";      push @$javasrc, "$FIG_Config::cgi_url/Html/css/FIG.js";
403      foreach my $script (@$javasrc) {      foreach my $script (@$javasrc) {
404          $csstext .= "<script src=\"$script\" type=\"text/javascript\"></script>\n";          $csstext .= "<script src=\"$script\" type=\"text/javascript\"></script>\n";
405      }      }
406    
407        Trace("Re-splicing the header terminator at $head_end_line.") if T(3);
   
408      splice( @$html, $head_end_line, 1, "$csstext</HEAD>\n" );  # note here I am replacing the </head> line. Could be bad...? But it doesn't increment everything else.      splice( @$html, $head_end_line, 1, "$csstext</HEAD>\n" );  # note here I am replacing the </head> line. Could be bad...? But it doesn't increment everything else.
409    
410      #      #
# Line 409  Line 422 
422          # BASE href needs to be absolute. RDO.          # BASE href needs to be absolute. RDO.
423          #          #
424          #          #
425          $base_url = &FIG::cgi_url;  #        $base_url = &FIG::cgi_url;
426  #       my $base_url = $FIG_Config::cgi_base;  #       my $base_url = $FIG_Config::cgi_base;
427  #       if ( ! $base_url )                      # if cgi_base was not defined  #       if ( ! $base_url )                      # if cgi_base was not defined
428  #       {  #       {
# Line 432  Line 445 
445      if ( $html_line < 0 )      if ( $html_line < 0 )
446      {      {
447          $html_line = 0;          $html_line = 0;
448            Trace("Splicing the HTML tag at $html_line.") if T(3);
449          splice( @$html, $html_line, 0, "<HTML>\n" );          splice( @$html, $html_line, 0, "<HTML>\n" );
450      }      }
451    
# Line 442  Line 456 
456      if ( $head_line < 0 )      if ( $head_line < 0 )
457      {      {
458          $head_line = $html_line + 1;          $head_line = $html_line + 1;
459            Trace("Splicing the HEAD tag at $head_line.") if T(3);
460          splice( @$html, $head_line, 0, "<HEAD>\n" );          splice( @$html, $head_line, 0, "<HEAD>\n" );
461      }      }
462    
463      #      #
464      #  Place FIG search link at bottom of page      #  Place FIG search link at bottom of page
465      #      #
466        Trace("Placing FIG search link.") if T(3);
467      my @tail = -f $html_tail_file ? `cat $html_tail_file` : ();      my @tail = -f $html_tail_file ? `cat $html_tail_file` : ();
468      if (! $no_home)      if (! $no_home)
469      {      {
# Line 459  Line 474 
474      #      #
475      # See if we have a site-specific tail (for disclaimers, etc).      # See if we have a site-specific tail (for disclaimers, etc).
476      #      #
477        Trace("Placing site tail.") if T(3);
478      my $site_tail = "$FIG_Config::fig_disk/config/site_tail.html";      my $site_tail = "$FIG_Config::fig_disk/config/site_tail.html";
479      my $site_fh;      my $site_fh;
480      if (open($site_fh, "<$site_tail"))      if (open($site_fh, "<$site_tail"))
# Line 473  Line 488 
488      #  or before </html>, or at end of page.      #  or before </html>, or at end of page.
489      #      #
490      my @tags = ();      my @tags = ();
491      # Check for a tracing queue.      Trace("Processing closing tags.") if T(3);
     my $traceString = QTrace("HTML");  
     if ($traceString) {  
         push @tags, $traceString;  
     }  
492      for ($i=0; ($i < @$html) && ($html->[$i] !~ /\<\/body\>/i); $i++) {}      for ($i=0; ($i < @$html) && ($html->[$i] !~ /\<\/body\>/i); $i++) {}
493      if ($i >= @$html)        # </body> not found; look for </html>      if ($i >= @$html)        # </body> not found; look for </html>
494      {      {
# Line 492  Line 503 
503    
504      if ( @tail )      if ( @tail )
505      {      {
506            Trace("Splicing tail.") if T(3);
507          splice( @$html, $i, 0, @tail, @tags );          splice( @$html, $i, 0, @tail, @tags );
508      }      }
509      elsif ( @tags )      elsif ( @tags )
510      {      {
511            Trace("Splicing tags.") if T(3);
512          splice( @$html, $i, 0, @tags );          splice( @$html, $i, 0, @tags );
513      }      }
514    
515        Trace("Printing the HTML array.") if T(3);
516      # RAE the chomp will return any new lines at the ends of elements in the array,      # RAE the chomp will return any new lines at the ends of elements in the array,
517      # and then we can join  with a "\n". This is because somethings put newlines in,      # and then we can join  with a "\n". This is because somethings put newlines in,
518      # and others don't. This should make nicer looking html      # and others don't. This should make nicer looking html
# Line 507  Line 521 
521      # print join "\n", @$html;      # print join "\n", @$html;
522      #      #
523      # Apparently the above still breaks things. This is the correct code:      # Apparently the above still breaks things. This is the correct code:
   
524      foreach $_ (@$html)      foreach $_ (@$html)
525      {      {
526          print $_;          my $line = $_;
527            if (T(4)) {
528                my $escapedLine = Tracer::Clean($line);
529                Trace("Printing:\n$escapedLine") if T(4);
530            }
531            print $line;
532      }      }
533    
534  }  }
535    
536    
537    =head1 make_table
538    
539    The main method to convert an array into a table.
540    
541    The col_hdrs are set to the <th> headers, the $tab is an array of arrays. The first is the rows, and the second is the columns. The title is the title of the table.
542    
543    The options define the settings for the table such as border, width, and class for css formatting. If the option "excelfile" is set to a filename that will be created in FIG_Config::temp, and the link included that allows the user to download the file as an excel file.
544    
545    =cut
546    
547  sub make_table {  sub make_table {
548      my($col_hdrs,$tab,$title, %options ) = @_;      my($col_hdrs,$tab,$title, %options ) = @_;
549      my(@tab);      my(@tab);
550    
551      my $border = defined $options{border} ? "border=\"$options{border}\"" : "border";      my $border = defined $options{border} ? "border=\"$options{border}\"" : "border";
552      my $width = defined $options{width} ? "width=\"$options{width}\"" : undef;      my $width = defined $options{width} ? "width=\"$options{width}\"" : "";
553      my $class = defined $options{class} ? "class=\"$options{class}\"" : undef;      my $class = defined $options{class} ? "class=\"$options{class}\"" : "";
554      push( @tab, "\n<table $border $width $class>\n",      push( @tab, "\n<table $border $width $class>\n",
555                  "\t<caption><b>$title</b></caption>\n",                  "\t<caption><b>$title</b></caption>\n",
556                  "\t<tr>\n\t\t"                  "\t<tr>\n\t\t"
# Line 539  Line 568 
568              );              );
569      }      }
570      push(@tab,"</table>\n");      push(@tab,"</table>\n");
571    
572        # excelfile should be appropriate for a filename (no spaces/special characters)
573        if (defined $options{"excelfile"}) {
574            if (! defined($raelib)) {
575                require raelib;
576                $raelib = new raelib;
577            }
578            push @tab, $raelib->tab2excel($col_hdrs,$tab,$title,\%options,$options{"excelfile"})}
579    
580      return join("",@tab);      return join("",@tab);
581  }  }
582    
# Line 780  Line 818 
818      return "<a href=$link>$role</a>";      return "<a href=$link>$role</a>";
819  }  }
820    
821  #  =head2 fid_link
822  # Local means to eliminate the fig|org.peg from the  
823  # text of the link.  Get a link to a fid.
824  #  
825    use: my $html=&HTML::fid_link($cgi, $fid, Local, Just_URL, Full_Path);
826    
827    Local is a boolean means to eliminate the fig|org.peg from the text of the link.
828    
829    Just_URL will only return the URL and not the HTML code. The default is to return the full code.
830    
831    Full_Path is a boolean that will get the full path to the URL not just a relative path. This is required in pages where the base href changes (e.g. if an image is imported like on the metabolic pages).
832    
833    =cut
834    
835    
836  sub fid_link {  sub fid_link {
837      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
838      my($cgi,$fid,$local,$just_url) = @_;      my($cgi,$fid,$local,$just_url,$fullpath) = @_;
839        Trace("Creating link for feature $fid.") if T(4);
840        my $err=join(" ", $cgi,$fid,$local,$just_url,$fullpath);
841        if (FIGRules::nmpdr_mode($cgi)) {
842            # We're NMPDR. Compute the link to the seed viewer feature page.
843            my $link = "seedviewer.cgi?page=Annotation;feature=$fid";
844            if ($fullpath) {
845                # Full-path mode: add the base URL.
846                $link = "$FIG_Config::cgi_url/$link";
847            }
848            if ($just_url) {
849                # URL-only mode: return the link.
850                return $link;
851            } else {
852                # HTML mode. We need to compute the link text.
853                my $text = $fid;
854                # If we're in local mode, we remove everything but the final number from the fig ID.
855                if ($local) {
856                    $fid =~ s/^.+\.//;
857                }
858                # Return the full HTML for the link.
859                return "<a href=\"$link\">$text</a>";
860            }
861        }
862      my($n);      my($n);
863    
864      my $top = top_link();      my $top = top_link();
865        if ($fullpath) {$top=$FIG_Config::cgi_url}
866    
867      if ($fid =~ /^fig\|\d+\.\d+\.([a-z]+)\.(\d+)/)      if ($fid =~ /^fig\|\d+\.\d+\.([a-zA-Z]+)\.(\d+)/)
868      {      {
869          if ($local)          if ($local)
870          {          {
# Line 810  Line 883 
883          }          }
884    
885          my $link;          my $link;
886            my $new_framework = $cgi->param('new_framework') ? 1 : 0;
887          #added to format prophage and path island links to feature.cgi          #added to format prophage and path island links to feature.cgi
888          if ($1 ne "peg")          my $sprout = $cgi->param('SPROUT') ? "&SPROUT=1" : "";
889            my $virt = "&48hr_job=" . $cgi->param("48hr_job");
890            Trace("Sprout mode is \"$sprout\".") if T(4);
891            if ($1 ne "peg" && ! $sprout)
892          {          {
893               Trace("Creating feature link for $fid.") if T(4);
894             my $user = $cgi->param('user');             my $user = $cgi->param('user');
895             if (! $user) { $user = "" }             if (! $user) { $user = "" }
896             my $sprout = $cgi->param('SPROUT') ? "&SPROUT=1" : "";             $link = "$top/feature.cgi?feature=$fid&user=$user$sprout$virt";
            $link = "$top/feature.cgi?feature=$fid&user=$user$trans$sprout";  
897             $link =~ s/[a-z_A-Z0-9]+\.cgi\?/feature.cgi?/;             $link =~ s/[a-z_A-Z0-9]+\.cgi\?/feature.cgi?/;
898          }          }
899          else          else
900          {          {
901                Trace("Creating protein link for $fid.") if T(4);
902              my $user = $cgi->param('user');              my $user = $cgi->param('user');
903              if (! $user) { $user = "" }              if (! $user) { $user = "" }
904              my $trans = $cgi->param('translate') ? "&translate=1" : "";              my $trans = $cgi->param('translate') ? "&translate=1" : "";
# Line 836  Line 914 
914    
915              #if (! $cgi_url) { $cgi_url = &FIG::cgi_url }              #if (! $cgi_url) { $cgi_url = &FIG::cgi_url }
916              #$link = $cgi_url . "/protein.cgi?prot=$fid&user=$user$trans$sprout";              #$link = $cgi_url . "/protein.cgi?prot=$fid&user=$user$trans$sprout";
917              $link = "$top/protein.cgi?prot=$fid&user=$user$trans$sprout";              $link = "$top/protein.cgi?prot=$fid&user=$user$trans$sprout$virt\&new_framework=$new_framework";
918              $link =~ s/[a-z_A-Z0-9]+\.cgi\?/protein.cgi?/;              $link =~ s/[a-z_A-Z0-9]+\.cgi\?/protein.cgi?/;
919          }          }
920          if ($just_url)          if ($just_url)
# Line 845  Line 923 
923          }          }
924          else          else
925          {          {
926              return "<a href=$link>$n</a>";              return "<a target=_blank href='$link'>$n</a>";
927          }          }
928      }      }
929      return $fid;      return $fid;
# Line 858  Line 936 
936      return $family;      return $family;
937  }  }
938    
939    =head2 evidence_codes_explain
940    
941    Given an evidence code, returns a string that explains this eveidence code.
942    
943    =cut
944    
945    sub evidence_codes_explain {
946     my($ec)=@_;
947     return unless ($ec);
948    
949     $ec=uc($ec);
950     return "IDA: Inferred from Direct Assay" if ($ec =~ /IDA/);
951     return "IGI: Inferred from Genetic Interaction" if ($ec =~ /IGI/);
952     return "TAS: Traceable Author Statement" if ($ec =~ /TAS/);
953     return "ISU: in subsystem unique" if ($ec =~ /ISU/);
954     return "$ec: in subsystem duplicates" if ($ec =~ /IDU/);
955     return "$ec: in cluster with" if ($ec =~ /ICW/);
956     return "FF: in FIGfam" if ($ec =~ /FF/);
957     return "CWN: clustered with nonhypothetical" if ($ec =~ /CWN/);
958     return "CWH: clustered, but only with hypotheticals" if ($ec =~ /CWH/);
959     return "DLIT: literature references to this gene exist" if ($ec =~ /DLIT/);
960     return "ILIT: no references to this gene exist, but they do to other genes with the same functional role" if ($ec =~ /ILIT/);
961     return "$ec: unknown!";
962    }
963    
964  sub get_html {  sub get_html {
965      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
# Line 877  Line 979 
979          my $response = $ua->request($request);          my $response = $ua->request($request);
980          $out = $response->content;          $out = $response->content;
981      }      }
982      else  
983        if ($type =~/get/i)
984      {      {
985          @args = ();          @args = ();
986          foreach $x (@$kv_pairs)          foreach $x (@$kv_pairs)
# Line 889  Line 992 
992          {          {
993              $url .= "?" . join("&",@args);              $url .= "?" . join("&",@args);
994          }          }
995          $request = new HTTP::Request('GET', $url);          my $request = new HTTP::Request('GET', $url);
996          my $response = $ua->request($request);          my $response = $ua->request($request);
997    
998          if ($response->is_success)          if ($response->is_success)
# Line 907  Line 1010 
1010    
1011  #   Now splice in a line of the form <base href=URL> to cause all relative links to work  #   Now splice in a line of the form <base href=URL> to cause all relative links to work
1012  #   properly.  Remove the header.  #   properly.  Remove the header.
1013        my $i;
1014      for ($i=0; ($i < @output) && ($output[$i] !~ /^\s*\</); $i++) {}      for ($i=0; ($i < @output) && ($output[$i] !~ /^\s*\</); $i++) {}
1015      if ($i < @output)      if ($i < @output) {
     {  
   
1016          splice(@output,0,$i);          splice(@output,0,$i);
1017      }      }
1018    
# Line 927  Line 1028 
1028  sub trim_output {  sub trim_output {
1029      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1030      my($out) = @_;      my($out) = @_;
1031      my $i;      my ($i, $j);
1032    
1033      for ($i=0; ($i < @$out) && ($out->[$i] !~ /^\</); $i++) {}      for ($i=0; ($i < @$out) && ($out->[$i] !~ /^\</); $i++) {}
1034      splice(@$out,0,$i);      splice(@$out,0,$i);
# Line 956  Line 1057 
1057      for ($j=$i-1; ($j > 0) && ($out->[$j] !~ /FIG search/); $j--) {}      for ($j=$i-1; ($j > 0) && ($out->[$j] !~ /FIG search/); $j--) {}
1058      if ($j > 0)      if ($j > 0)
1059      {      {
1060            #
1061            # Hm. We would have tried using the options here:
1062            # my $tail_name = $options{tail_name} ? $options{tail_name} : "html.tail";
1063            # but they're not passed in. So use the default html.tail.
1064            #
1065            my $html_tail_file = "./Html/html.tail";
1066          my @tmp = `cat $html_tail_file`;          my @tmp = `cat $html_tail_file`;
1067          my $n = @tmp;          my $n = @tmp;
1068          splice(@$out,$j-$n,$n+1);          splice(@$out,$j-$n,$n+1);
1069      }      }
1070  }  }
1071    
1072    =head2 alias_rl
1073    
1074    Returns the url that links to an external page showing information about the given alias.
1075    The type of the alias will be determined by the prefix (i.e. 'tr|' for Trembl) If the type
1076    cannot be determined, the function will return undef.
1077    
1078    use: my $html=&HTML::alias_url($alias, $type);
1079    
1080    =cut
1081    
1082    sub alias_url {
1083      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1084    
1085      my ($id, $type) = @_;
1086    
1087      if ($type eq "SEED") { # 1
1088        return "http://seed-viewer.theseed.org/linkin.cgi?id=$id";
1089      }
1090      elsif ($type eq "UniProt") {
1091        return "http://www.uniprot.org/entry/$id";
1092      }
1093      elsif ($type eq "UniProt_ac") { # 2
1094        return "http://www.uniprot.org/entry/$id";
1095      }
1096      elsif ($type eq "UniProt_id") { # 3
1097        return "http://www.uniprot.org/entry/$id";
1098      }
1099      elsif ($type eq "EntrezGene") { # 4
1100        return "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&id=$id";
1101      }
1102      elsif ($type eq "RefSeq") { # 5
1103        return "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&id=$id";
1104      }
1105      elsif ($type eq "GIID") { # 6
1106        return "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&id=$id";
1107      }
1108      elsif ($type eq "NCBI") {
1109        return "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&id=$id";
1110      }
1111      elsif ($type eq "PDB") { # 7
1112        $id =~ s/\:\w//;
1113        return "http://www.rcsb.org/pdb/explore/explore.do?structureId=$id";
1114      }
1115      elsif ($type eq "PFAM") { # 8
1116        return "http://pfam.janelia.org/family?acc=$id";
1117      }
1118      elsif ($type eq "GO") { # 9
1119        return "http://amigo.geneontology.org/cgi-bin/amigo/go.cgi?view=details&search_constraint=terms&depth=0&query=$id";
1120      }
1121      elsif ($type eq "PIRSF") { # 10
1122        return "http://pir.georgetown.edu/cgi-bin/ipcSF?id=$id";
1123      }
1124      elsif ($type eq "IPI") { # 11
1125        return "http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+[IPI-AllText:".$id."*]+-lv+30+-view+SeqSimpleView+-page+qResult";
1126      }
1127      elsif ($type eq "UniRef_100") { # 12
1128        return "http://www.uniprot.org/entry/$id";
1129      }
1130      elsif ($type eq "UniRef_90") { # 13
1131        return "http://www.uniprot.org/entry/$id";
1132      }
1133      elsif ($type eq "UniRef_50") { # 14
1134        return "http://www.uniprot.org/entry/$id";
1135      }
1136      elsif ($type eq "UniParc") { # 15
1137        return "http://www.uniprot.org/entry/$id";
1138      }
1139      elsif ($type eq "PIR-PSD") { # 16
1140        return "http://pir.georgetown.edu/cgi-bin/pir_psd_get.pl?id=$id";
1141      }
1142      elsif ($type eq "Taxon_ID") { # 17
1143        return "http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=$id";
1144      }
1145      elsif ($type eq "OMIM") { # 18
1146        return "http://www.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id=$id";
1147      }
1148      elsif ($type eq "UniGene") { # 19
1149        return "http://www.ncbi.nlm.nih.gov/sites/entrez?db=unigene&cmd=search&term=$id";
1150      }
1151      elsif ($type eq "Ensemble_ID") { # 20
1152        #return "$id";
1153      }
1154      elsif ($type eq "PMID") { # 21
1155        return "http://www.ncbi.nlm.nih.gov/pubmed/$id";
1156      }
1157      elsif ($type eq "EMBL_DNA_AC") { # 22
1158        return "http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-e+[EMBL:".$id."]+-newId";
1159      }
1160      elsif ($type eq "EMBL_Protein_AC") { # 23
1161        $id =~ s/\.\d//;
1162        return "http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-e+[{EMBL}-ProteinID:".$id."]";
1163      }
1164      elsif ($type eq "CMR") { # 24
1165        if ($id =~ /^\d+$/) {
1166          return "http://cmr.jcvi.org/cgi-bin/CMR/shared/GenePage.cgi?type=PID&acc=".$id;
1167        } else {
1168          return "http://cmr.jcvi.org/tigr-scripts/CMR/shared/GenePage.cgi?locus=".$id;
1169        }
1170      }
1171      elsif ($type eq "SwissProt"){ # 25
1172          return "http://www.uniprot.org/entry/$id";
1173      }
1174      elsif ($type eq "IMG"){ # 26
1175          return "http://img.jgi.doe.gov/cgi-bin/pub/main.cgi?page=geneDetail&gene_oid=$id";
1176      }
1177      elsif ($type eq "KEGG") { # 27
1178          my ($pre,$post) = ($id) =~ /(.*):(.*)/;
1179          return "http://www.genome.ad.jp/dbget-bin/www_bget?" . $pre . "+" . $post;
1180      }
1181      elsif ($type eq "ASAP") { # 28
1182        return "https://asap.ahabs.wisc.edu/asap/feature_info.php?FeatureID=$id";
1183      }
1184      elsif ($type eq "GenBank") { # 29
1185          return "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&id=$id";
1186      }
1187      elsif ($type eq "DBJ") { # 30
1188          return "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&id=$id";
1189      }
1190      elsif ($type eq "SCOP") { # 31
1191          $id =~ s/\:\w//;
1192          return "http://scop.mrc-lmb.cam.ac.uk/scop/search.cgi?pdb=$id";
1193      }
1194      elsif ($type eq "CATH") { # 32
1195          $id =~ s/\:\w//;
1196          return "http://www.cathdb.info/cgi-bin/CATHSrch.pl?type=PDB&query=$id";
1197      }
1198      elsif ($type eq "FSSP") { # 33
1199          $id =~ s/\:\w//;
1200          return "http://ekhidna.biocenter.helsinki.fi/dali/daliquery?find=$id";
1201      }
1202      elsif ($type eq "MMDB") { # 34
1203          $id =~ s/\:\w//;
1204          return "http://www.ncbi.nlm.nih.gov/Structure/mmdb/mmdbsrv.cgi?form=6&db=tDopt=s&uid=$id";
1205      }
1206      elsif ($type eq "PDBsum") { # 35
1207          $id =~ s/\:\w//;
1208          return "http://www.ebi.ac.uk/thornton-srv/databases/cgi-bin/pdbsum/GetPage.pl?pdbcode=$id";
1209      }
1210    
1211      return undef;
1212    }
1213    
1214  sub set_prot_links {  sub set_prot_links {
1215      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1216      my($cgi,$x) = @_;      my($cgi,$x) = @_;
# Line 988  Line 1237 
1237          $after = $3;          $after = $3;
1238          return &set_prot_links($cgi,$before) . &HTML::gi_link($cgi,$match) . &set_prot_links($cgi,$after);          return &set_prot_links($cgi,$before) . &HTML::gi_link($cgi,$match) . &set_prot_links($cgi,$after);
1239      }      }
1240      elsif ($x =~ /^(.*)(tigr\|[0-9a-zA-Z]+)(.*)/s)      elsif ($x =~ /^(.*)(gb\|\S+)(.*)/s)
1241        {
1242            $before = $1;
1243            $match = $2;
1244            $after = $3;
1245            return &set_prot_links($cgi,$before) . &HTML::gb_link($cgi,$match) . &set_prot_links($cgi,$after);
1246        }
1247        elsif ($x =~ /^(.*)(img\|\d+)(.*)/s)
1248        {
1249            $before = $1;
1250            $match = $2;
1251            $after = $3;
1252            return &set_prot_links($cgi,$before) . &HTML::img_link($cgi,$match) . &set_prot_links($cgi,$after);
1253        }
1254        elsif ($x =~ /^(.*)(tigr\|\w+)(.*)/s)
1255      {      {
1256          $before = $1;          $before = $1;
1257          $match = $2;          $match = $2;
1258          $after = $3;          $after = $3;
1259          return &set_prot_links($cgi,$before) . &HTML::tigr_link($cgi,$match) . &set_prot_links($cgi,$after);          return &set_prot_links($cgi,$before) . &HTML::tigr_link($cgi,$match) . &set_prot_links($cgi,$after);
1260      }      }
1261      elsif ($x =~ /^(.*)\beric\|\w+\b(.*)/s)      elsif ($x =~ /^(.*)(tigrcmr\|\w+)(.*)/s)
1262        {
1263            $before = $1;
1264            $match = $2;
1265            $after = $3;
1266            return &set_prot_links($cgi,$before) . &HTML::tigr_link($cgi,$match) . &set_prot_links($cgi,$after);
1267        }
1268        elsif ($x =~ /^(.*)(cmr\|\w+)(.*)/s)
1269        {
1270            $before = $1;
1271            $match = $2;
1272            $after = $3;
1273            return &set_prot_links($cgi,$before) . &HTML::cmr_link($cgi,$match) . &set_prot_links($cgi,$after);
1274        }
1275        elsif ($x =~ /^(.*)(dbj\|\S+)(.*)/s)
1276        {
1277            $before = $1;
1278            $match = $2;
1279            $after = $3;
1280            return &set_prot_links($cgi,$before) . &HTML::dbj_link($cgi,$match) . &set_prot_links($cgi,$after);
1281        }
1282        elsif ($x =~ /^(.*)\b(eric\|\S+)\b(.*)/s)
1283      {      {
1284          $before = $1;          $before = $1;
1285          $match = $2;          $match = $2;
# Line 1003  Line 1287 
1287          return &set_prot_links($cgi,$before) . &HTML::eric_link($cgi,$match) . &set_prot_links($cgi,$after);          return &set_prot_links($cgi,$before) . &HTML::eric_link($cgi,$match) . &set_prot_links($cgi,$after);
1288      }      }
1289    
1290      elsif ($x =~ /^(.*)\bbhb\|.*?\b(.*)/s)      elsif ($x =~ /^(.*)\b(bhb\|.*?)\b(.*)/s)
1291      {      {
1292          $before = $1;          $before = $1;
1293          $match = $2;          $match = $2;
# Line 1011  Line 1295 
1295          return &set_prot_links($cgi,$before) . &HTML::bhb_link($cgi,$match) . &set_prot_links($cgi,$after);          return &set_prot_links($cgi,$before) . &HTML::bhb_link($cgi,$match) . &set_prot_links($cgi,$after);
1296      }      }
1297    
1298      elsif ($x =~ /^(.*)\bapidb\|.*?\..*\b(.*)/s)      elsif ($x =~ /^(.*)\b(apidb\|[0-9\.a-z_]+)\b(.*)/s)
1299      {      {
1300          $before = $1;          $before = $1;
1301          $match = $2;          $match = $2;
# Line 1019  Line 1303 
1303          return &set_prot_links($cgi,$before) . &HTML::apidb_link($cgi,$match) . &set_prot_links($cgi,$after);          return &set_prot_links($cgi,$before) . &HTML::apidb_link($cgi,$match) . &set_prot_links($cgi,$after);
1304      }      }
1305    
1306      elsif ($x =~ /^(.*)\bpatric\|.*?\b(.*)/s)      elsif ($x =~ /^(.*)\b(patric\|.*?)\b(.*)/s)
1307      {      {
1308          $before = $1;          $before = $1;
1309          $match = $2;          $match = $2;
# Line 1027  Line 1311 
1311          return &set_prot_links($cgi,$before) . &HTML::patric_link($cgi,$match) . &set_prot_links($cgi,$after);          return &set_prot_links($cgi,$before) . &HTML::patric_link($cgi,$match) . &set_prot_links($cgi,$after);
1312      }      }
1313    
1314      elsif ($x =~ /^(.*)\bvbrc\|.*?\b(.*)/s)      elsif ($x =~ /^(.*)\b(vbrc\|.*?)\b(.*)/s)
1315      {      {
1316          $before = $1;          $before = $1;
1317          $match = $2;          $match = $2;
# Line 1035  Line 1319 
1319          return &set_prot_links($cgi,$before) . &HTML::vbrc_link($cgi,$match) . &set_prot_links($cgi,$after);          return &set_prot_links($cgi,$before) . &HTML::vbrc_link($cgi,$match) . &set_prot_links($cgi,$after);
1320      }      }
1321    
1322      elsif ($x =~ /^(.*)\bvectorbase\|.*?\b(.*)/s)      elsif ($x =~ /^(.*)\b(vectorbase\|.*?)\b(.*)/s)
1323      {      {
1324          $before = $1;          $before = $1;
1325          $match = $2;          $match = $2;
# Line 1091  Line 1375 
1375          $after = $3;          $after = $3;
1376          return &set_prot_links($cgi,$before) . &HTML::mim_link($cgi,$match) . &set_prot_links($cgi,$after);          return &set_prot_links($cgi,$before) . &HTML::mim_link($cgi,$match) . &set_prot_links($cgi,$after);
1377      }      }
1378      elsif ($x =~ /^(.*)(UniGene:[a-zA-Z_0-9\.]+)(.*)/s)      elsif ($x =~ /^(.*)(HGNC:[a-zA-Z_0-9\.]+)(.*)/s)
1379      {      {
1380          $before = $1;          $before = $1;
1381          $match = $2;          $match = $2;
1382          $after = $3;          $after = $3;
1383          return &set_prot_links($cgi,$before) . &HTML::unigene_link($cgi,$match) . &set_prot_links($cgi,$after);          return &set_prot_links($cgi,$before) . &HTML::hgnc_link($cgi,$match) . &set_prot_links($cgi,$after);
1384      }      }
1385      elsif ($x =~ /^(.*)(IPI:[a-zA-Z_0-9\.]+)(.*)/s)      elsif ($x =~ /^(.*)(UniGene:[a-zA-Z_0-9\.]+)(.*)/s)
1386      {      {
1387          $before = $1;          $before = $1;
1388          $match = $2;          $match = $2;
1389          $after = $3;          $after = $3;
1390          return &set_prot_links($cgi,$before) . &HTML::ipi_link($cgi,$match) . &set_prot_links($cgi,$after);          return &set_prot_links($cgi,$before) . &HTML::unigene_link($cgi,$match) . &set_prot_links($cgi,$after);
1391      }      }
1392    # IPI stopped working. turn off for now.
1393    #    elsif ($x =~ /^(.*)(IPI:[a-zA-Z_0-9\.]+)(.*)/s)
1394    #    {
1395    #        $before = $1;
1396    #        $match = $2;
1397    #        $after = $3;
1398    #        return &set_prot_links($cgi,$before) . &HTML::ipi_link($cgi,$match) . &set_prot_links($cgi,$after);
1399    #    }
1400      elsif ($x =~ /^(.*)(WP:[a-zA-Z_0-9\.]+)(.*)/s)      elsif ($x =~ /^(.*)(WP:[a-zA-Z_0-9\.]+)(.*)/s)
1401      {      {
1402          #wormbase          #wormbase
# Line 1141  Line 1433 
1433          $after = $3;          $after = $3;
1434          return &set_prot_links($cgi,$before) . &HTML::sgd_link($cgi,$match) . &set_prot_links($cgi,$after);          return &set_prot_links($cgi,$before) . &HTML::sgd_link($cgi,$match) . &set_prot_links($cgi,$after);
1435      }      }
1436        elsif ($x =~ /^(.*)(tr\|[a-zA-Z0-9]+)(.*)/s)
1437        {
1438    
1439          $before = $1;
1440          $match = $2;
1441          $after = $3;
1442    
1443          return &set_prot_links($cgi,$before) .  &HTML::trembl_link($cgi,$match) . &set_prot_links($cgi,$after);
1444        }
1445      return $x;      return $x;
1446  }  }
1447    
1448    sub lit_link {
1449        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1450        my($id) = @_;
1451    
1452        if ( $id =~ /([di]lit)\((\d+)\)/ )
1453        {
1454            my($pre, $pubmed_id) = ($1, $2);
1455            my $pubmed_url = &alias_url($pubmed_id, 'PMID');
1456            $id = "$pre(<a href='$pubmed_url' target=_blank>$pubmed_id</a>)";
1457        }
1458        return $id;
1459    }
1460    
1461  sub refseq_link {  sub refseq_link {
1462      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1463      my($cgi,$id) = @_;      my($cgi,$id) = @_;
1464    
1465      if ($id =~ /^[NXYZA]P_/)      if ($id =~ /^[NXYZA]P_/)
1466      {      {
1467          return "<a href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=protein&cmd=search&term=$id>$id</a>";          return "<a href='http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=protein&cmd=search&term=$id' target=_blank>$id</a>";
1468      }      }
1469      elsif ($id =~ /^[NXYZA]M_/)      elsif ($id =~ /^[NXYZA]M_/)
1470      {      {
1471          return "<a href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=nuccore&cmd=search&term=$id>$id</a>";          return "<a href='http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=nuccore&cmd=search&term=$id' target=_blank>$id</a>";
1472      }      }
1473  }  }
1474    
# Line 1164  Line 1478 
1478    
1479      if ($gi =~ /^gi\|(\d+)$/)      if ($gi =~ /^gi\|(\d+)$/)
1480      {      {
1481          return "<a href=http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?cmd=Retrieve&db=Protein&list_uids=$1&dopt=GenPept>$gi</a>";          return "<a href='http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?cmd=Retrieve&db=Protein&list_uids=$1&dopt=GenPept' target=_blank>$gi</a>";
1482      }      }
1483      return $gi;      return $gi;
1484  }  }
1485    
1486    sub gb_link {
1487        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1488        my($cgi,$gb) = @_;
1489    
1490        if ($gb =~ /^gb\|(\S+)$/)
1491        {
1492            return "<a href='http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&id=$1' target=_blank>$gb</a>";
1493        }
1494        return $gb;
1495    }
1496    
1497  sub tigr_link {  sub tigr_link {
1498      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1499      my($cgi,$tigr) = @_;      my($cgi,$tigr) = @_;
1500    
1501      if ($tigr =~ /^tigr\|(NT|ntbp|ntbpA|BA|BMAA|BXB|GBA)([0-9a-zA-Z]+)$/)      if ($tigr =~ /^tigr\|(NT|ntbp|ntbpA|BA|BMAA|BXB|GBA)(\w+)$/)
1502      {      {
1503          my $id=$1.$2;          my $id=$1.$2;
1504          return "<a href=\"http://pathema.tigr.org/tigr-scripts/pathema/shared/GenePage.cgi?locus=$id\">$tigr</a> (Pathema)";          return "<a href=\"http://pathema.tigr.org/tigr-scripts/pathema/shared/GenePage.cgi?locus=$id\" target=_blank>$tigr</a> (Pathema)";
1505      }      }
1506      elsif ($tigr =~ /^tigr\|([0-9a-zA-Z]+)$/)      elsif ($tigr =~ /^tigr(cmr)?\|(\S+)$/)
1507      {      {
1508          return "<a href=\"http://www.tigr.org/tigr-scripts/CMR2/GenePage.spl?locus=$1\">$?tigr</a>";          return "<a href=\"http://www.tigr.org/tigr-scripts/CMR2/GenePage.spl?locus=$2\" target=_blank>$tigr</a>";
1509      }      }
1510      return $tigr;      return $tigr;
1511  }  }
1512    
1513    sub cmr_link {
1514        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1515        my($cgi,$cmr) = @_;
1516    
1517        if ($cmr =~ /^cmr\|(\d+)$/)
1518        {
1519            my $id=$1;
1520            return "<a href=\"http://cmr.jcvi.org/cgi-bin/CMR/shared/GenePage.cgi?type=PID&acc=".$id."\" target=_blank>$cmr</a>";
1521        }
1522        elsif ($cmr =~ /^cmr\|(\S+)$/)
1523        {
1524            my $id = $1;
1525            return "<a href=\"http://cmr.jcvi.org/tigr-scripts/CMR/shared/GenePage.cgi?locus=".$id."\" target=_blank>$cmr</a>";
1526        }
1527        return $cmr;
1528    }
1529    
1530  sub eric_link {  sub eric_link {
1531      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1532      my($cgi,$eric) = @_;      my($cgi,$eric) = @_;
1533    
1534      if ($eric =~ /^eric\|(\w+)$/)      if ($eric =~ /^eric\|(\S+)/)
1535      {      {
1536          return "<a href=\"https://asap.ahabs.wisc.edu/asap/feature_info.php?FeatureID=$1\">$eric</a>";          return "<a href=\"https://asap.ahabs.wisc.edu/asap/feature_info.php?FeatureID=$1\" target=_blank>$eric</a>";
1537      }      }
1538      return $eric;      return $eric;
1539  }  }
1540    
1541    sub dbj_link {
1542        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1543        my($cgi,$dbj) = @_;
1544    
1545        if ($dbj =~ /^dbj\|(\S+)/)
1546        {
1547            return "<a href=\"http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&id=$1\" target=_blank>$dbj</a>";
1548        }
1549        return $dbj;
1550    }
1551    
1552  sub bhb_link {  sub bhb_link {
1553      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1554      my($cgi,$bhb) = @_;      my($cgi,$bhb) = @_;
1555    
1556      return "<a href=\"http://www.biohealthbase.org\">$bhb</a>";      return "<a href=\"http://www.biohealthbase.org\" target=_blank>$bhb</a>";
1557  }  }
1558    
1559  sub apidb_link {  sub apidb_link {
# Line 1209  Line 1562 
1562    
1563      if ($api =~ /apidb\|(.*?)\.(.*)$/)      if ($api =~ /apidb\|(.*?)\.(.*)$/)
1564      {      {
1565          return "<a href=\"http://www.apidb.org/cgi-bin/redirect.cgi?taxon_id=$1&source_id=$2\">$api</a>";          return "<a href=\"http://www.apidb.org/cgi-bin/redirect.cgi?taxon_id=$1&source_id=$2\" target=_blank>$api</a>";
1566      }      }
1567      return $api;      return $api;
1568  }  }
# Line 1220  Line 1573 
1573    
1574      if ($patric =~ /patric\|(.*)/)      if ($patric =~ /patric\|(.*)/)
1575      {      {
1576          return "<a href=\"https://patric.vbi.vt.edu/software/curationTool/gep/pgiCuration.php?locus_name=$1\">$patric</a>";          return "<a href=\"https://patric.vbi.vt.edu/software/curationTool/gep/pgiCuration.php?locus_name=$1\" target=_blank>$patric</a>";
1577      }      }
1578      return $patric;      return $patric;
1579  }  }
# Line 1231  Line 1584 
1584    
1585      if ($vbrc =~ /vbrc\|(.*)/)      if ($vbrc =~ /vbrc\|(.*)/)
1586      {      {
1587          return "<a href=\"http://www.biovirus.org/gene_detail.asp?name=$1\">$vbrc</a>";          return "<a href=\"http://www.biovirus.org/gene_detail.asp?name=$1\" target=_blank>$vbrc</a>";
1588      }      }
1589      return $vbrc;      return $vbrc;
1590  }  }
# Line 1239  Line 1592 
1592  sub vectorbase_link {  sub vectorbase_link {
1593      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1594      my($cgi,$vec) = @_;      my($cgi,$vec) = @_;
1595      return "<a href=\"http://www.vectorbase.org\">$vec</a>";      return "<a href=\"http://www.vectorbase.org\" target=_blank>$vec</a>";
1596  }  }
1597    
1598    sub uniprot_link {
1599        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1600        my($cgi,$uni) = @_;
1601    
1602        if ($uni =~ /^(sp|tr|uni)\|(\S+)$/)
1603        {
1604            return "<a href='" . &HTML::alias_url($2, 'UniProt') . "' target=_blank>$uni</a>";
1605        }
1606        return $uni;
1607    }
1608    
1609  sub uni_link {  sub uni_link {
1610      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
# Line 1249  Line 1612 
1612    
1613      if ($uni =~ /^uni\|(\S+)$/)      if ($uni =~ /^uni\|(\S+)$/)
1614      {      {
1615          return "<a href=http://www.pir.uniprot.org/cgi-bin/upEntry?id=$1>$uni</a>";          #return "<a href=http://www.pir.uniprot.org/cgi-bin/upEntry?id=$1>$uni</a>";
1616            #return "<a href='http://www.ebi.uniprot.org/uniprot-srv/uniProtView.do?proteinAc=$1' target=_blank>$uni</a>";
1617            return "<a href='" . &HTML::alias_url($1, 'UniProt') . "' target=_blank>$uni</a>";
1618      }      }
1619      return $uni;      return $uni;
1620  }  }
# Line 1260  Line 1625 
1625    
1626      if ($sp =~ /^sp\|(\S+)$/)      if ($sp =~ /^sp\|(\S+)$/)
1627      {      {
1628          return "<a href=http://us.expasy.org/cgi-bin/get-sprot-entry?$1>$sp</a>";          #return "<a href='http://us.expasy.org/cgi-bin/get-sprot-entry?$1' target=_blank>$sp</a>";
1629            return "<a href='" . &HTML::alias_url($1, 'UniProt') . "' target=_blank>$sp</a>";
1630      }      }
1631      return $sp;      return $sp;
1632  }  }
1633    
1634    sub trembl_link {
1635        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1636        my($cgi,$tr) = @_;
1637    
1638        if ($tr =~ /^tr\|(\S+)$/)
1639        {
1640            #return "<a href='http://us.expasy.org/cgi-bin/get-sprot-entry?$1' target=_blank>$tr</a>";
1641            return "<a href='" . &HTML::alias_url($1, 'UniProt') . "' target=_blank>$tr</a>";
1642        }
1643        return $tr;
1644    }
1645    
1646  sub pir_link {  sub pir_link {
1647      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1648      my($cgi,$pir) = @_;      my($cgi,$pir) = @_;
1649    
1650      if ($pir =~ /^pirnr\|(NF\d+)$/)      if ($pir =~ /^pirnr\|(NF\d+)$/)
1651      {      {
1652          return "<a href=http://pir.georgetown.edu/cgi-bin/nfEntry.pl?id=$1>$pir</a>";          return "<a href='http://pir.georgetown.edu/cgi-bin/nfEntry.pl?id=$1' target=_blank>$pir</a>";
1653      }      }
1654      return $pir;      return $pir;
1655  }  }
# Line 1282  Line 1660 
1660    
1661      if ($kegg =~ /^kegg\|([^:]+):(\S+)$/)      if ($kegg =~ /^kegg\|([^:]+):(\S+)$/)
1662      {      {
1663          return "<a href=http://www.genome.ad.jp/dbget-bin/www_bget?$1+$2>$kegg</a>";          return "<a href='http://www.genome.ad.jp/dbget-bin/www_bget?$1+$2' target=_blank>$kegg</a>";
1664      }      }
1665      return $kegg;      return $kegg;
1666  }  }
1667    
1668    sub img_link {
1669        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1670        my($cgi,$img) = @_;
1671    
1672        if ($img =~ /^img\|(\S+)$/)
1673        {
1674            return "<a href='http://img.jgi.doe.gov/cgi-bin/pub/main.cgi?page=geneDetail&gene_oid=$1' target=_blank>$img</a>";
1675        }
1676        return $img;
1677    }
1678    
1679  sub ensembl_link {  sub ensembl_link {
1680      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1681      my($cgi,$ensembl) = @_;      my($cgi,$ensembl) = @_;
# Line 1295  Line 1684 
1684      {      {
1685          my $what=$1;          my $what=$1;
1686          my $key=$2;          my $key=$2;
1687          my $idx="all";          my $idx="All";
1688          if ($what eq "EnsemblGene") { $idx = "Gene" }          if ($what eq "EnsemblGene") { $idx = "Gene" }
1689          if ($what eq "EnsemblTranscript") { $idx = "all" }          if ($what eq "EnsemblTranscript") { $idx = "All" }
1690          if ($what eq "EnsemblProtein") { $idx = "all" }          if ($what eq "EnsemblProtein") { $idx = "All" }
1691    
1692          #I really want to get right to the transcript and peptide pages, but          #I really want to get right to the transcript and peptide pages, but
1693          #can't see how to do that without knowing the org name too, which          #can't see how to do that without knowing the org name too, which
1694          #I don't know at this point. (ensembl org name, not real org name)          #I don't know at this point. (ensembl org name, not real org name)
1695    
1696          return "<a href=http://www.ensembl.org/Homo_sapiens/textview?species=all&idx=$idx&q=$key>$ensembl</a>";          return "<a href='http://www.ensembl.org/Homo_sapiens/searchview?species=all&idx=$idx&q=$key' target=_blank>$ensembl</a>";
1697      }      }
1698      return $ensembl;      return $ensembl;
1699  }  }
# Line 1315  Line 1704 
1704    
1705      if ($entrezgene =~ /^EntrezGene:(\S+)$/)      if ($entrezgene =~ /^EntrezGene:(\S+)$/)
1706      {      {
1707          return "<a href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=full_report&list_uids=$1>$entrezgene</a>";          return "<a href='http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=full_report&list_uids=$1' target=_blank>$entrezgene</a>";
1708      }      }
1709      return $entrezgene;      return $entrezgene;
1710  }  }
# Line 1326  Line 1715 
1715    
1716      if ($mim =~ /^MIM:(\S+)$/)      if ($mim =~ /^MIM:(\S+)$/)
1717      {      {
1718          return "<a href=http://www3.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id=$1>$mim</a>";          return "<a href='http://www3.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id=$1' target=_blank>$mim</a>";
1719      }      }
1720      return $mim;      return $mim;
1721  }  }
1722    
1723    sub hgnc_link {
1724        shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1725        my($cgi,$hgnc) = @_;
1726    
1727        if ($hgnc =~ /^HGNC:(\S+)$/)
1728        {
1729            return "<a href='http://www.gene.ucl.ac.uk/cgi-bin/nomenclature/searchgenes.pl?field=symbol&anchor=equals&match=$1&symbol_search=Search&number=50&format=html&sortby=symbol' target=_blank>$hgnc</a>";
1730        }
1731    
1732        return $hgnc;
1733    }
1734    
1735  sub unigene_link {  sub unigene_link {
1736      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1737      my($cgi,$unigene) = @_;      my($cgi,$unigene) = @_;
1738    
1739      if ($unigene =~ /^UniGene:(\S+)$/)      if ($unigene =~ /^UniGene:(\S+)$/)
1740      {      {
1741          return "<a href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=unigene&cmd=search&term=$1>$unigene</a>";          return "<a href='http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=unigene&cmd=search&term=$1' target=_blank>$unigene</a>";
1742      }      }
1743      return $unigene;      return $unigene;
1744  }  }
# Line 1348  Line 1749 
1749    
1750      if ($ipi =~ /^IPI:(\S+)$/)      if ($ipi =~ /^IPI:(\S+)$/)
1751      {      {
1752          return "<a href=http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-id+AEoS1R8Jnn+-e+[IPI:\'$1\']+-qnum+1+-enum+1>$ipi</a>";          return "<a href='http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-id+AEoS1R8Jnn+-e+[IPI:\'$1\']+-qnum+1+-enum+1' target=_blank>$ipi</a>";
1753      }      }
1754      return $ipi;      return $ipi;
1755  }  }
# Line 1361  Line 1762 
1762    
1763      if ($wp =~ /^WP:(\S+)$/)      if ($wp =~ /^WP:(\S+)$/)
1764      {      {
1765          return "<a href=http://www.wormbase.org/db/searches/basic?class=Any&query=$1&Search=Search>$wp</a>";          return "<a href='http://www.wormbase.org/db/searches/basic?class=Any&query=$1&Search=Search' target=_blank>$wp</a>";
1766      }      }
1767      return $wp;      return $wp;
1768  }  }
# Line 1374  Line 1775 
1775    
1776      if ($fb =~ /^FB:(\S+)$/)      if ($fb =~ /^FB:(\S+)$/)
1777      {      {
1778          return "<a href=http://flybase.bio.indiana.edu/.bin/fbidq.html?$1>$fb</a>";          return "<a href='http://flybase.bio.indiana.edu/.bin/fbidq.html?$1' target=_blank>$fb</a>";
1779      }      }
1780      return $fb;      return $fb;
1781  }  }
# Line 1387  Line 1788 
1788    
1789      if ($fb =~ /^FlyBaseORFNames:(\S+)$/)      if ($fb =~ /^FlyBaseORFNames:(\S+)$/)
1790      {      {
1791          return "<a href=http://flybase.bio.indiana.edu/.bin/fbidq.html?$1>$fb</a>";          return "<a href='http://flybase.bio.indiana.edu/.bin/fbidq.html?$1' target=_blank>$fb</a>";
1792      }      }
1793      return $fb;      return $fb;
1794  }  }
# Line 1400  Line 1801 
1801    
1802      if ($sgd =~ /^SGD_LOCUS:(\S+)$/)      if ($sgd =~ /^SGD_LOCUS:(\S+)$/)
1803      {      {
1804          return "<a href=http://db.yeastgenome.org/cgi-bin/locus.pl?locus=$1>$sgd</a>";          return "<a href='http://db.yeastgenome.org/cgi-bin/locus.pl?locus=$1' target=_blank>$sgd</a>";
1805      }      }
1806      return $sgd;      return $sgd;
1807  }  }
# Line 1431  Line 1832 
1832      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1833      my($cgi,$map,$org) = @_;      my($cgi,$map,$org) = @_;
1834    
1835      $user = $cgi->param('user');      my $user = $cgi->param('user');
1836      $user = $user ? $user : "";      $user = $user ? $user : "";
1837      $org = $org ? $org : "";      $org = $org ? $org : "";
1838    
# Line 1449  Line 1850 
1850    # -name => field and the checkbox name    # -name => field and the checkbox name
1851    my ($form, $button)=@_;    my ($form, $button)=@_;
1852    
1853    $java_script="<input type=\"button\" name=\"CheckAll\" value=\"Check All\"\nonClick=\"checkAll(document.$form.$button)\">\n";    my $java_script="<input type=\"button\" name=\"CheckAll\" value=\"Check All\"\nonClick=\"checkAll(document.$form.$button)\">\n";
1854    $java_script.="<input type=\"button\" name=\"CheckFirst\" value=\"Check First Half\"\nonClick=\"checkFirst(document.$form.$button)\">\n";    $java_script.="<input type=\"button\" name=\"CheckFirst\" value=\"Check First Half\"\nonClick=\"checkFirst(document.$form.$button)\">\n";
1855    $java_script.="<input type=\"button\" name=\"CheckSecond\" value=\"Check Second Half\"\nonClick=\"checkSecond(document.$form.$button)\">\n";    $java_script.="<input type=\"button\" name=\"CheckSecond\" value=\"Check Second Half\"\nonClick=\"checkSecond(document.$form.$button)\">\n";
1856    $java_script.="<input type=\"button\" name=\"UnCheckAll\" value=\"Uncheck All\"\nonClick=\"uncheckAll(document.$form.$button)\">\n";    $java_script.="<input type=\"button\" name=\"UnCheckAll\" value=\"Uncheck All\"\nonClick=\"uncheckAll(document.$form.$button)\">\n";
# Line 1457  Line 1858 
1858    return $java_script;    return $java_script;
1859  }  }
1860    
1861    =head3 sub_link
1862    
1863        my $htmlText = HTML::sub_link($cgi, $sub, gid);
1864    
1865    Create a subsystem link. The link will be to the display page if there is no
1866    user or we are in SPROUT mode; otherwise it will be to the edit page.
1867    
1868    =over 4
1869    
1870    =item cgi
1871    
1872    CGI query object for the current web session. The parameters of special interest
1873    are C<SPROUT> and C<user>. If the user is non-blank and SPROUT mode is 0, then
1874    the subsystem's edit page will be shown rather than its display page.
1875    
1876    =item sub
1877    
1878    Name of the desired subsystem. It will be cleaned of underscores before the
1879    hyperlink is applied.
1880    
1881    =item gid
1882    
1883    Genome ID to be specified as the focus.
1884    
1885    =back
1886    
1887    =cut
1888    
1889  sub sub_link {  sub sub_link {
1890        # Allow call as an instance in addition to the authorized method.
1891      shift if UNIVERSAL::isa($_[0],__PACKAGE__);      shift if UNIVERSAL::isa($_[0],__PACKAGE__);
1892      my($cgi,$sub) = @_;      # Get the parameters.
1893      my($sub_link);      my ($cgi, $sub, $gid) = @_;
1894        # Declare the return variable.
1895        my $retVal;
1896        # Clean the subsystem name for display purposes. This is a very
1897        # different thing from URL-escaping.
1898        my $cleaned = Tracer::Clean($sub);
1899        $cleaned =~ s/_/ /g;
1900        # URL-escape the subsystem name for use in the link.
1901        my $linkable = uri_escape($sub);
1902        # Determine the mode. Note we use the little OR trick to insure that
1903        # we have the correct value for plugging into the output link.
1904        my $user = $cgi->param('user') || "";
1905        my $sproutMode = $cgi->param('SPROUT') || 0;
1906        if ($user && ! $sproutMode) {
1907            # A SEED user is calling, so we go to the edit page.
1908            $retVal = "<a href=\"subsys.cgi?ssa_name=$linkable&request=show_ssa&user=$user\">$cleaned</a>";
1909        } else {
1910            # A visitor or SPROUT user is calling, so we go to the display page.
1911            $retVal = "<a href=\"$FIG_Config::cgi_url/seedviewer.cgi?page=Subsystems;subsystem=$linkable\">$cleaned</a>";
1912        }
1913        # Return the result.
1914        return $retVal;
1915    }
1916    
1917      my $user = $cgi->param('user');  sub reaction_map_link {
1918      if ($user)      my($mapID, @reaction_list) = @_;
1919        if($mapID =~ /\d+/)
1920      {      {
1921          my $esc_sub = uri_escape( $sub );          my $reactions = join "+", @reaction_list;
1922          $sub =~ s/\_/ /g;          if ($reactions ne "")
1923          $sub_link = "<a href=./subsys.cgi?ssa_name=$esc_sub&request=show_ssa&user=$user>$sub</a>";          {
1924                $reactions = "+".$reactions;
1925            }
1926    
1927            return "<a href=http://www.genome.jp/dbget-bin/show_pathway?rn$mapID$reactions>$mapID</a>";
1928        }
1929        else
1930        {
1931            return $mapID;
1932        }
1933    }
1934    
1935    sub compound_link {
1936        my($compound) = @_;
1937        if($compound =~ /^C\d+/)
1938        {
1939            return "<a href=\"javascript:void(0)\"onclick=\"window.open('http://www.genome.jp/dbget-bin/www_bget?compound+$compound','$&','height=640,width=800,scrollbars=yes,toolbar=yes,status=yes,resizable=yes')\">$compound</a>";
1940      }      }
1941      else      else
1942      {      {
1943          $sub_link = $sub;          return $compound;
1944      }      }
     return $sub_link;  
1945  }  }
1946    
1947    
1948  sub reaction_link {  sub reaction_link {
1949      my($reaction) = @_;      my($reaction) = @_;
1950        if ($reaction =~ /^(\*)?(R\d+)/)
     if ($reaction =~ /^R\d+/)  
1951      {      {
1952          return "<a href=\"http://www.genome.ad.jp/dbget-bin/www_bget?rn+$reaction\" target=reaction$$>$reaction</a>";          # return "<a href=\"http://www.genome.ad.jp/dbget-bin/www_bget?rn+$2\" target=reaction$$>$reaction</a>";
1953            return "<a href=\"javascript:void(0)\"onclick=\"window.open('http://www.genome.ad.jp/dbget-bin/www_bget?rn+$reaction','$&','height=640,width=800,scrollbars=yes,toolbar=yes,status=yes,resizable=yes')\">$reaction</a>";
1954      }      }
1955      return $reaction;      return $reaction;
1956  }  }
1957    
1958    
1959  sub html_for_assignments {  sub html_for_assignments {
1960      my($fig,$user,$peg_sets) = @_;      my($fig,$user,$peg_sets) = @_;
1961      my $i;      my $i;
1962    
1963      my @vals = ();      my @vals = ();
1964      my $set = 1;      my $set = 1;
1965      foreach $peg_set (@$peg_sets)      foreach my $peg_set (@$peg_sets)
1966      {      {
1967          for ($i=0; ($i < @$peg_set); $i++)          for ($i=0; ($i < @$peg_set); $i++)
1968          {          {
1969              $peg = $peg_set->[$i];              my $peg = $peg_set->[$i];
1970              push(@vals,'show=' . join("@",($set,$i+1,$peg,&FIG::abbrev($fig->org_of($peg)),"")));              push(@vals,'show=' . join("@",($set,$i+1,$peg,&FIG::abbrev($fig->org_of($peg)),"")));
1971          }          }
1972          $set++;          $set++;
# Line 1607  Line 2077 
2077    
2078    
2079   my @files=("SEED.rss");   my @files=("SEED.rss");
2080   if ($args->{"type"}) {push @files, "SEED.$type.rss"}   if ($args->{"type"}) {
2081        my $type = $args->{type};
2082        push @files, "SEED.$type.rss"
2083    }
2084    
2085   foreach my $file ("SEED.rss", @$files)   foreach my $file ("SEED.rss", @$files)
2086   {   {

Legend:
Removed from v.1.81  
changed lines
  Added in v.1.130

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3