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

Diff of /FigWebServices/pir.cgi

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

revision 1.8, Sat Feb 12 00:36:39 2005 UTC revision 1.9, Sat Feb 12 01:11:04 2005 UTC
# Line 55  Line 55 
55    
56    
57  if ($cgi->param('tabulate')) {  if ($cgi->param('tabulate')) {
58   $html=&table_annotations($html);   $html=&table_annotations($html, $pegbypir, $pirid);
59   push @$html, $cgi->p($cgi->div({class=>"diagnostic"}, "<small>Generating this table took approximately " . time-$^T . " seconds\n</small>"));   push @$html, $cgi->p($cgi->div({class=>"diagnostic"}, ("<small>Generating this table took approximately " . (time-$^T) . " seconds\n</small>")));
60  }  }
61  elsif ($cgi->param('pirsf')) {  elsif ($cgi->param('pirsf')) {
62   # we want to display one of the correspondances   # we want to display one of the correspondances
# Line 199  Line 199 
199   return $pir, $functions;   return $pir, $functions;
200  }  }
201    
   
 =head1 count_annotations  
   
 Count the number of annotations per subsystem. This is to make the pir_comp.html table automatic  
   
 returns a reference to a hash, with two keys: {'function'} is a reference to a hash of all functions  
 {'subsystems'} is a reference to a hash of all subsystems  
   
 =cut  
   
 sub count_annotations {  
  unless (-e "$FIG_Config::data/Global/pirsfcorrespondance.txt") {  
   print STDERR "Can't find the correspondance file pirsfcorrespondance.txt so we are going to make it\n";  
   raelib->pirsfcorrespondance("$FIG_Config::data/Global/pirsfinfo.dat", "$FIG_Config::data/Global/pirsfcorrespondance.txt");  
  }  
  open (IN, "$FIG_Config::data/Global/pirsfcorrespondance.txt") || die "Can't open $FIG_Config::data/Global/pirsfcorrespondance.txt";  
  my $pir;  
  my $current;  
  while (<IN>) {  
   chomp;  
   if (/^>/) {$current=$_; next}  
   else {  
    my ($pid, $fid)=split /\t/;  
    $pir->{'function'}->{$current}->{$fig->function_of($fid)}++;  
    foreach my $subsys ($fig->subsystems_for_peg($fid)) {$pir->{'subsystems'}->{$current}->{$$subsys[0]}++}  
   }  
  }  
  return $pir;  
 }  
   
   
202  =head1 table_annotations  =head1 table_annotations
203    
204  Return a table sorted by the number of annotations, and list a bunch of stuff  Return a table sorted by the number of annotations, and list a bunch of stuff
# Line 237  Line 206 
206  =cut  =cut
207    
208  sub table_annotations {  sub table_annotations {
209   my ($html)=@_;   my ($html, $pegbypir, $pirid)=@_;
210   my $pir=&count_annotations();   my $count; my $subsystems;
211     foreach my $sf (keys %$pegbypir) {
212      my $function; my $ss;
213      foreach my $peg (@{$pegbypir->{$sf}}) {
214       $function->{scalar $fig->function_of($peg)}++;
215       foreach my $subsys ($fig->subsystems_for_peg($peg)) {$ss->{$$subsys[0]}++}
216      }
217      $subsystems->{$sf}=join "; ", keys %$ss;
218      $count->{$sf}=scalar keys %$function;
219     }
220    
221   my $col_hdrs = ["Number of SEED annotations in a Superfamily", "PIRSF<br><small>(Link goes to SEED/PIR comparison)</small>",   my $col_hdrs = ["Number of SEED annotations in a Superfamily", "PIRSF<br><small>(Link goes to SEED/PIR comparison)</small>",
222                   "Superfamily name", "Subsystems in superfamily"];                   "Superfamily name", "Subsystems in superfamily"];
223   my $tab=[];   my $tab; my $lastcount;
  my $rowcount;  
224   # note we are going to make a new table every 200 rows because that way the browsers don't get messed up   # note we are going to make a new table every 200 rows because that way the browsers don't get messed up
225   foreach my $sf (sort {scalar keys %{$pir->{'function'}->{$b}} <=> scalar keys %{$pir->{'function'}->{$a}}} keys %{$pir->{'function'}}) {   foreach my $sf (sort {$count->{$b} <=> $count->{$a}} keys %$count) {
226    $rowcount++;    if ($lastcount ne $count->{$sf}) {
227    $sf =~ /(PIRSF\d+)/;     $lastcount=$count->{$sf};
228    push @$tab,     push(@$html,&HTML::make_table($col_hdrs,$tab,"")) if ($tab);
229     (    }
230     (scalar keys %{$pir->{'function'}->{$sf}}),    push @$tab, [
231     "<a href=\"http://seed-linux-2.uchicago.edu/FIG/pir.cgi?pirsf=$1&ssonly='1'&user=''>$1</a>",     $count->{$sf},
232     $sf,     "<a href=\"http://seed-linux-2.uchicago.edu/FIG/pir.cgi?pirsf=$sf&ssonly='1'&user=''>$sf</a>",
233     join "; ", keys %{$pir->{'subsystems'}->{$sf}},     $pirid->{$sf},
234     );     $subsystems->{$sf},
235     if ($rowcount == 200) {    ];
     push(@$html,&HTML::make_table($col_hdrs,$tab,""));  
     $tab=[];  
     $rowcount=0;  
    }  
236   }   }
   
237   push(@$html,&HTML::make_table($col_hdrs,$tab,""));   push(@$html,&HTML::make_table($col_hdrs,$tab,""));
238   return $html;   return $html;
239  }  }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3