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

Diff of /FigWebServices/proteinfamilies.cgi

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

revision 1.4, Wed Jul 13 01:49:55 2005 UTC revision 1.5, Wed Jul 13 03:57:22 2005 UTC
# Line 65  Line 65 
65  {  {
66   &combine_families($fig,$cgi,$html);   &combine_families($fig,$cgi,$html);
67  }  }
68    elsif ($cgi->param('proteins_between_two'))
69    {
70     &proteins_between_two($fig, $cgi, $html);
71    }
72  elsif ($cgi->param('Compare FIG Functions'))  elsif ($cgi->param('Compare FIG Functions'))
73  {  {
74   my @needed=grep {$cgi->param($_)} $cgi->param("allfams");   my @needed=grep {$cgi->param($_)} $cgi->param("allfams");
# Line 128  Line 132 
132    "<p>$peg is in the following ", scalar(@families), " families. Please choose one or more families using the checkboxes</p>\n",    "<p>$peg is in the following ", scalar(@families), " families. Please choose one or more families using the checkboxes</p>\n",
133    &HTML::make_table($col_hdrs, $tab, "Families for $peg"),  "\n",    &HTML::make_table($col_hdrs, $tab, "Families for $peg"),  "\n",
134    $cgi->submit('Show Proteins In Each Family'), $cgi->submit(-name=>"Suggest", -value=>"Suggest Proteins for this Family"),    $cgi->submit('Show Proteins In Each Family'), $cgi->submit(-name=>"Suggest", -value=>"Suggest Proteins for this Family"),
135      $cgi->submit(-name=>'proteins_between_two', -value=>"Compare two or more families for missing"),
136    $cgi->submit("Combine Families With And"), $cgi->submit("Compare FIG Functions"),    $cgi->submit("Combine Families With And"), $cgi->submit("Compare FIG Functions"),
137    $cgi->hidden(-name=>'prot'),$cgi->hidden(-name=>"allfams", -value=>\@families), "\n",    $cgi->hidden(-name=>'prot'),$cgi->hidden(-name=>"allfams", -value=>\@families), "\n",
138    $cgi->reset, $cgi->end_form;    $cgi->reset, $cgi->end_form;
# Line 241  Line 246 
246   print STDERR "Looking through ", scalar(@families), " families\n";   print STDERR "Looking through ", scalar(@families), " families\n";
247   my $famcount=1;my $time=time;   my $famcount=1;my $time=time;
248   my $content;   my $content;
249     my $row;
250   foreach my $fam (@families) {   foreach my $fam (@families) {
251    print STDERR "$famcount in ", time-$time, "\n"; $time=time; $famcount++;    print STDERR "$famcount in ", time-$time, "\n"; $time=time; $famcount++;
252    
253      push @$row, [$fam, 'td style="background-color: grey'];
254    
255    my @newprots=$fig->proteins_in_family($fam);    my @newprots=$fig->proteins_in_family($fam);
256      push @$row, scalar(@newprots);
257    
258    print STDERR "$fam has ", scalar(@newprots), "\n";    print STDERR "$fam has ", scalar(@newprots), "\n";
259    foreach my $p (@newprots) {    foreach my $p (@newprots) {
260     my @newfamilies=$fig->families_for_protein($p);     my @newfamilies=$fig->families_for_protein($p);
# Line 257  Line 267 
267    
268   my $tab=[];   my $tab=[];
269   @$tab=map {[$_, $fig->family_function($_), scalar(@{$content->{$_}})]} keys %$content;   @$tab=map {[$_, $fig->family_function($_), scalar(@{$content->{$_}})]} keys %$content;
270   my $col_hdrs=["Family ID", "Family function", "Nummber of proteins in family"];   my $col_hdrs=["Family ID", "Family function", "Number of proteins in family"];
271    
272   push @$html, $cgi->p("$prot is in families ", join ",", @families),   push @$html, $cgi->p("$prot is in families ", join ",", @families),
273   $cgi->p("These are the other families that $prot should also appear in:"),   $cgi->p("These are the other families that $prot should also appear in:"),
274   &HTML::make_table($col_hdrs, $tab, "Other Families"), "\n";   &HTML::make_table($col_hdrs, $tab, "Other Families"), "\n";
275  }  }
276    
277    
278    sub proteins_between_two {
279     my ($fig,$cgi,$html)=@_;
280     # first find all the families and all the cids in those families
281     my $cids; my @families; my $allprots;
282     foreach my $f (grep {$cgi->param($_)} $cgi->param("allfams"))
283     {
284      push @families, $f;
285      foreach my $e ($fig->ids_in_family($f)) {$cids->{$e}->{$f}=1; $allprots++}
286     }
287    
288     # now figure out those cids that are in all families
289     # we are going to do this with a boolean switch rather than just counting occurences
290     my @wanted; my @missing;
291     foreach my $cid (keys %$cids) {
292      my $keep=1;
293      foreach my $f (@families) {
294       unless ($cids->{$cid}->{$f}) {
295        undef $keep;
296        push @missing, $cid;
297       }
298      }
299      push @wanted, $cid if ($keep);
300     }
301    
302     # make some HTML header
303     push @$html, "<h2>Comparison of different protein families</h2><ul>\n";
304     foreach my $f (sort @families) {push @$html, "<li>", $fig->family_function($f), " ($f) </li>\n"}
305     push @$html, "</ul><p>These are the proteins that are unique to one or other of these families:</p>";
306    
307     foreach my $f (sort @families) {
308    
309      my $tab=[];
310      foreach my $p (sort {$a <=> $b} @missing) {
311       next unless ($cids->{$p}->{$f});
312       push @$tab, [$p, (join ", ", $fig->cid_to_prots($p))];
313      }
314    
315      my $list;
316      foreach my $x (@families) {next if ($f eq $x); $list .= "<li>". $fig->family_function($x). " ($x)</li>\n"}
317      push @$html, $cgi->p, "<div style='font-weight: bolder'>Proteins that are in <br><center style='font-weight: bigger'>",
318      $fig->family_function($f), " ($f)</center><br>\nthat are not in <ul>$list</ul>\n</div>\n",
319      &HTML::make_table(["Cluster ID", "Other Proteins"], $tab, " &nbsp; ");
320     }
321    }
322    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3