[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.4, Wed Oct 4 16:03:55 2006 UTC revision 1.9, Sat Dec 2 09:46:01 2006 UTC
# Line 61  Line 61 
61    
62  =head3 Form  =head3 Form
63    
64  C<< my $html = $shelp->Include(); >>  C<< my $html = $shelp->Form(); >>
65    
66  Generate the HTML for a form to request a new search.  Generate the HTML for a form to request a new search.
67    
# Line 80  Line 80 
80      # there is the selector for the given genome, the commonality and cutoff values,      # there is the selector for the given genome, the commonality and cutoff values,
81      # and the submit button. Our first task, then, is to get the genome selection      # and the submit button. Our first task, then, is to get the genome selection
82      # menus.      # menus.
83      my $givenMenu   = $self->NmpdrGenomeMenu('given', 0, [$cgi->param('genome')]);      my $givenMenu   = $self->NmpdrGenomeMenu('given', 0, [$cgi->param('given')]);
84      my $targetMenu  = $self->NmpdrGenomeMenu('target', 'multiple', [$cgi->param('target')], 10, 'exclusion');      my $targetMenu  = $self->NmpdrGenomeMenu('target', 'multiple', [$cgi->param('target')], 10, 'exclusion');
85      my $excludeMenu = $self->NmpdrGenomeMenu('exclusion', 'multiple', [$cgi->param('exclusion')], 10, 'target');      my $excludeMenu = $self->NmpdrGenomeMenu('exclusion', 'multiple', [$cgi->param('exclusion')], 10, 'target');
86      # Get the default values to use for the commonality and cutoff controls.      # Get the default values to use for the commonality and cutoff controls.
87      my $commonality = $cgi->param('commonality') || "0.8";      my $commonality = $cgi->param('commonality') || "0.8";
88      my $cutoff = $cgi->param('cutoff') || "1e-10";      my $cutoff = $cgi->param('cutoff') || "1e-10";
89      # Now we build the table rows. The top contains the two numeric parameters and      my $statistical = $cgi->param('statistical') || 1;
90      # the submit button.      # Now we build the table rows.
91      my @rows = ();      my @rows = ();
92        # First we have the given genome.
93        push @rows, $cgi->Tr($cgi->td({valign => "top"}, "Reference Genome"),
94                             $cgi->td({colspan => 2}, $givenMenu));
95        # Now show the target and exclusion menus.
96        push @rows, $cgi->Tr($cgi->td({valign => "top"}, "Inclusion Genomes (Set 1)"),
97                             $cgi->td({colspan => 2}, $targetMenu));
98        push @rows, $cgi->Tr($cgi->td({valign => "top"}, "Exclusion Genomes (Set 2)"),
99                             $cgi->td({colspan => 2}, $excludeMenu));
100        # Next, the numeric parameters.
101      push @rows, $cgi->Tr($cgi->td("Commonality"),      push @rows, $cgi->Tr($cgi->td("Commonality"),
102                           $cgi->td($cgi->textfield(-name => 'commonality',                           $cgi->td($cgi->textfield(-name => 'commonality',
103                                                    -value => $commonality,                                                    -value => $commonality,
104                                                    -size => 5)));                                                    -size => 5))),
105                    $cgi->Tr($cgi->td(), $cgi->td(
106                                      $cgi->checkbox(-name => 'statistical',
107                                                     -checked => $statistical,
108                                                     -value => 1,
109                                                     -label => 'Use Statistical Algorithm')));
110      push @rows, $cgi->Tr($cgi->td("Cutoff"),      push @rows, $cgi->Tr($cgi->td("Cutoff"),
111                           $cgi->td($cgi->textfield(-name => 'cutoff',                           $cgi->td($cgi->textfield(-name => 'cutoff',
112                                                    -value => $cutoff,                                                    -value => $cutoff,
113                                                    -size => 5)));                                                    -size => 5)));
114      push @rows, $self->SubmitRow();      # Next, the feature filter rows.
     # The next rows have the given genome and a feature filter.  
     push @rows, $cgi->Tr($cgi->td({valign => "top"}, "Given Genome"),  
                          $cgi->td({colspan => 2}, $givenMenu));  
115      push @rows, $self->FeatureFilterRows();      push @rows, $self->FeatureFilterRows();
116      # Now show the target and exclusion menus.      # Finally, the submit button.
117      push @rows, $cgi->Tr($cgi->td({valign => "top"}, "Target Genomes (Set 1)"),      push @rows, $self->SubmitRow();
                          $cgi->td({colspan => 2}, $targetMenu));  
     push @rows, $cgi->Tr($cgi->td({valign => "top"}, "Exclusion Genomes (Set 2)"),  
                          $cgi->td({colspan => 2}, $excludeMenu));  
118      # Create the table.      # Create the table.
119      $retVal .= $self->MakeTable(\@rows);      $retVal .= $self->MakeTable(\@rows);
120      # Close the form.      # Close the form.
# Line 158  Line 166 
166              # Insure the given genome is in the target set.              # Insure the given genome is in the target set.
167              $targetGenomes{$givenGenomeID} = 1              $targetGenomes{$givenGenomeID} = 1
168          }          }
169            # Find out if we want to use a statistical analysis.
170            my $statistical = $cgi->param('statistical') || 0;
171          # Denote we have not yet found any genomes.          # Denote we have not yet found any genomes.
172          $retVal = 0;          $retVal = 0;
173          # Create a feature query object to loop through the chosen features of the given          # Create a feature query object to loop through the chosen features of the given
# Line 170  Line 180 
180          while (my $record = $fquery->Fetch()) {          while (my $record = $fquery->Fetch()) {
181              # Get the feature's ID.              # Get the feature's ID.
182              my $fid = $fquery->FID();              my $fid = $fquery->FID();
             Trace("Processing feature $fid.") if T(3);  
183              # Request its list of BBHs. The list is actually a hash mapping each BBH to its              # Request its list of BBHs. The list is actually a hash mapping each BBH to its
184              # score. All we care about, however, are the BBHs themselves.              # score. All we care about, however, are the BBHs themselves.
185              my %bbhList = $sprout->LowBBHs($fid, $cutoff);              my %bbhList = $sprout->LowBBHs($fid, $cutoff);
# Line 195  Line 204 
204                      $alreadySeen{$genomeID} = 1;                      $alreadySeen{$genomeID} = 1;
205                  }                  }
206              }              }
207                # Create a variable to indicate whether or not we want to keep this feature.
208                my $okFlag;
209                # We need to see if we're using statistics or not. This only matters
210                # for a two-set situation.
211                if ($statistical && $exclusionSetSize > 0) {
212                    # This looks like it has something to do with variance computations,
213                    # but I'm not sure.
214                    my $targetNotCount = $targetSetSize - $targetCount;
215                    my $targetSquare = $targetCount * $targetCount + $targetNotCount * $targetNotCount;
216                    my $exclusionNotCount = $exclusionSetSize - $exclusionCount;
217                    my $exclusionSquare = $exclusionCount * $exclusionCount + $exclusionNotCount * $exclusionNotCount;
218                    my $mixed = $targetCount * $exclusionCount + $targetNotCount * $exclusionNotCount;
219                    my $inD = 1 - (($exclusionSetSize * $mixed) / ($targetSetSize * $exclusionSquare));
220                    my $outD = 1 - (($targetSetSize * $mixed) / ($exclusionSetSize * $targetSquare));
221                    # If the two differentials are greater than one, we keep this feature.
222                    $okFlag = ($inD + $outD > 1);
223                } else {
224              # Check to see if we're common in set 1 and not in set 2.              # Check to see if we're common in set 1 and not in set 2.
225              if (IsCommon($targetCount, $targetSetSize, $commonality) &&              if (IsCommon($targetCount, $targetSetSize, $commonality) &&
226                  ! IsCommon($exclusionCount, $exclusionSetSize, $commonality)) {                  ! IsCommon($exclusionCount, $exclusionSetSize, $commonality)) {
227                  # We satisfy the criterion, so we put this feature to the output.                  # We satisfy the criterion, so we put this feature to the output.
228                        $okFlag = 1;
229                    }
230                }
231                if ($okFlag) {
232                    # Put this feature to the output.
233                  $self->PutFeature($fquery);                  $self->PutFeature($fquery);
234                  # Increase the result count.                  # Increase the result count.
235                  $retVal++;                  $retVal++;
236              }              }
237          }          }
238            # Close the session file.
239            $self->CloseSession();
240      }      }
241      # Return the result count.      # Return the result count.
242      return $retVal;      return $retVal;
# Line 223  Line 256 
256      # Get the parameters.      # Get the parameters.
257      my ($self) = @_;      my ($self) = @_;
258      # Return the result.      # Return the result.
259      return "Search for features that are common to a group of organisms or that discriminate between two groups of organisms.";      return "Search for genes that are common to a group of organisms or that discriminate between two groups of organisms.";
260  }  }
261    
262  =head2 Internal Utilities  =head2 Internal Utilities

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.9

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3