[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.6, Wed Jul 13 04:16:28 2005 UTC revision 1.7, Thu Jul 14 05:05:28 2005 UTC
# Line 6  Line 6 
6    
7  A base web interface for getting information about protein families in and out. Initially we are going to make a 3 (or 4) column table of protein, family and other proteins.  A base web interface for getting information about protein families in and out. Initially we are going to make a 3 (or 4) column table of protein, family and other proteins.
8    
9    PLEASE NOTE: Do not attempt to read or understand this code. Please leave now. It is a complete mess because it is very experimental and we are trying stuff out. none of it will work. The exit is this way ---->
10    
11  =cut  =cut
12    
13  use strict;  use strict;
# Line 78  Line 80 
80  elsif ($cgi->param('Suggest')) {  elsif ($cgi->param('Suggest')) {
81   &suggest_proteins($fig,$cgi,$html);   &suggest_proteins($fig,$cgi,$html);
82  }  }
83    elsif ($cgi->param('extend_family')) {
84     &extend_family($fig,$cgi,$html);
85    }
86  elsif ($cgi->param('family'))  elsif ($cgi->param('family'))
87  {  {
88   &show_family($fig,$cgi,$html);   &show_family($fig,$cgi,$html);
# Line 131  Line 136 
136    $cgi->start_form,    $cgi->start_form,
137    "<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",
138    &HTML::make_table($col_hdrs, $tab, "Families for $peg"),  "\n",    &HTML::make_table($col_hdrs, $tab, "Families for $peg"),  "\n",
139    $cgi->submit('Show Proteins In Each Family'), $cgi->submit(-name=>"Suggest", -value=>"Suggest Additional families for this protein"),    $cgi->submit('Show Proteins In Each Family'),
140    $cgi->submit(-name=>'proteins_between_two', -value=>"Compare two or more families for missing"), "<br>\n",    $cgi->submit(-name=>'proteins_between_two', -value=>"Compare two or more families for missing"), "<br>\n",
141      $cgi->submit(-name=>'extend_family', -value=>"Extend and contract family"),
142    $cgi->submit("Combine Families With And"), $cgi->submit("Compare FIG Functions"),    $cgi->submit("Combine Families With And"), $cgi->submit("Compare FIG Functions"),
143    $cgi->hidden(-name=>'prot'),$cgi->hidden(-name=>"allfams", -value=>\@families), "\n",    $cgi->hidden(-name=>'prot'),$cgi->hidden(-name=>"allfams", -value=>\@families), "\n",
144    $cgi->reset, $cgi->end_form;    $cgi->reset, $cgi->end_form;
145   }   }
146  }  }
147    
148    # this was deleted from above
149    #$cgi->submit(-name=>"Suggest", -value=>"Suggest Additional families for this protein"),
150    
151  sub show_family {  sub show_family {
152   my ($fig,$cgi,$html)=@_;   my ($fig,$cgi,$html)=@_;
153   foreach my $fam ($cgi->param('family')) {   foreach my $fam ($cgi->param('family')) {
# Line 320  Line 329 
329   }   }
330  }  }
331    
332    
333    sub extend_family {
334     my ($fig,$cgi,$html)=@_;
335    # here are the questions:
336    # 1. Given a column in a spreadsheet:
337    # 2. Here are the proteins in that column
338    # 3. For each protein, here are the families that they are in. How many families are unique and how many families is every protein in?
339    #       if we start with a column of 10 proteins, and nine of them are all in the same families and one is not, we want to exclude the one and keep the nine.
340    #       so we recommend that a protein be removed from a family.
341    # 4. For each of the families that are good, which proteins are there in some/most of the families that are not in the column that we are looking at
342    # 5. For each of the families that are good, which proteins are only in one of those families and not in any others?
343    
344    # Note that column == family, But start with fig and then  allow a replace ID feature like before.
345    
346     #my $focus=$cgi->param('focus') or "fig"; # these are the things that we are interested in
347     my $focus='fig';
348     push @$html, "<h2>Testing: Limited to fig</h2>\n";
349     foreach my $col (grep {$cgi->param($_)} $cgi->param("allfams"))
350     {
351      # $col is the column in the spreadsheet. This is really a family, but to visualize and code this I am doing it in a FIG-centric way
352      my %proteins_in_col;
353      map {$proteins_in_col{$_}=1} $fig->ids_in_family($col);
354    
355      # @proteins are the proteins in that column, although these are cids and not fids at the moment
356      my $familycount;
357      foreach my $prot (keys %proteins_in_col) {
358       foreach my $fam ($fig->in_family($prot)) {
359        $familycount->{$fam}++;
360       }
361      }
362    
363      my $tab=[];
364      foreach my $f (sort {$familycount->{$b} <=> $familycount->{$a}} keys %$familycount) {
365       next if ($f eq $col);
366       # It seems that $sz_family is not right
367       my @all=$fig->ids_in_family($f);
368       #my @allmissing=grep {!$proteins_in_col{$_}} ($fig->ids_in_family($f)); # note this is done in two separate lines so I can get the value of @allmissing
369       my @allmissing=grep {!$proteins_in_col{$_}} @all;
370       print STDERR "ALL: ", scalar(@all), " ALLMISSING: ", scalar(@allmissing), " IN COL: ", scalar(keys %proteins_in_col), "\n";
371       my @missing=
372            map {"<a href=\'/FIG/protein.cgi?user=$user&prot=$_'>$_</a>"}
373            grep {/^$focus/}
374            map {$fig->cid_to_prots($_)} @allmissing;
375            #grep {!$proteins_in_col{$_}}
376            #($fig->ids_in_family($f));
377    
378       my $prots_by_fam=join ", ", @missing;
379       push @$tab, [$f, scalar(@all), $fig->family_function($f), $familycount->{$f}, scalar(@allmissing), scalar(@missing), $prots_by_fam];
380      }
381    
382      my $col_hdrs=["Family ID", "Size of Family", "Family Function",
383                    "Number of proteins in $col that are also in the family in column 1",
384                    "Number of proteins in the family in column 1 that are not in $col",
385                    "Number of proteins in the family in column 1 that are not in $col and begin with $focus",
386                    "Proteins that are in the family in column 1 that are not"];
387      push @$html, $cgi->p, "<h3>Your chosen family was $col that has the function ", $fig->family_function($col), " and has ",
388      $fig->sz_family($col), " proteins</h3>",
389      $cgi->p("\nThese are the proteins that should also be in $col. Or maybe not.\n"), &HTML::make_table($col_hdrs, $tab, ' &nbsp; ');
390     }
391    }
392    
393    
394    

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3