[Bio] / Sprout / SHSigGenes.pm Repository:
ViewVC logotype

Diff of /Sprout/SHSigGenes.pm

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

revision 1.19, Tue Apr 29 20:52:45 2008 UTC revision 1.21, Thu Feb 5 07:24:09 2009 UTC
# Line 4  Line 4 
4    
5      use strict;      use strict;
6      use Tracer;      use Tracer;
7      use CGI;      use CGI qw(-nosticky);
8      use HTML;      use HTML;
9      use Sprout;      use Sprout;
10      use Time::HiRes;      use Time::HiRes;
# Line 99  Line 99 
99      # Now we build the table rows.      # Now we build the table rows.
100      my @rows = ();      my @rows = ();
101      # First we have the given genome.      # First we have the given genome.
102      push @rows, $cgi->Tr($cgi->td({valign => "top"}, "Reference Genome"),      push @rows, CGI::Tr(CGI::td({valign => "top"}, "Reference Genome"),
103                           $cgi->td({colspan => 2}, $givenMenu));                           CGI::td({colspan => 2}, $givenMenu));
104      # Now show the target and exclusion menus.      # Now show the target and exclusion menus.
105      push @rows, $cgi->Tr($cgi->td({valign => "top"}, "Inclusion Genomes (Set 1)"),      push @rows, CGI::Tr(CGI::td({valign => "top"}, "Inclusion Genomes (Set 1)"),
106                           $cgi->td({colspan => 2}, $targetMenu));                           CGI::td({colspan => 2}, $targetMenu));
107      push @rows, $cgi->Tr($cgi->td({valign => "top"}, "Exclusion Genomes (Set 2)"),      push @rows, CGI::Tr(CGI::td({valign => "top"}, "Exclusion Genomes (Set 2)"),
108                           $cgi->td({colspan => 2}, $excludeMenu));                           CGI::td({colspan => 2}, $excludeMenu));
109      # Next, the tuning parameters.      # Next, the tuning parameters.
110      push @rows, $cgi->Tr($cgi->td("Commonality"),      push @rows, CGI::Tr(CGI::td("Commonality"),
111                           $cgi->td($cgi->textfield(-name => 'commonality',                           CGI::td(CGI::textfield(-name => 'commonality',
112                                                    -value => $commonality,                                                    -value => $commonality,
113                                                    -size => 5))),                                                    -size => 5))),
114                  $cgi->Tr($cgi->td(), $cgi->td(join(" ",                  CGI::Tr(CGI::td(), CGI::td(join(" ",
115                                    $cgi->checkbox(-name => 'statistical',                                    CGI::checkbox(-name => 'statistical',
116                                                   -checked => $statistical,                                                   -checked => $statistical,
117                                                   -value => 1,                                                   -value => 1,
118                                                   -label => 'Use Statistical Algorithm') .                                                   -label => 'Use Statistical Algorithm') .
# Line 122  Line 122 
122                                                       "specifically to choose differentiating genes. " .                                                       "specifically to choose differentiating genes. " .
123                                                       "This box has no effect when looking for genes " .                                                       "This box has no effect when looking for genes " .
124                                                       "in common."),                                                       "in common."),
125                                    $cgi->checkbox(-name => 'useSims',                                    CGI::checkbox(-name => 'useSims',
126                                                   -checked => $useSims,                                                   -checked => $useSims,
127                                                   -value => 1,                                                   -value => 1,
128                                                   -label => 'Use Similarities') .                                                   -label => 'Use Similarities') .
# Line 130  Line 130 
130                                                       "Normally, Bidirectional Best Hits are used to " .                                                       "Normally, Bidirectional Best Hits are used to " .
131                                                       "find matching genes. Check this box to use " .                                                       "find matching genes. Check this box to use " .
132                                                       "similarities instead.")))),                                                       "similarities instead.")))),
133                  $cgi->Tr($cgi->td(), $cgi->td(join(" ",                  CGI::Tr(CGI::td(), CGI::td(join(" ",
134                                    $cgi->checkbox(-name => 'showMatch',                                    CGI::checkbox(-name => 'showMatch',
135                                                   -checked => $showMatch,                                                   -checked => $showMatch,
136                                                   -value => 1,                                                   -value => 1,
137                                                   -label => 'Show Matching Genes') .                                                   -label => 'Show Matching Genes') .
138                                    SearchHelper::Hint("SigGenes",                                    SearchHelper::Hint("SigGenes",
139                                                       "Check this button to display the genes matching " .                                                       "Check this button to display the genes matching " .
140                                                       "each gene displayed in the results.")))),                                                       "each gene displayed in the results.")))),
141                  $cgi->Tr($cgi->td("Cutoff"),                  CGI::Tr(CGI::td("Cutoff"),
142                           $cgi->td($cgi->textfield(-name => 'cutoff',                           CGI::td(CGI::textfield(-name => 'cutoff',
143                                                    -value => $cutoff,                                                    -value => $cutoff,
144                                                    -size => 5)));                                                    -size => 5)));
145      # Next, the feature filter rows.      # Next, the feature filter rows.
# Line 203  Line 203 
203          }          }
204          # Only proceed if the filtering parameters are valid.          # Only proceed if the filtering parameters are valid.
205          if ($rhelp->Valid()) {          if ($rhelp->Valid()) {
             # Start the output session.  
             $self->OpenSession($rhelp);  
206              # Now we need to gather and validate the genome sets.              # Now we need to gather and validate the genome sets.
207              $self->PrintLine("Gathering the target genomes.  ");              $self->PrintLine("Gathering the target genomes.  ");
208              my ($givenGenomeID) = $self->GetGenomes('given');              my ($givenGenomeID) = $self->GetGenomes('given');
209                Trace("Given genome is $givenGenomeID.") if T(3);
210              my %targetGenomes = map { $_ => 1 } $self->GetGenomes('target');              my %targetGenomes = map { $_ => 1 } $self->GetGenomes('target');
211                Trace("Target genomes are " . join(", ", sort keys %targetGenomes) . ".") if T(3);
212              $self->PrintLine("Gathering the exclusion genomes.  ");              $self->PrintLine("Gathering the exclusion genomes.  ");
213              my %exclusionGenomes = map { $_ => 1 } $self->GetGenomes('exclusion');              my %exclusionGenomes = map { $_ => 1 } $self->GetGenomes('exclusion');
214                Trace("Exclusion genomes are " . join(", ", sort keys %exclusionGenomes) . ".") if T(3);
215              $self->PrintLine("Validating the genome sets.<br />");              $self->PrintLine("Validating the genome sets.<br />");
216              # Insure the given genome is not in the exclusion set.              # Insure the given genome is not in the exclusion set.
217              if ($exclusionGenomes{$givenGenomeID}) {              if ($exclusionGenomes{$givenGenomeID}) {
218                  $self->SetMessage("The given genome ($givenGenomeID) cannot be in the exclusion set.");                  $self->SetMessage("The given genome ($givenGenomeID) cannot be in the exclusion set.");
219              } else {              } else {
220                    # Start the output session.
221                    $self->OpenSession($rhelp);
222                  # Insure the given genome is in the target set.                  # Insure the given genome is in the target set.
223                  $targetGenomes{$givenGenomeID} = 1;                  $targetGenomes{$givenGenomeID} = 1;
224              }                  Trace("$givenGenomeID added to target set.") if T(3);
225              # Find out if we want to use a statistical analysis.              # Find out if we want to use a statistical analysis.
226              my $statistical = $cgi->param('statistical') || 1;              my $statistical = $cgi->param('statistical') || 1;
227              # Denote we have not yet found any genomes.              # Denote we have not yet found any genomes.
# Line 228  Line 231 
231              # Get the peg matrix.              # Get the peg matrix.
232              Trace("Requesting matrix.") if T(3);              Trace("Requesting matrix.") if T(3);
233              $saveTime = time();              $saveTime = time();
234              my %bbhMatrix;                  my $bbhMatrix;
235              if (! $cgi->param('useSims')) {              if (! $cgi->param('useSims')) {
236                  # Here we are using BBHs, which are fast enough to do in one gulp.                  # Here we are using BBHs, which are fast enough to do in one gulp.
237                  $self->PrintLine("Requesting bidirectional best hits.  ");                  $self->PrintLine("Requesting bidirectional best hits.  ");
238                  %bbhMatrix = $sprout->BBHMatrix($givenGenomeID, $cutoff, @allGenomes);                      $bbhMatrix = $sprout->BBHMatrix($givenGenomeID, $cutoff, @allGenomes);
239              } else {              } else {
240                  # Here we are using similarities, which are much more complicated.                  # Here we are using similarities, which are much more complicated.
241                  $self->PrintLine("Requesting similarities.<br />");                  $self->PrintLine("Requesting similarities.<br />");
# Line 248  Line 251 
251                      my $simCount = scalar @{$simList};                      my $simCount = scalar @{$simList};
252                      $self->PrintLine("Raw similarity count: $simCount.  ");                      $self->PrintLine("Raw similarity count: $simCount.  ");
253                      # Create the matrix hash for this feature.                      # Create the matrix hash for this feature.
254                      $bbhMatrix{$fid} = {};                          $bbhMatrix->{$fid} = {};
255                      # Now we need to filter out the similarities that don't land on the target genome.                      # Now we need to filter out the similarities that don't land on the target genome.
256                      $simCount = 0;                      $simCount = 0;
257                      for my $sim (@{$simList}) {                      for my $sim (@{$simList}) {
# Line 256  Line 259 
259                          my $genomeID2 = $sprout->GenomeOf($sim->id2);                          my $genomeID2 = $sprout->GenomeOf($sim->id2);
260                          if ($keepGenomes{$genomeID2}) {                          if ($keepGenomes{$genomeID2}) {
261                              # Here we're keeping the similarity, so we put it in this feature's hash.                              # Here we're keeping the similarity, so we put it in this feature's hash.
262                              $bbhMatrix{$fid}->{$sim->id2} = $sim->psc;                                  $bbhMatrix->{$fid}->{$sim->id2} = $sim->psc;
263                              $simCount++;                              $simCount++;
264                          }                          }
265                      }                      }
# Line 291  Line 294 
294                      $self->PrintLine("Checking feature $fid.<br />");                      $self->PrintLine("Checking feature $fid.<br />");
295                      # Get its list of matching genes. The list is actually a hash mapping each matched gene to its                      # Get its list of matching genes. The list is actually a hash mapping each matched gene to its
296                      # score. All we care about, however, are the matches themselves.                      # score. All we care about, however, are the matches themselves.
297                      my $bbhList = $bbhMatrix{$fid};                          my $bbhList = $bbhMatrix->{$fid};
298                      # We next wish to loop through the BBH IDs, counting how many are in each of the                      # We next wish to loop through the BBH IDs, counting how many are in each of the
299                      # sets. If a genome occurs twice, we only want to count the first occurrence, so                      # sets. If a genome occurs twice, we only want to count the first occurrence, so
300                      # we have a hash of genomes we've already seen. The hash will map each gene ID                      # we have a hash of genomes we've already seen. The hash will map each gene ID
# Line 393  Line 396 
396              $putTimer += time() - $saveTime;              $putTimer += time() - $saveTime;
397          }          }
398      }      }
399        }
400      # Trace the timers.      # Trace the timers.
401      Trace("Time spent: Put = $putTimer, Query = $queryTimer, BBH = $bbhTimer.") if T(3);      Trace("Time spent: Put = $putTimer, Query = $queryTimer, BBH = $bbhTimer.") if T(3);
402      # Return the result count.      # Return the result count.

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.21

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3