[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.1, Wed Jun 29 00:28:01 2005 UTC revision 1.2, Fri Jul 1 02:09:16 2005 UTC
# Line 45  Line 45 
45    
46  unshift(@$html, "<TITLE>The SEED - Global Protein Families </TITLE>\n");  unshift(@$html, "<TITLE>The SEED - Global Protein Families </TITLE>\n");
47    
48  if ($cgi->param('family'))  my %proteinbase=(
49     "fig"  => "/FIG/protein.cgi?user=$user&prot=fig|",
50     "cog"  => "http://www.ncbi.nlm.nih.gov/COG/old/palox.cgi?",
51     "sp"   => "http://www.expasy.org/uniprot/",
52     "tr"   => "http://www.expasy.org/uniprot/",
53     "kegg" => "http://www.genome.jp/dbget-bin/www_bget?",
54    );
55    
56    
57    
58    if ($cgi->param('Show Proteins In Each Family'))
59    {
60     my @needed=grep {$cgi->param($_)} $cgi->param("allfams");
61     $cgi->param(-name=>'family', -value=>\@needed);
62     &show_family($fig,$cgi,$html);
63    }
64    elsif ($cgi->param("Combine Families With And"))
65    {
66     &combine_families($fig,$cgi,$html);
67    }
68    elsif ($cgi->param('Compare FIG Functions'))
69    {
70     my @needed=grep {$cgi->param($_)} $cgi->param("allfams");
71     $cgi->param(-name=>'family', -value=>\@needed);
72     &compare_functions($fig,$cgi,$html);
73    }
74    elsif ($cgi->param('family'))
75  {  {
76   &simpleshow($fig,$cgi,$html) if ($cgi->param('simpleshow'));   &show_family($fig,$cgi,$html);
  &intersect($fig,$cgi,$html) if ($cgi->param('Find Proteins In All Checked Families'));  
77  }  }
78  elsif ($cgi->param('prot'))  elsif ($cgi->param('prot'))
79  {  {
80   &choose_family($fig,$cgi,$html);   &show_protein($fig,$cgi,$html);
  &intersect($fig,$cgi,$html) if ($cgi->param('Find Proteins In All Checked Families'));  
81  }  }
82  else  else
83  {  {
# Line 67  Line 91 
91  sub show_initial {  sub show_initial {
92   my ($fig,$cgi,$html)=@_;   my ($fig,$cgi,$html)=@_;
93   # generate a blank page   # generate a blank page
94   push @$html, "<h2>Protein Families</h2><p>Please enter a protein ID in the box below. You will recieve a list of all the families that protein is in. You can use a FIG ID such as the peg in there now, or an ID from SwissProt, KEGG, NCBI, and others.</p>";   push @$html,
95   push @$html, $cgi->start_form(), "Please enter a protein id: ", $cgi->textfield(-name=>"prot", -value=>"fig|83333.1.peg.1697", -size=>40), "<br>", $cgi->submit, $cgi->reset, $cgi->end_form;   "<h2>Protein Families</h2>\n",
96     "<p>Please enter a protein ID . You will recieve a list of all the families that protein is in. \n",
97     "You can use a FIG ID such as fig|83333.1.peg.3, or an ID from SwissProt, KEGG, NCBI, and others.</p>",
98     $cgi->start_form(),
99     "Please enter a protein id: ", $cgi->textfield(-name=>"prot", -size=>40), "<br>",
100     "<p>Alternately, you can enter a family. Please enter a family name in the format pir|PIRSF001547 or fig|PF002363.</p>",
101     "Please enter a family id:  ", $cgi->textfield(-name=>"family", -size=>40), "<br>",
102     $cgi->submit, $cgi->reset, $cgi->end_form;
103   return $html;   return $html;
104  }  }
105    
106    sub show_protein {
 sub choose_family  
 {  
107   my ($fig,$cgi,$html)=@_;   my ($fig,$cgi,$html)=@_;
108   # we know the protein, so we are going to make a list of families that protein is in   foreach my $peg ($cgi->param('prot')) {
109   my $prot=$cgi->param('prot');    my @families=$fig->families_for_protein($peg);
110   my $eid=$fig->prot_to_eid($prot);    unless (@families)
111   my @families=$fig->in_family($eid);    {
112       push @$html, "<h2 style='color: red'>Sorry, $peg is not in any protein families</h2>";
113   # I am going to make a table here, but it is going to be complex so I am not going to use the $tab method     return;
  my $table="<table border=1>\n";  
  $table .= "<tr><Th>Protein</th><th>Family ID</th><th>Family Function</th><th>Family Size</th><th>Select Family</th><th>Other Proteins In Family</th><th>Proteins Function</th></tr>\n";  
  if (scalar @families)  
  {  
   $table .="<tr><td rowspan=". scalar(@families)." valign=middle align=center>$prot</td>";  
   # the first family will have to be on the same line as the protein identifier  
   my $fam=shift @families;  
   my $url=$cgi->url . "?prot=$prot&family=$fam&simpleshow=1&filter=fig";  
   $table .= "<td><a href='$url'>$fam</a></td><td>". $fig->family_function($fam) . "</td><td>" . $fig->sz_family($fam) . "</td><td>" . $cgi->checkbox(-name=>$fam, -label=>'') . "</td></tr>\n";  
   foreach $fam (@families) {  
    $url=$cgi->url . "?prot=$prot&family=$fam&simpleshow=1&filter=fig";  
    $table .= "<td><a href='$url'>$fam</a></td><td>". $fig->family_function($fam) . "</td><td>" . $fig->sz_family($fam) . "</td><td>" . $cgi->checkbox(-name=>$fam, -label=>'') . "</td></tr>\n";  
114    }    }
115    
116      my $tab=[];
117      my $self=$cgi->url;
118      foreach my $fam (@families) {
119       push @$tab, ["<a href='$self?family=$fam'>$fam</a>", $fig->family_function($fam), $fig->sz_family($fam), $cgi->checkbox(-name=>$fam, -label=>'')];
120   }   }
121   else  
122   {    my $col_hdrs=['Family ID', 'Family Function', 'Number of Unique Proteins in Family', 'Choose Family'];
123    $table .= "<tr><td>$prot</td><td colspan=6>No known families</td></tr>\n";    push @$html, "<h2>Families for $peg</h2>\n",
124      $cgi->start_form,
125      "<p>$peg is in the following ", scalar(@families), " families. Please choose one or more families using the checkboxes</p>\n",
126      &HTML::make_table($col_hdrs, $tab, "Families for $peg"),  "\n",
127      $cgi->submit('Show Proteins In Each Family'), $cgi->submit("Combine Families With And"), $cgi->submit("Compare FIG Functions"),
128      $cgi->hidden(-name=>"allfams", -value=>\@families), "\n",
129      $cgi->reset, $cgi->end_form;
130   }   }
  $table .= "</table>";  
  push @$html, $cgi->start_form,  
               $cgi->hidden(-name=>"prot", -value=>$cgi->param('prot')), "\n",  
               $cgi->hidden(-name=>"simpleshow", -value=>$cgi->param('simpleshow')), "\n",  
               "<p><h2>Protein Families</h2></p><p>This table shows all the families that your protein is in. The protein is listed on the left. The links under family ID will give you a representation of that family.<br>The family size is the number of proteins in that particular family.<br>You can either click on an individual family or compare several families at once.", $cgi->p,  
               $cgi->hidden(-name=>"filter", -value=>"fig"),  
               $cgi->submit, $cgi->reset,  
               $table, $cgi->p,  
               $cgi->submit('Find Proteins In All Checked Families'), $cgi->p,  
               $cgi->submit, $cgi->reset, $cgi->end_form;  
131  }  }
132    
133  sub simpleshow {  sub show_family {
134   my ($fig,$cgi,$html)=@_;   my ($fig,$cgi,$html)=@_;
135   my $prot=$cgi->param('prot');   foreach my $fam ($cgi->param('family')) {
136   my $wantfam=$cgi->param('family');    my @eids=sort {$a <=> $b} $fig->ids_in_family($fam);
137   my $eid=$fig->prot_to_eid($prot);    my $tab=[];
138   my @families=$fig->in_family($eid);    my $col_hdrs=['Cluster ID', 'Polypeptides with same protein sequence'];
139   my $filter=$cgi->param('filter'); unless ($filter) {$filter="."}    foreach my $eid (@eids) {
140       my @pegs=$fig->eid_to_prots($eid);
141   # make another complex table. This will have the same number of rows as the size of the family     foreach my $p (@pegs) {
142   my $rows=$fig->sz_family($wantfam);      foreach my $k (keys %proteinbase) {
143   my @mates=$fig->ids_in_family($wantfam);       if ($p =~ /^$k/) {$p =~ s/^(.*?)\|//; $p = "<a href='$proteinbase{$k}$p'>$1|$p</a>"}
   
  my $table="<table border=1>\n";  
  $table .= "<tr><Th>Protein</th><th>Family ID</th><th>Family Function</th><th>Family Size</th><th>Select Family</th><th>Other Proteins In Family</th><th>Proteins Function</th></tr>\n";  
  if (scalar @families)  
  {  
   my $class="increase_visibility";  
   $table .="<tr><td rowspan=$rows valign=middle align=center>$prot</td>";  
   my $fam=$wantfam;  
   @families=grep {!/$wantfam/} @families;  
   my $url=$cgi->url . "&family=$fam&simpleshow=1&filter=$filter";  
   $table .= "<td class='$class'><a href='$url'>$fam</a></td><td class='$class'>". $fig->family_function($fam) . "</td><td class='$class'>" . $fig->sz_family($fam) . "</td><td>" . $cgi->checkbox(-name=>$fam, -label=>'') . "</td>";  
   my $mate=shift @mates; my %functions;  
   my @others;  
   my @eids=grep {/$filter/} $fig->eid_to_prots($mate);  
   if (scalar @eids) {  
    foreach my $ot (@eids) {  
     push @others, "<a href='/FIG/protein.cgi?prot=$ot'>$ot</a>";  
     $functions{$fig->function_of($ot)}=1;  
144     }     }
    $table .= "<td>" . (join ", ", (@others)) . "</td><td>" . (join ", ", (grep {/\S/} keys %functions)) . "</td></tr>\n";  
145    }    }
146    else     push @$tab, [$eid, (join ", ", (@pegs))];
   {  
    $table .= "<td colspan=2>No $filter id's in group $mate. Try changing the filter below</td></tr>\n";  
147    }    }
148    # now we need to generate the table for the rest of the data. But the two arrays will be of different sizes, so we need to figure  
149    # out which is the bigger, and cycle through that many times.    push @$html, "<h2>$fam Family</h2>\n",
150    my $most=$#mates;    "<p>The family $fam has the function ", $fig->family_function($fam), ", and contains ", $fig->sz_family($fam), " proteins, as shown in the table below.<br>",
151    $class="decrease_visibility";    "Each of the proteins with a given ID have the same sequence, and hence are the same polypeptide, even though they may come from different organisms.</p>",
152    if ($#families > $most) {$most=$#families}    "<p>The links will take you to the respective databases for each of the other protein families.\n</p>",
153    for (my $i=0; $i<=$most; $i++) {    $cgi->start_form,
154     if ($families[$i]) {    &HTML::make_table($col_hdrs, $tab, "Proteins in " . $fig->family_function($fam) . " ($fam)"),
155      $fam=$families[$i];    $cgi->hidden(-name=>'family', -value=>"$fam"), $cgi->submit("Compare FIG Functions"),
156      $url=$cgi->url . "?prot=$prot&family=$fam&simpleshow=1&filter=$filter";    $cgi->end_form;
     $table .= "<tr><td class='$class'><a href='$url'>$fam</a></td><td class='$class'>". $fig->family_function($fam) . "</td><td class='$class'>" . $fig->sz_family($fam) . "</td><td>" . $cgi->checkbox(-name=>$fam, -label=>'') . "</td>";  
    }  
    else {  
     $table .= "<tr><td colspan=4> &nbsp; </td>";  
    }  
    if ($mates[$i]) {  
     $mate=$mates[$i];  
     undef %functions; undef @others;  
     my @eids=grep {/$filter/} $fig->eid_to_prots($mate);  
     if (scalar @eids) {  
      foreach my $ot (@eids) {  
       push @others, "<a href='/FIG/protein.cgi?prot=$ot&user=$user'>$ot</a>";  
       $functions{$fig->function_of($ot)}=1;  
157       }       }
      $table .= "<td>" . (join ", ", (@others)) . "</td><td>" . (join ", ", (grep {/\S/} keys %functions)) . "</td></tr>\n";  
158      }      }
159      else  
160    sub combine_families {
161     my ($fig,$cgi,$html)=@_;
162     # first find all the families and all the eids in those families
163     my $eids; my @families;
164     foreach my $f (grep {$cgi->param($_)} $cgi->param("allfams"))
165      {      {
166       $table .= "<td colspan=2>No $filter id's in group $mate. Try changing the filter below</td></tr>\n";    push @families, $f;
167      foreach my $e ($fig->ids_in_family($f)) {
168       $eids->{$e}->{$f}=1;
169      }
170      }      }
171    
172     # now figure out those eids that are in all families
173     # we are going to do this with a boolean switch rather than just counting occurences
174     my @wanted;
175     foreach my $eid (keys %$eids) {
176      my $keep=1;
177      foreach my $f (@families) {undef $keep unless (exists $eids->{$eid}->{$f})}
178      push @wanted if ($keep);
179     }     }
180     else {  
181      $table .= "<tr><td colspan=2> &nbsp; </td>";   my $tab=[];
182     my $col_hdrs=['Cluster ID', 'Polypeptides with same protein sequence'];
183     foreach my $eid (@wanted) {
184      my @pegs=$fig->eid_to_prots($eid);
185      foreach my $p (@pegs) {
186       foreach my $k (keys %proteinbase) {
187        if ($p =~ /^$k/) {$p =~ s/^(.*?)\|//; $p = "<a href='$proteinbase{$k}$p'>$1|$p</a>"}
188     }     }
189    }    }
190      push @$tab, [$eid, (join ", ", (@pegs))];
191   }   }
192   $table .= "</table>\n\n";  
193   push @$html, $cgi->start_form,  
194                $cgi->hidden(-name=>"prot", -value=>$cgi->param('prot')), "\n",   push @$html, "<h2>Proteins in ", (join ", ", (@families)), " families</h2>\n",
195                $cgi->hidden(-name=>"family", -value=>$cgi->param('family')), "\n",   "<p>The following proteins are present in the ", scalar(@families), " families that you selected.<br>",
196                $cgi->hidden(-name=>"simpleshow", -value=>$cgi->param('simpleshow')), "\n",   "Each of the proteins with a given ID have the same sequence, and hence are the same polypeptide, even though they may come from different organisms.</p>",
197                "<p><h2>Protein Families</h2></p><p>This table shows all the families that your protein is in. The protein is listed on the left. The links under family ID will give you a representation of that family in this layout. The proteins in the family shown in the right two columns are the proteins from the family that is highlighted. You can filter those proteins based on their database of origin using the filter here.<p>", $cgi->p,   "<p>The links will take you to the respective databases for each of the other protein families.\n</p>",
198                "Filter the results to those beginning with: ", $cgi->textfield(-name=>"filter", -size=>6, -default=>$filter), $cgi->submit, $cgi->reset,   $cgi->start_form,
199                $table, $cgi->p,   &HTML::make_table($col_hdrs, $tab, "Proteins in " . (join ", ", (@families)) . " families"),
200                "Filter the results to those beginning with: ", $cgi->textfield(-name=>"filter", -size=>6, -default=>$filter), $cgi->submit("Refilter"), $cgi->reset,   $cgi->end_form;
               $cgi->submit('Find Proteins In All Checked Families'), $cgi->p,  
               $cgi->submit, $cgi->reset, $cgi->end_form;  
201  }  }
202    
203  sub intersect {  sub compare_functions {
204   my ($fig,$cgi,$html)=@_;   my ($fig,$cgi,$html)=@_;
205   my $prot=$cgi->param('prot');   foreach my $fam ($cgi->param('family')) {
206   my $wantfam=$cgi->param('family');    my @eids=sort {$a <=> $b} $fig->ids_in_family($fam);
207   my $filter=$cgi->param('filter'); unless ($filter) {$filter="."}    my $tab=[];
208      my $col_hdrs=['FIG ID', 'Genome', 'Assigned Function'];
209   # figure out which families we are looking for the intersection between    foreach my $eid (@eids) {
210   my ($families, $proteins);     foreach my $peg (grep {/^fig/} $fig->eid_to_prots($eid)) {
211   foreach my $fam ($fig->families_for_protein($prot)) {      my $p=$peg;
212    next unless ($cgi->param($fam));      $p =~ s/fig\|//;
213    $families->{$fam}=1;      $p = "<a href='$proteinbase{'fig'}$p'>$peg</a>";
214    foreach my $peg ($fig->proteins_in_family($fam)) {      push @$tab, [$p, ($fig->genus_species($fig->genome_of($peg))), scalar($fig->function_of($peg))];
    $proteins->{$peg}->{$fam}=1;  
215    }    }
216   }   }
217    
218   push @$html, $cgi->start_form,    push @$html, "<h2>Functions in $fam Family</h2>\n",
219                $cgi->hidden(-name=>"prot", -value=>$cgi->param('prot')), "\n",    "<p>The family $fam has the function ", $fig->family_function($fam), ".\n",
220                $cgi->hidden(-name=>"family", -value=>$cgi->param('family')), "\n",    "The functions shown here are the functions of just the proteins in the SEED database from this family</p>",
221                $cgi->hidden(-name=>"simpleshow", -value=>$cgi->param('simpleshow')), "\n",    $cgi->start_form,
222                $cgi->hidden(-name=>"Find Proteins In All Checked Families", -value=>1), "\n",    &HTML::make_table($col_hdrs, $tab, "Proteins in " . $fig->family_function($fam) . " ($fam)"),
223                map {$cgi->hidden(-name=>"$_", -value=>1)} keys %$families;    $cgi->hidden(-name=>'family', -value=>"$fam"), $cgi->submit("Compare FIG Functions"),
224      $cgi->end_form;
  push @$html, "<p>Proteins in the following families: &nbsp; ", (join ", &nbsp; ", (keys %$families)), "</p>\n";  
  foreach my $peg (grep {/$filter/} keys %$proteins) {  
   if (scalar(keys %{$proteins->{$peg}}) == scalar(keys %$families)) {  
    push @$html, "<a href='/FIG/protein.cgi?prot=$peg&user=$user'>$peg</a><br>\n";  
   }  
225   }   }
  push @$html, "Filter the results to those beginning with: ", $cgi->textfield(-name=>"filter", -size=>6, -default=>$filter), $cgi->submit,$cgi->reset;  
226  }  }
227    
   
   

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3