NAME

Bio::Tools::SeqStats - Object holding statistics for one particular sequence

SYNOPSIS

    # build a primary nucleic acid or protein sequence object somehow
    # then build a statistics object from the sequence object

        $seqobj = Bio::PrimarySeq->new(-seq=>'ACTGTGGCGTCAACTG', -moltype = 'dna', -id = 'test');
        $seq_stats  =  Bio::Tools::SeqStats->new($seqobj);

    # obtain a hash of counts of each type of monomer (ie amino or nucleic acid)
        $hash_ref = $seq_stats->count_monomers();  # eg for DNA sequence
        foreach $base ( sort keys $$hash_ref) {
            print "Number of bases of type ",$base "= ",%$hash_ref{$base}"\n";
        }
    # or obtain the count directly without creating a new statistics object
        $hash_ref = Bio::Tools::SeqStats->count_monomers($seqobj);
        foreach $base ( sort keys $$hash_ref) {
            print "Number of bases of type ",$base "= ",%$hash_ref{$base}"\n";
        }

    # obtain hash of counts of each type of codon in a nucleic acid sequence
        $hash_ref = $seq_stats-> count_codons();  # for nucleic acid sequence
    #  or
        $hash_ref = Bio::Tools::SeqStats->count_codons($seqobj);

    # Obtain the molecular weight of a sequence. Since the sequence may contain
    # ambiguous monomers, the molecular weight is returned as a (reference to) a
    # two element array containing greatest lower bound (GLB) and least upper bound
    # (LUB) of the molecular weight
        $weight = $seq_stats->get_mol_wt();
    #  or
        $weight = Bio::Tools::SeqStats->get_mol_wt($seqobj);
        print "Molecular weight of sequence ", $seqobj->id(), " is greater than ", $$weight[0], " and less than " , $$weight[1], "\n";

DESCRIPTION

Bio::Tools::SeqStats is a lightweight object for the calculation of simple statistical and numerical properties of a sequence. By "lightweight" I mean that only "primary" sequences are handled by the object. The calling script needs to create the appropriate primary sequence to be passed to SeqStats if statistics on a sequence feature are required. Similarly if a codon count is desired for a frame-shifted sequence and/or a negative strand sequence, the calling script needs to create that sequence and pass it to the SeqStats object.

SeqStats can be called in two distinct manners. If only a single computation is required on a given sequence object, the method can be called easily using the SeqStats object directly:

        $weight = Bio::SeqStats->get_mol_wt($seqobj);

Alternately, if several computations will be required on a given sequence object, an "instance" statistics object can be constructed and used for the method calls:

        $seq_stats  =  Bio::SeqStats->new($seqobj);
        $monomers = $seq_stats->count_monomers();
        $codons = $seq_stats->count_codons();
        $weight = $seq_stats->get_mol_wt();

As currently implemented the object can return the following values from a sequence: * The molecular weight of the sequence: get_mol_wt() * The number of each type of monomer present: count_monomers() * The number of each codon present in a nucleic acid sequence: count_codons()

Note that since sequences may contain ambiguous monomers (eg "M" meaning "A" or "C" in a nucleic acid sequence), the method get_mol_wt returns a two-element array containing the greatest lower bound and least upper bound of the molecule. (For a sequence with no ambiguous monomers, the two elements of the returned array will be equal.) The method count_codons() handles ambiguous bases by simply counting all ambiguous codons together and issuing a warning to that effect.

DEVELOPERS NOTES

Ewan moved it from Bio::SeqStats to Bio::Tools::SeqStats

STILL TO WRITE

FEEDBACK

Mailing Lists

User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of the Bioperl mailing lists. Your participation is much appreciated.

   bioperl-l@bioperl.org             - General discussion
   bioperl-guts-l@bioperl.org        - Automated bug and CVS messages
   http://bioperl.org/MailList.shtml - About the mailing lists

Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via email or the web:

  bioperl-bugs@bio.perl.org
  http://bio.perl.org/bioperl-bugs/

AUTHOR - Peter Schattner

Email peter@unix.sri.com

APPENDIX

The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _

count_monomers

 Title   : count_monomers
 Usage   : $rcount = $seq_stats->count_monomers(); or $rcount = $seq_stats->Bio::SeqStats->($seqobj);
 Function: Counts the number of each type of monomer (amino acid or base)
in the sequence.
 Example :
 Returns : Reference to a hash in which keys are letters of the genetic alphabet
 used and values are number of occurrences of the letter in the sequence.
 Args    : None or reference to sequence object

  Throws an exception if type of sequence is unknown (ie amino or nucleic)or if
unknown letter in alphabet. Ambiguous elements are allowed.

get_mol_wt

 Title   : get_mol_wt
 Usage   : $wt = $seqobj->get_mol_wt() or $wt = Bio::SeqStats->get_mol_wt($seqobj);
 Function: Calculate molecular weight of sequence
 Example :
 Returns : Reference to two element array containing lower and upper bounds of
molecule's molecular weight. If sequence contains no ambiguous elements, both entries
in array are equal to molecular weight of molecule.
 Args    : None or reference to sequence object

  Throws an exception if type of sequence is unknown (ie not amino or nucleic)or if
unknown letter in alphabet. Ambiguous elements are allowed.

count_codons

 Title   : count_codons
 Usage   : $rcount = $seqstats->count_codons (); or $rcount = Bio::SeqStats->count_codons($seqobj);
 Function: Counts the number of each type of codons in a given frame for a dna or
 rna sequence.
 Example :
 Returns : Reference to a hash in which keys are codons of the genetic alphabet
 used and values are number of occurrences of the codons in the sequence. All codons
 with "ambiguous" bases are counted together.
 Args    : None or reference to sequence object

  Throws an exception if type of sequence is unknown or protein.

_is_alphabet_strict

 Title   :   _is_alphabet_strict
 Usage   :
 Function:  internal function to determine whether there are any ambiguous elements
in the current sequence
 Example :
 Returns : 1 if strict alphabet is being used, 0 if ambiguous elements are present
 Args    :

  Throws an exception if type of sequence is unknown (ie amino or nucleic) or if
unknown letter in alphabet. Ambiguous monomers are allowed.