[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.16, Mon Jul 16 20:04:51 2007 UTC revision 1.20, Mon Jan 19 21:56:19 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 67  Line 67 
67    
68  =head3 Form  =head3 Form
69    
70  C<< my $html = $shelp->Form(); >>      my $html = $shelp->Form();
71    
72  Generate the HTML for a form to request a new search.  Generate the HTML for a form to request a new search.
73    
# 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') .
119                                    SearchHelper::Hint("When two sets of genomees are specified, check this " .                                    SearchHelper::Hint("SigGenes",
120                                                         "When two sets of genomes are specified, check this " .
121                                                       "box to use a statistical algorithm designed " .                                                       "box to use a statistical algorithm designed " .
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') .
129                                    SearchHelper::Hint("Normally, Bidirectional Best Hits are used to " .                                    SearchHelper::Hint("SigGenes",
130                                                         "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("Check this button to display the genes matching " .                                    SearchHelper::Hint("SigGenes",
139                                                         "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 154  Line 157 
157    
158  =head3 Find  =head3 Find
159    
160  C<< my $resultCount = $shelp->Find(); >>      my $resultCount = $shelp->Find();
161    
162  Conduct a search based on the current CGI query parameters. The search results will  Conduct a search based on the current CGI query parameters. The search results will
163  be written to the session cache file and the number of results will be  be written to the session cache file and the number of results will be
# Line 225  Line 228 
228              # Get the peg matrix.              # Get the peg matrix.
229              Trace("Requesting matrix.") if T(3);              Trace("Requesting matrix.") if T(3);
230              $saveTime = time();              $saveTime = time();
231              my %bbhMatrix;              my $bbhMatrix;
232              if (! $cgi->param('useSims')) {              if (! $cgi->param('useSims')) {
233                  # 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.
234                  $self->PrintLine("Requesting bidirectional best hits.  ");                  $self->PrintLine("Requesting bidirectional best hits.  ");
235                  %bbhMatrix = $sprout->BBHMatrix($givenGenomeID, $cutoff, @allGenomes);                  $bbhMatrix = $sprout->BBHMatrix($givenGenomeID, $cutoff, @allGenomes);
236              } else {              } else {
237                  # Here we are using similarities, which are much more complicated.                  # Here we are using similarities, which are much more complicated.
238                  $self->PrintLine("Requesting similarities.<br />");                  $self->PrintLine("Requesting similarities.<br />");
# Line 245  Line 248 
248                      my $simCount = scalar @{$simList};                      my $simCount = scalar @{$simList};
249                      $self->PrintLine("Raw similarity count: $simCount.  ");                      $self->PrintLine("Raw similarity count: $simCount.  ");
250                      # Create the matrix hash for this feature.                      # Create the matrix hash for this feature.
251                      $bbhMatrix{$fid} = {};                      $bbhMatrix->{$fid} = {};
252                      # 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.
253                      $simCount = 0;                      $simCount = 0;
254                      for my $sim (@{$simList}) {                      for my $sim (@{$simList}) {
# Line 253  Line 256 
256                          my $genomeID2 = $sprout->GenomeOf($sim->id2);                          my $genomeID2 = $sprout->GenomeOf($sim->id2);
257                          if ($keepGenomes{$genomeID2}) {                          if ($keepGenomes{$genomeID2}) {
258                              # 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.
259                              $bbhMatrix{$fid}->{$sim->id2} = $sim->psc;                              $bbhMatrix->{$fid}->{$sim->id2} = $sim->psc;
260                              $simCount++;                              $simCount++;
261                          }                          }
262                      }                      }
# Line 288  Line 291 
291                      $self->PrintLine("Checking feature $fid.<br />");                      $self->PrintLine("Checking feature $fid.<br />");
292                      # 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
293                      # score. All we care about, however, are the matches themselves.                      # score. All we care about, however, are the matches themselves.
294                      my $bbhList = $bbhMatrix{$fid};                      my $bbhList = $bbhMatrix->{$fid};
295                      # 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
296                      # 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
297                      # 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 398  Line 401 
401    
402  =head3 Description  =head3 Description
403    
404  C<< my $htmlText = $shelp->Description(); >>      my $htmlText = $shelp->Description();
405    
406  Return a description of this search. The description is used for the table of contents  Return a description of this search. The description is used for the table of contents
407  on the main search tools page. It may contain HTML, but it should be character-level,  on the main search tools page. It may contain HTML, but it should be character-level,
# Line 415  Line 418 
418    
419  =head3 SearchTitle  =head3 SearchTitle
420    
421  C<< my $titleHtml = $shelp->SearchTitle(); >>      my $titleHtml = $shelp->SearchTitle();
422    
423  Return the display title for this search. The display title appears above the search results.  Return the display title for this search. The display title appears above the search results.
424  If no result is returned, no title will be displayed. The result should be an html string  If no result is returned, no title will be displayed. The result should be an html string
# Line 439  Line 442 
442    
443  =head3 IsCommon  =head3 IsCommon
444    
445  C<< my $score = SHSigGenes::IsCommon($count, $size, $commonality); >>      my $score = SHSigGenes::IsCommon($count, $size, $commonality);
446    
447  Return the match score if a specified count indicates a gene is common in a specified set  Return the match score if a specified count indicates a gene is common in a specified set
448  and 0 otherwise. Commonality is computed by dividing the count by the size of the set and  and 0 otherwise. Commonality is computed by dividing the count by the size of the set and

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.20

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3