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

Diff of /Sprout/Sprout.pm

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

revision 1.61, Wed Jun 14 20:15:48 2006 UTC revision 1.63, Sun Jun 18 07:03:00 2006 UTC
# Line 793  Line 793 
793      return @retVal;      return @retVal;
794  }  }
795    
796    =head3 GenomeLength
797    
798    C<< my $length = $sprout->GenomeLength($genomeID); >>
799    
800    Return the length of the specified genome in base pairs.
801    
802    =over 4
803    
804    =item genomeID
805    
806    ID of the genome whose base pair count is desired.
807    
808    =item RETURN
809    
810    Returns the number of base pairs in all the contigs of the specified
811    genome.
812    
813    =back
814    
815    =cut
816    
817    sub GenomeLength {
818        # Get the parameters.
819        my ($self, $genomeID) = @_;
820        # Declare the return variable.
821        my $retVal = 0;
822        # Get the genome's contig sequence lengths.
823        my @lens = $self->GetFlat(['HasContig', 'IsMadeUpOf'], 'HasContig(from-link) = ?',
824                           [$genomeID], 'IsMadeUpOf(len)');
825        # Sum the lengths.
826        map { $retVal += $_ } @lens;
827        # Return the result.
828        return $retVal;
829    }
830    
831    =head3 FeatureCount
832    
833    C<< my $count = $sprout->FeatureCount($genomeID, $type); >>
834    
835    Return the number of features of the specified type in the specified genome.
836    
837    =over 4
838    
839    =genomeID
840    
841    ID of the genome whose feature count is desired.
842    
843    =item type
844    
845    Type of feature to count (eg. C<peg>, C<rna>, etc.).
846    
847    =item RETURN
848    
849    Returns the number of features of the specified type for the specified genome.
850    
851    =back
852    
853    =cut
854    
855    sub FeatureCount {
856        # Get the parameters.
857        my ($self, $genomeID, $type) = @_;
858        # Compute the count.
859        my $retVal = $self->GetCount(['HasFeature', 'Feature'],
860                                    "HasFeature(from-link) = ? AND Feature(type) = ?",
861                                    [$genomeID, $type]);
862        # Return the result.
863        return $retVal;
864    }
865    
866    =head3 GenomeAssignments
867    
868    C<< my $fidHash = $sprout->GenomeAssignments($genomeID); >>
869    
870    Return a list of a genome's assigned features. The return hash will contain each
871    assigned feature of the genome mapped to the text of its most recent functional
872    assignment.
873    
874    =over 4
875    
876    =item genomeID
877    
878    ID of the genome whose functional assignments are desired.
879    
880    =item RETURN
881    
882    Returns a reference to a hash which maps each feature to its most recent
883    functional assignment.
884    
885    =back
886    
887    =cut
888    
889    sub GenomeAssignments {
890        # Get the parameters.
891        my ($self, $genomeID) = @_;
892        # Declare the return variable.
893        my $retVal = {};
894        # Query the genome's features and annotations. We'll put the oldest annotations
895        # first so that the last assignment to go into the hash will be the correct one.
896        my $query = $self->Get(['HasFeature', 'IsTargetOfAnnotation', 'Annotation'],
897                               "HasFeature(from-link) = ? ORDER BY Annotation(time)",
898                               [$genomeID]);
899        # Loop through the annotations.
900        while (my $data = $query->Fetch) {
901            # Get the feature ID and annotation text.
902            my ($fid, $annotation) = $data->Values(['HasFeature(from-link)',
903                                                    'Annotation(text)']);
904            # Check to see if this is an assignment. Note that the user really
905            # doesn't matter to us, other than we use it to determine whether or
906            # not this is an assignment.
907            my ($user, $assignment) = $self->_ParseAssignment('fig', $annotation);
908            if ($user) {
909                # Here it's an assignment. We put it in the return hash, overwriting
910                # any older assignment that might be present.
911                $retVal->{$fid} = $assignment;
912            }
913        }
914        # Return the result.
915        return $retVal;
916    }
917    
918  =head3 ContigLength  =head3 ContigLength
919    
920  C<< my $length = $sprout->ContigLength($contigID); >>  C<< my $length = $sprout->ContigLength($contigID); >>

Legend:
Removed from v.1.61  
changed lines
  Added in v.1.63

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3