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

Diff of /FigWebServices/sigs.cgi

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

revision 1.40, Mon Aug 14 04:57:29 2006 UTC revision 1.41, Sat Aug 26 17:37:50 2006 UTC
# Line 74  Line 74 
74    
75  my $given = $cgi->param('given');  my $given = $cgi->param('given');
76    
77  if (((@set1 == 0) && (@set2 == 0)) || (! $given))  # Determine the operating mode.
78  {  my $submit1 = $cgi->param("Find Common Proteins");
79    my $submit2 = $cgi->param("Find Discriminating Proteins");
80    # This will be set to 1 for common proteins and 2 for discriminating proteins.
81    my $mode = 0;
82    
83    if (! $given && ($submit1 || $submit2)) {
84        push @$html, $cgi->h3("You must select a given organism.");
85    } else {
86        # Here the user wantsd to process data. Insure the given organism is in
87        # set 1.
88        my @found = grep { $_ eq $given } @set1;
89        if (! @found) {
90            push @set1, $given;
91        }
92        if ($submit1) {
93            $mode = 1;
94            if (@set2 > 0) {
95                push @$html, $cgi->h3("Organisms from set 2 were ignored.");
96            }
97        } elsif ($submit2) {
98            if (@set2 == 0) {
99                push @$html, $cgi->h3("Could not process: set 2 was empty.");
100            } else {
101                $mode = 2;
102            }
103        }
104    }
105    
106    if ($mode == 0) {
107    
108      $col_hdrs = ["Given","Set 1","","Set 2","genome","Genus/Species"];      $col_hdrs = ["Given","Set 1","","Set 2","genome","Genus/Species"];
109      $tab = [];      $tab = [];
# Line 91  Line 119 
119      @given = $cgi->radio_group(-name => 'given',      @given = $cgi->radio_group(-name => 'given',
120                                 -values => [@orgs],                                 -values => [@orgs],
121                                 -nolabels => 1);                                 -nolabels => 1);
122        # We're going to create a navigation bar here that gets you automatically
123        # to the first organism beginning with a specified letter.
124        my $bar = $cgi->a({ name => "bar" },"");
125        my $currLetter = "";
126      foreach $org (@orgs)      foreach $org (@orgs)
127      {      {
128            my $name = $full{$org};
129            my $backToTop = "";
130            if (substr($name, 0, 1) ne $currLetter) {
131                # Here we have a navigation target: the first organism whose name begins
132                # with a new letter. We put in the name label
133                $currLetter = substr($name, 0, 1);
134                $bar .= $cgi->a({ href => "#$currLetter" }, $currLetter) . " ";
135                $name = $cgi->a({ name => $currLetter },"") . $name;
136                $backToTop = $cgi->a({ href => "#bar"}, "TOP");
137            }
138          push(@$tab,[shift @given,          push(@$tab,[shift @given,
139                      $cgi->radio_group(-name => $org,                      $cgi->radio_group(-name => $org,
140                                        -default => 'neither',                                        -default => 'neither',
# Line 101  Line 142 
142                                        -nolabels => 1                                        -nolabels => 1
143                                        ),                                        ),
144                      $org,                      $org,
145                      $full{$org}]);                      $name, $backToTop]);
146      }      }
147      my $sprout = $cgi->param('SPROUT') ? 1 : 0;      my $sprout = $cgi->param('SPROUT') ? 1 : 0;
148        # Create the navigation bar.
149      push(@$html,$cgi->start_form(-action => 'sigs.cgi'),      push(@$html,$cgi->start_form(-action => 'sigs.cgi'),
150                  $cgi->hidden(-name => 'SPROUT', -value => $sprout),                  $cgi->hidden(-name => 'SPROUT', -value => $sprout),
151                  $cgi->h1("Find Proteins that Discriminate Two Sets of Organisms or Are Common to a Set of Organisms"),                  $cgi->h3("Find Proteins from Given Organism that Discriminate Set 1 from Set 2"),
                 &HTML::make_table($col_hdrs,$tab,"Pick organisms for Set 1 and Set 2"),  
152                  $cgi->br, "Similarity Cutoff: ",$cgi->textfield(-name => "cutoff", -size => 10, -value => 1.0e-10),                  $cgi->br, "Similarity Cutoff: ",$cgi->textfield(-name => "cutoff", -size => 10, -value => 1.0e-10),
153                  $cgi->br,                  $cgi->br,
154                  $cgi->checkbox( -name => 'sort_by_func', -value => 1, -override => 1, -checked => 0, -label => 'Sort by Function'),                  $cgi->checkbox( -name => 'sort_by_func', -value => 1, -override => 1, -checked => 0, -label => 'Sort by Function'),
155                  $cgi->br,                  $cgi->br,
156                  $cgi->checkbox( -name => 'write_tab', -value => 1, -override => 1, -checked => 0, -label => 'Export Tab Delimited Table'),                  $cgi->checkbox( -name => 'write_tab', -value => 1, -override => 1, -checked => 0, -label => 'Export Tab Delimited Table'),
157                  $cgi->br,                  $cgi->br,
158                    $cgi->submit("Find Discriminating Proteins"),$cgi->reset,
159                    $cgi->br,
160                  $cgi->br,                  $cgi->br,
161                  $cgi->submit("Find the Discriminating Proteins from Given Organism"),$cgi->reset,                  $cgi->h3("Find Proteins from Given Organism that are Common to Set 1"),
162                  $cgi->br,                  $cgi->br,
163                    "Minimum matches from Set 1: ", $cgi->textfield(-name => minN, -size => 5),
164                  $cgi->br,                  $cgi->br,
165                  $cgi->submit("Find Genes from Checked Organism and in Organisms from Set 1"),                  $cgi->submit("Find Common Proteins"),$cgi->reset,
166                  " (minimum matches from Set 1: )", $cgi->textfield(-name => minN, -size => 5));                  $cgi->br, $cgi->br,
167                    $cgi->h3("Select Given, Set 1, and Set 2"),
168                    $cgi->p($bar),
169                    &HTML::make_table($col_hdrs,$tab,"Pick organisms for Set 1 and Set 2"),
170                    $cgi->br);
171      if ($cgi->param('TTYPE')) {      if ($cgi->param('TTYPE')) {
172          push @$html,          push @$html,
173                  $cgi->br,                  $cgi->br,
# Line 129  Line 177 
177      push @$html,      push @$html,
178                  $cgi->end_form,                  $cgi->end_form,
179                  "\n";                  "\n";
180  }  } else {
181  else      # Mode 1 or 2
 {  
182      my $sim_cutoff = $cgi->param('sim_cutoff');      my $sim_cutoff = $cgi->param('sim_cutoff');
183      if (! $sim_cutoff) { $sim_cutoff = 1.0e-10 }      if (! $sim_cutoff) { $sim_cutoff = 1.0e-10 }
   
     if (@set1 > 0)  
     {  
184          my @hits;          my @hits;
185          if (@set2 > 0)      if ($mode == 2) {
         {  
186              @hits = &differentiating_genes(\@set1,\@set2,$given,$sim_cutoff,$is_sprout);              @hits = &differentiating_genes(\@set1,\@set2,$given,$sim_cutoff,$is_sprout);
187              Trace(scalar(@hits) . " hits found by differentiating_genes.") if T(3);              Trace(scalar(@hits) . " hits found by differentiating_genes.") if T(3);
188              if ($cgi->param('sort_by_func'))          if ($cgi->param('sort_by_func')) {
             {  
189                  @hits    = sort { ($a->[2] cmp $b->[2]) or ($b->[1] <=> $a->[1]) or (&FIG::by_fig_id($a->[0],$b->[0])) } @hits;                  @hits    = sort { ($a->[2] cmp $b->[2]) or ($b->[1] <=> $a->[1]) or (&FIG::by_fig_id($a->[0],$b->[0])) } @hits;
190              }          } else {
             else  
             {  
191                  @hits    = sort { ($b->[1] <=> $a->[1]) || (&FIG::by_fig_id($a->[0],$b->[0])) } @hits;                  @hits    = sort { ($b->[1] <=> $a->[1]) || (&FIG::by_fig_id($a->[0],$b->[0])) } @hits;
192              }              }
193    
194              if ($cgi->param('write_tab'))          if ($cgi->param('write_tab')) {
             {  
195                  push(@$html,"<pre>\n");                  push(@$html,"<pre>\n");
196                  foreach $_ (@hits)              foreach $_ (@hits) {
                 {  
197                      push(@$html,join("\t",@$_) . "\n");                      push(@$html,join("\t",@$_) . "\n");
198                  }                  }
199                  push(@$html,"</pre>\n");                  push(@$html,"</pre>\n");
200              }          } else {
             else  
             {  
201                  $col_hdrs = ["","Gene","Score","Function"];                  $col_hdrs = ["","Gene","Score","Function"];
202                  $tab      = [];                  $tab      = [];
203                  my $gs = $fig_or_sprout->genus_species($given);                  my $gs = $fig_or_sprout->genus_species($given);
204                  $title    = "Genes in $gs that Discriminate";                  $title    = "Genes in $gs that Discriminate";
205                  my $subscript = 1;                  my $subscript = 1;
206                  foreach $_ (@hits)              foreach $_ (@hits) {
                 {  
207                      my($peg,$score,$function) = @$_;                      my($peg,$score,$function) = @$_;
208                      push(@$tab,[$subscript,&HTML::fid_link($cgi,$peg,"local"),$score,$function]);                      push(@$tab,[$subscript,&HTML::fid_link($cgi,$peg,"local"),$score,$function]);
209                      $subscript++;                      $subscript++;
210                  }                  }
   
211                  push(@$html,&HTML::make_table($col_hdrs,$tab,$title));                  push(@$html,&HTML::make_table($col_hdrs,$tab,$title));
212              }              }
213          }      } else {
214          else          # Mode 1
         {  
215              my($i,$j,%which_col,$peg1,$func1,$link,$genome1,$hit);              my($i,$j,%which_col,$peg1,$func1,$link,$genome1,$hit);
216              my $minN = $cgi->param('minN');              my $minN = $cgi->param('minN');
217              $minN = $minN ? $minN : @set1;              $minN = $minN ? $minN : @set1;
218              @hits = &common_genes(\@set1,$given,$sim_cutoff,$minN,$is_sprout);              @hits = &common_genes(\@set1,$given,$sim_cutoff,$minN,$is_sprout);
219              $col_hdrs = ["",&FIG::abbrev($fig_or_sprout->genus_species($given)),"Score","Function"];              $col_hdrs = ["",&FIG::abbrev($fig_or_sprout->genus_species($given)),"Score","Function"];
220              for ($i=0; ($i < @set1); $i++)          for ($i=0; ($i < @set1); $i++) {
             {  
221                  $which_col{$set1[$i]} = $i+4;                  $which_col{$set1[$i]} = $i+4;
222                  push(@$col_hdrs,&FIG::abbrev($fig_or_sprout->genus_species($set1[$i])));                  push(@$col_hdrs,&FIG::abbrev($fig_or_sprout->genus_species($set1[$i])));
223              }              }
# Line 193  Line 225 
225              $tab      = [];              $tab      = [];
226              $title    = "Genes in Common";              $title    = "Genes in Common";
227    
228              for ($j=0; ($j < @hits); $j++)          for ($j=0; ($j < @hits); $j++) {
             {  
229                  my($peg,$score,$hits) = @{$hits[$j]};                  my($peg,$score,$hits) = @{$hits[$j]};
230                  my $func = scalar $fig_or_sprout->function_of($peg,$cgi->param('user'));                  my $func = scalar $fig_or_sprout->function_of($peg,$cgi->param('user'));
231                  my $row = [$j+1,&HTML::fid_link($cgi,$peg,"local"),$score,$func];                  my $row = [$j+1,&HTML::fid_link($cgi,$peg,"local"),$score,$func];
232                  for ($i=0; ($i < @set1); $i++)              for ($i=0; ($i < @set1); $i++) {
                 {  
233                      push(@$row,"");                      push(@$row,"");
234                  }                  }
235                  foreach $hit (@$hits)              foreach $hit (@$hits) {
                 {  
236                      ($peg1,$func1) = @$hit;                      ($peg1,$func1) = @$hit;
237                      $genome1 = &FIG::genome_of($peg1);                      $genome1 = &FIG::genome_of($peg1);
238                      $col     = $which_col{$genome1};                      $col     = $which_col{$genome1};
# Line 215  Line 244 
244              push(@$html,&HTML::make_table($col_hdrs,$tab,$title));              push(@$html,&HTML::make_table($col_hdrs,$tab,$title));
245          }          }
246      }      }
     else  
     {  
         push(@$html,$cgi->h1("You need to fill in at least Set1"));  
     }  
 }  
247  if ($is_sprout) {  if ($is_sprout) {
248      # For sprout, we use a template.      # For sprout, we use a template.
249      my $template = "$FIG_Config::template_url/Sigs_tmpl.php";      my $template = "$FIG_Config::template_url/Sigs_tmpl.php";

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.41

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3