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

Diff of /FigWebServices/genome_statistics.cgi

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

revision 1.18, Thu Aug 4 22:35:28 2005 UTC revision 1.19, Tue Aug 9 14:25:11 2005 UTC
# Line 6  Line 6 
6    
7  use HTML;  use HTML;
8  use strict;  use strict;
 use CGI::Carp qw(fatalsToBrowser);  
9  use CGI;  use CGI;
10  my $cgi = new CGI;  my $cgi = new CGI;
 use raelib;  
   
11    
12  if (0)  if (0)
13  {  {
# Line 46  Line 43 
43    
44  my @genomes = $cgi->param('genome');  my @genomes = $cgi->param('genome');
45  my $request = $cgi->param('request');  my $request = $cgi->param('request');
 my $user = $cgi->param('user');  
46    
47  if ($request eq "subsystems_summary")  if ($request eq "subsystems_summary")
48  {  {
49      &subsys_summary($fig,$cgi,$html);      &subsys_summary($fig,$cgi,$html);
50  }  }
 elsif ($request eq "subsystems_by_homology")  
 {  
     &subsys_homol($fig,$cgi,$html,$cgi->param('genome'));  
 }  
51  elsif ($request eq "edit_kv_stats") {  elsif ($request eq "edit_kv_stats") {
52      &edit_kv_stats($fig,$cgi,$html, $cgi->param('genome'));      &edit_kv_stats($fig,$cgi,$html, $cgi->param('genome'));
53  }  }
# Line 75  Line 67 
67          &kv_peg_stats($fig, $cgi, $html, $genome);          &kv_peg_stats($fig, $cgi, $html, $genome);
68          push(@$html,$cgi->hr);          push(@$html,$cgi->hr);
69          &kv_stats($fig, $cgi, $html, $genome);          &kv_stats($fig, $cgi, $html, $genome);
70          push(@$html,"<p><a href=./genome_statistics.cgi?genome=$genome&request=show_subsystems&user=$user>Show Subsystems</a></p>");          my $user = $cgi->param('user');
71          push(@$html,"<p><a href=./genome_statistics.cgi?genome=$genome&request=subsystems_by_homology&user=$user>Count Proteins in Subsystems</a></p>");          push(@$html,"<a href=./genome_statistics.cgi?genome=$genome&request=show_subsystems&user=$user>Show Subsystems</a>");
72          push(@$html,$cgi->br);          push(@$html,$cgi->br);
73      }      }
74  }  }
# Line 202  Line 194 
194    
195  sub handle_show_subsystems {  sub handle_show_subsystems {
196      my($fig,$cgi,$html,$genome) = @_;      my($fig,$cgi,$html,$genome) = @_;
197      my(%in,$sub,$role,$protein,$sub_link);      my(%in,$sub,$role,$protein,$sub_link,$tuple,$categories);
198    
199      my($subsystem_data,$assignments_data) = &get_data($fig,$cgi,$genome);      my($subsystem_data,$assignments_data) = &get_data($fig,$cgi,$genome);
200      foreach $_ (@$subsystem_data)      foreach $_ (@$subsystem_data)
# Line 210  Line 202 
202          ($sub,$role,$protein) = @$_;          ($sub,$role,$protein) = @$_;
203          push(@{$in{$sub}->{$role}},&HTML::fid_link($cgi,$protein,0) . ": " . scalar $fig->function_of($protein));          push(@{$in{$sub}->{$role}},&HTML::fid_link($cgi,$protein,0) . ": " . scalar $fig->function_of($protein));
204      }      }
205      foreach $sub (sort keys(%in))  
206        my @subs = sort { ($a->[0] cmp $b->[0]) or
207                          ($a->[1] cmp $b->[1]) or
208                          ($a->[2] cmp $b->[2]) or
209                          ($a->[3] cmp $b->[3]) or
210                          ($a->[4] cmp $b->[4])
211                        }
212                   map { $sub = $_;
213                         $categories = $fig->subsystem_classification($sub);
214                         $categories = ((@$categories > 0) && $categories->[0]) ? $categories : ["Misc"];
215                         [@$categories,$sub]
216                       }
217           keys(%in);
218    
219        my $last = "";
220        foreach $tuple (@subs)
221        {
222            $sub = pop @{$tuple};
223            my $topic = $tuple->[0];
224            if ($topic ne $last)
225      {      {
226                push(@$html,$cgi->h2($topic));
227                $last = $topic;
228            }
229          $sub_link = &sub_link($cgi,$sub);          $sub_link = &sub_link($cgi,$sub);
230          push(@$html,$cgi->h2($sub_link));          push(@$html,$cgi->h3($sub_link));
231    
232          my $roles = [];          my $roles = [];
233          foreach $role (sort keys(%{$in{$sub}}))          foreach $role (sort keys(%{$in{$sub}}))
234          {          {
# Line 311  Line 326 
326    
327  sub sub_link {  sub sub_link {
328      my($cgi,$sub) = @_;      my($cgi,$sub) = @_;
     my($sub_link);  
329    
330      my $user = $cgi->param('user');      my $user = $cgi->param('user');
331      if ($user)      $user = defined($user) ? $user : "";
332      {      my $sub_link = "<a href=./subsys.cgi?ssa_name=$sub&request=show_ssa&user=$user>$sub</a>";
333          $sub_link = "<a href=./subsys.cgi?ssa_name=$sub&request=show_ssa&user=$user>$sub</a>";  
     }  
     else  
     {  
         $sub_link = $sub;  
     }  
334      return $sub_link;      return $sub_link;
335  }  }
336    
# Line 527  Line 536 
536   }   }
537  }  }
538    
 sub subsys_homol {  
  my ($fig,$cgi,$html, $genome)=@_;  
   
  if (!$genome && $cgi->param('korgs')) {$genome=$cgi->param('korgs')}  
  if (!$genome) {push @$html, 'Please specify a genome\n'; return}  
   
  # here we are going to get some subsystems based on what genes are present and what they are homologous to  
  my ($maxN, $maxP)=(($cgi->param('maxN') or 5), ($cgi->param('maxP') or 1e-20));  
  my $sscount;  
  foreach my $peg ($fig->pegs_of($genome)) {  
   map {$sscount->{$_->[0]}->{'Annotated'}++} $fig->subsystems_for_peg($peg);  
   map {map {$sscount->{$_->[0]}->{'Homology'}->{$peg}++} $fig->subsystems_for_peg($_->[1])} $fig->sims($peg, $maxN, $maxP, 'fig');  
  }  
   
  my %label;  
  my @ss=sort {$a cmp $b} keys %$sscount;  
  my @labels=raelib->subsys_names_for_display(@ss);  
  foreach my $i (0 .. @ss) {$label{$ss[$i]}=$labels[$i]}  
   
  my $col_hdrs=["Susbystems", "Proteins in subsystem", "Proteins by<br>homology to other<br>proteins in subsystems"];  
  my $tab=[];  
  foreach my $ss (@ss) {  
   $sscount->{$ss}->{"Homology"}={} unless (exists $sscount->{$ss}->{"Homology"});  
   my @row=("<a href='/FIG/subsys.cgi?user=$user&ssa_name=$ss&request=show_ssa&can_alter=&check=&sort=by_phylo&show_clusters=1' target='_blank'>$label{$ss}</a>");  
   push @row, ($sscount->{$ss}->{"Annotated"} or 0), scalar(keys %{$sscount->{$ss}->{"Homology"}});  
   push @$tab, \@row;  
  }  
  my $title="Pegs in " . $fig->genus_species($genome) ." ($genome) that are, or could, be in subsystems";  
  push @$html, "<h2>Pegs In Subsystems</h2><p>These are the numbers of proteins in subsystems or that could be in subsystems",  
   ".\n The scond column is the number of proteins that are actually in subsystems. ",  
   "\nThe third column is the number of proteins that are similar to a protein in that subsystem ",  
   " (with a cutoff of $maxP and only looking through $maxN sims for each protein).\n",  
   "<br>You can change these numbers below, but be careful -- more sims means the searching will take a lot longer and may time out!</p>",  
   &HTML::make_table($col_hdrs,$tab,$title),  
   $cgi->start_form(), $cgi->hidden("request"), $cgi->p,  
   "<table border=0><tr><td>Enter the max number of similarities to look through:</td><td>",  
   $cgi->textfield(-name=>"maxN", -value=>$maxN, -size=>2), "</td></tr>\n<tr><td>Enter the maximum E value:</td><td>",  
   $cgi->textfield(-name=>"maxP", -value=>$maxP, -size=>6), "</td></tr></table>\n", $cgi->p,  
   raelib->scrolling_org_list($cgi, 0, $genome), $cgi->p, $cgi->submit, $cgi->reset, $cgi->end_form;  
   
 }  
   
   
   
   

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3