[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.3, Tue Jul 12 14:34:15 2005 UTC revision 1.4, Wed Jul 13 01:49:55 2005 UTC
# Line 71  Line 71 
71   $cgi->param(-name=>'family', -value=>\@needed);   $cgi->param(-name=>'family', -value=>\@needed);
72   &compare_functions($fig,$cgi,$html);   &compare_functions($fig,$cgi,$html);
73  }  }
74    elsif ($cgi->param('Suggest')) {
75     &suggest_proteins($fig,$cgi,$html);
76    }
77  elsif ($cgi->param('family'))  elsif ($cgi->param('family'))
78  {  {
79   &show_family($fig,$cgi,$html);   &show_family($fig,$cgi,$html);
# Line 124  Line 127 
127    $cgi->start_form,    $cgi->start_form,
128    "<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",
129    &HTML::make_table($col_hdrs, $tab, "Families for $peg"),  "\n",    &HTML::make_table($col_hdrs, $tab, "Families for $peg"),  "\n",
130    $cgi->submit('Show Proteins In Each Family'), $cgi->submit("Combine Families With And"), $cgi->submit("Compare FIG Functions"),    $cgi->submit('Show Proteins In Each Family'), $cgi->submit(-name=>"Suggest", -value=>"Suggest Proteins for this Family"),
131    $cgi->hidden(-name=>"allfams", -value=>\@families), "\n",    $cgi->submit("Combine Families With And"), $cgi->submit("Compare FIG Functions"),
132      $cgi->hidden(-name=>'prot'),$cgi->hidden(-name=>"allfams", -value=>\@families), "\n",
133    $cgi->reset, $cgi->end_form;    $cgi->reset, $cgi->end_form;
134   }   }
135  }  }
# Line 133  Line 137 
137  sub show_family {  sub show_family {
138   my ($fig,$cgi,$html)=@_;   my ($fig,$cgi,$html)=@_;
139   foreach my $fam ($cgi->param('family')) {   foreach my $fam ($cgi->param('family')) {
140    my @eids=sort {$a <=> $b} $fig->ids_in_family($fam);    my @cids=sort {$a <=> $b} $fig->ids_in_family($fam);
141    my $tab=[];    my $tab=[];
142    my $col_hdrs=['Cluster ID', 'Polypeptides with same amino acid sequence'];    my $col_hdrs=['Cluster ID', 'Polypeptides with same amino acid sequence'];
143    foreach my $eid (@eids) {    foreach my $cid (@cids) {
144     my @pegs=$fig->eid_to_prots($eid);     my @pegs=$fig->cid_to_prots($cid);
145     foreach my $p (@pegs) {     foreach my $p (@pegs) {
146      foreach my $k (keys %proteinbase) {      foreach my $k (keys %proteinbase) {
147       if ($p =~ /^$k/) {$p =~ s/^(.*?)\|//; $p = "<a href='$proteinbase{$k}$p'>$1|$p</a>"}       if ($p =~ /^$k/) {$p =~ s/^(.*?)\|//; $p = "<a href='$proteinbase{$k}$p'>$1|$p</a>"}
148      }      }
149     }     }
150     push @$tab, [$eid, (join ", ", (@pegs))];     push @$tab, [$cid, (join ", ", (@pegs))];
151    }    }
152    
153    push @$html, "<h2>$fam Family</h2>\n",    push @$html, "<h2>$fam Family</h2>\n",
# Line 153  Line 157 
157    "<p>The links will take you to the respective databases for each of the other protein families.\n</p>",    "<p>The links will take you to the respective databases for each of the other protein families.\n</p>",
158    $cgi->start_form,    $cgi->start_form,
159    &HTML::make_table($col_hdrs, $tab, "Proteins in " . $fig->family_function($fam) . " ($fam)"),    &HTML::make_table($col_hdrs, $tab, "Proteins in " . $fig->family_function($fam) . " ($fam)"),
160    $cgi->hidden(-name=>'family', -value=>"$fam"), $cgi->submit("Compare FIG Functions"),    $cgi->hidden(-name=>'prot'),$cgi->hidden(-name=>'family', -value=>"$fam"), $cgi->submit("Compare FIG Functions"),
161    $cgi->end_form;    $cgi->end_form;
162   }   }
163  }  }
164    
165  sub combine_families {  sub combine_families {
166   my ($fig,$cgi,$html)=@_;   my ($fig,$cgi,$html)=@_;
167   # first find all the families and all the eids in those families   # first find all the families and all the cids in those families
168   my $eids; my @families; my $allprots;   my $cids; my @families; my $allprots;
169   foreach my $f (grep {$cgi->param($_)} $cgi->param("allfams"))   foreach my $f (grep {$cgi->param($_)} $cgi->param("allfams"))
170   {   {
171    push @families, $f;    push @families, $f;
172    foreach my $e ($fig->ids_in_family($f)) {$eids->{$e}->{$f}=1; $allprots++}    foreach my $e ($fig->ids_in_family($f)) {$cids->{$e}->{$f}=1; $allprots++}
173   }   }
174    
175   # now figure out those eids that are in all families   # now figure out those cids that are in all families
176   # we are going to do this with a boolean switch rather than just counting occurences   # we are going to do this with a boolean switch rather than just counting occurences
177   my @wanted;   my @wanted;
178   foreach my $eid (keys %$eids) {   foreach my $cid (keys %$cids) {
179    my $keep=1;    my $keep=1;
180    foreach my $f (@families) {undef $keep unless ($eids->{$eid}->{$f})}    foreach my $f (@families) {undef $keep unless ($cids->{$cid}->{$f})}
181    push @wanted, $eid if ($keep);    push @wanted, $cid if ($keep);
182   }   }
183    
184   my $tab=[];   my $tab=[];
185   my $col_hdrs=['Cluster ID', 'Polypeptides with same amino acid sequence'];   my $col_hdrs=['Cluster ID', 'Polypeptides with same amino acid sequence'];
186   foreach my $eid (sort {$a <=> $b} @wanted) {   foreach my $cid (sort {$a <=> $b} @wanted) {
187    my @pegs=$fig->eid_to_prots($eid);    my @pegs=$fig->cid_to_prots($cid);
188    foreach my $p (@pegs) {    foreach my $p (@pegs) {
189     foreach my $k (keys %proteinbase) {     foreach my $k (keys %proteinbase) {
190      if ($p =~ /^$k/) {$p =~ s/^(.*?)\|//; $p = "<a href='$proteinbase{$k}$p'>$1|$p</a>"}      if ($p =~ /^$k/) {$p =~ s/^(.*?)\|//; $p = "<a href='$proteinbase{$k}$p'>$1|$p</a>"}
191     }     }
192    }    }
193    push @$tab, [$eid, (join ", ", (@pegs))];    push @$tab, [$cid, (join ", ", (@pegs))];
194   }   }
195    
196    
197   push @$html, "<h2>Proteins in ", (join ", ", (@families)), " families</h2>\n",   push @$html, "<h2>Proteins in ", (join ", ", (@families)), " families</h2>\n",
198   "<h3>Summary</h3>\n<p>There were $allprots proteins in the ", scalar(@families), " families that you selected.\n<br>",   "<h3>Summary</h3>\n<p>There were $allprots proteins in the ", scalar(@families), " families that you selected.\n<br>",
199   "Out of a those proteins, there were ", scalar(keys %$eids),   "Out of a those proteins, there were ", scalar(keys %$cids),
200   " unique proteins, and ", scalar(@wanted), " proteins are present in the ",   " unique proteins, and ", scalar(@wanted), " proteins are present in the ",
201   scalar(@families), " families.</p>\n",   scalar(@families), " families.</p>\n",
202   "Each of the sequences with a given ID have the same amino acid sequence, and hence are the same polypeptide, even though they may come from different organisms.</p>",   "Each of the sequences with a given ID have the same amino acid sequence, and hence are the same polypeptide, even though they may come from different organisms.</p>",
# Line 205  Line 209 
209  sub compare_functions {  sub compare_functions {
210   my ($fig,$cgi,$html)=@_;   my ($fig,$cgi,$html)=@_;
211   foreach my $fam ($cgi->param('family')) {   foreach my $fam ($cgi->param('family')) {
212    my @eids=sort {$a <=> $b} $fig->ids_in_family($fam);    my @cids=sort {$a <=> $b} $fig->ids_in_family($fam);
213    my $tab=[];    my $tab=[];
214    my $col_hdrs=['FIG ID', 'Genome', 'Assigned Function'];    my $col_hdrs=['FIG ID', 'Genome', 'Assigned Function'];
215    foreach my $eid (@eids) {    foreach my $cid (@cids) {
216     foreach my $peg (grep {/^fig/} $fig->eid_to_prots($eid)) {     foreach my $peg (grep {/^fig/} $fig->cid_to_prots($cid)) {
217      my $p=$peg;      my $p=$peg;
218      $p =~ s/fig\|//;      $p =~ s/fig\|//;
219      $p = "<a href='$proteinbase{'fig'}$p'>$peg</a>";      $p = "<a href='$proteinbase{'fig'}$p'>$peg</a>";
# Line 222  Line 226 
226    "The functions shown here are the functions of just the proteins in the SEED database from this family</p>",    "The functions shown here are the functions of just the proteins in the SEED database from this family</p>",
227    $cgi->start_form,    $cgi->start_form,
228    &HTML::make_table($col_hdrs, $tab, "Proteins in " . $fig->family_function($fam) . " ($fam)"),    &HTML::make_table($col_hdrs, $tab, "Proteins in " . $fig->family_function($fam) . " ($fam)"),
229    $cgi->hidden(-name=>'family', -value=>"$fam"), $cgi->submit("Compare FIG Functions"),    $cgi->hidden(-name=>'prot'), $cgi->hidden(-name=>'family', -value=>"$fam"), $cgi->submit("Compare FIG Functions"),
230    $cgi->end_form;    $cgi->end_form;
231   }   }
232  }  }
233    
234    sub suggest_proteins {
235     my ($fig,$cgi,$html)=@_;
236     my $prot=$cgi->param('prot');
237     my @families=$fig->families_for_protein($prot);
238     my $knownfamily;
239     map {$knownfamily->{$_}=1} @families;
240    
241     print STDERR "Looking through ", scalar(@families), " families\n";
242     my $famcount=1;my $time=time;
243     my $content;
244     foreach my $fam (@families) {
245      print STDERR "$famcount in ", time-$time, "\n"; $time=time; $famcount++;
246    
247      my @newprots=$fig->proteins_in_family($fam);
248      print STDERR "$fam has ", scalar(@newprots), "\n";
249      foreach my $p (@newprots) {
250       my @newfamilies=$fig->families_for_protein($p);
251       foreach my $nf (@newfamilies) {
252        next if ($knownfamily->{$nf});
253        push @{$content->{$nf}}, $p;
254       }
255      }
256     }
257    
258     my $tab=[];
259     @$tab=map {[$_, $fig->family_function($_), scalar(@{$content->{$_}})]} keys %$content;
260     my $col_hdrs=["Family ID", "Family function", "Nummber of proteins in family"];
261    
262     push @$html, $cgi->p("$prot is in families ", join ",", @families),
263     $cgi->p("These are the other families that $prot should also appear in:"),
264     &HTML::make_table($col_hdrs, $tab, "Other Families"), "\n";
265    }
266    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3