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

Diff of /Sprout/Sapling.pm

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

revision 1.15, Tue Aug 4 16:53:18 2009 UTC revision 1.16, Tue Aug 11 19:36:46 2009 UTC
# Line 63  Line 63 
63    
64  Reference to a hash of tuning parameters.  Reference to a hash of tuning parameters.
65    
66    =item otuHash
67    
68    Reference to a hash that maps genome IDs to genome set names.
69    
70  =back  =back
71    
72  =head2 Configuration and Construction  =head2 Configuration and Construction
# Line 204  Line 208 
208      $retVal->{genomeHash} = undef;      $retVal->{genomeHash} = undef;
209      $retVal->{subHash} = undef;      $retVal->{subHash} = undef;
210      $retVal->{tuning} = undef;      $retVal->{tuning} = undef;
211        # Set up the hash of genome IDs to OTUs.
212        $retVal->{otuHash} = {};
213      # Return it.      # Return it.
214      return $retVal;      return $retVal;
215  }  }
216    
217  =head2 Public Methods  =head2 Public Methods
218    
219    =head3 OTU
220    
221        my $otu = $sap->OTU($genomeID);
222    
223    Return the name of the Organism Taxonomic Unit (GenomeSet) for the
224    specified genome ID. OTU information is cached in memory, so that once it
225    is known, it does not need to be re-fetched from the database.
226    
227    =over 4
228    
229    =item genomeID
230    
231    ID of a genome or feature. If a feature ID is specified, the genome ID will be
232    extracted from it.
233    
234    =item RETURN
235    
236    Returns the name of the genome set for the specified genome, or C<undef> if the
237    genome is not in the
238    
239    =back
240    
241    =cut
242    
243    sub OTU {
244        # Get the parameters.
245        my ($self, $genomeID) = @_;
246        # Get the OTU hash.
247        my $otuHash = $self->{otuHash};
248        # Compute the real genome ID.
249        my $realGenomeID = ($genomeID =~ /^fig\|(\d+\.\d+)/ ? $1 : $genomeID);
250        # Look it up in the hash.
251        my $retVal = $otuHash->{$realGenomeID};
252        # Was it found?
253        if (! defined $retVal) {
254            # No, get the OTU from the database.
255            ($retVal) = $self->GetFlat("IsCollectedInto", "IsCollectedInto(from-link) = ?",
256                                       [$realGenomeID], "to-link");
257            # Save it in the hash for future use.
258            $otuHash->{$realGenomeID} = $retVal;
259        }
260        # Return the result.
261        return $retVal;
262    }
263    
264    
265  =head3 ComputeDNA  =head3 ComputeDNA
266    
267      my $dna = $sap->ComputeDNA($location);      my $dna = $sap->ComputeDNA($location);

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3