NAME

Bio::Seq - Sequence object, with features

SYNOPSIS

$seqio  = Bio::SeqIO->new ( '-format' => 'Fasta' , -file => 'myfile.fasta');
$seqobj = $seqio->next_seq();

# features must implement Bio::SeqFeatureI

@features = $seqobj->top_SeqFeatures(); # just top level
@features = $seqobj->all_SeqFeatures(); # descend into sub features

$seq      = $seqobj->seq(); # actual sequence as a string
$seqstr   = $seqobj->subseq(10,50);    
$ann      = $seqobj->annotation(); # annotation object

DESCRIPTION

A Seq object is a sequence with sequence features placed on them. The Seq object contains a PrimarySeq object for the actual sequence and also implements its interface.

In bioperl we have 3 main players that people are going to use

Bio::PrimarySeq - just the sequence and its names, nothing else.
Bio::SeqFeature - a location on a sequence, potentially with a sequence.
                  and annotation
Bio::Seq        - A sequence and a collection of seqfeatures (an aggregate) with
                  its own annotation.

Although bioperl is not tied to file formats heavily, these distrinctions do map to file formats sensibly and for some bioinformaticians this might help you:

Bio::PrimarySeq - Fasta file of a sequence
Bio::SeqFeature - A single entry in an EMBL/GenBank/DDBJ feature table
Bio::Seq        - A single EMBL/GenBank/DDBJ entry

By having this split we avoid alot of nasty ciricular references (seqfeatures can hold a reference to a sequence without the sequence holding a reference to the seqfeature).

Ian Korf really helped in the design of the Seq and SeqFeature system.

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.

vsns-bcd-perl@lists.uni-bielefeld.de          - General discussion
vsns-bcd-perl-guts@lists.uni-bielefeld.de     - Technically-oriented discussion
http://bio.perl.org/MailList.html             - 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 - Ewan Birney, inspired by Ian Korf objects

Email birney@sanger.ac.uk

Describe contact details here

APPENDIX

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

PrimarySeq interface

The primaryseq interface is the basic sequence getting and setting methods found on all sequences.

These methods implement the PrimarySeq interface by delegating to the primary_seq inside the object. This means that you can use a Seq object wherever there is a PrimarySeq, and of course, you are free to use these functions anyway.

seq

Title   : seq
Usage   : $string    = $obj->seq()
Function: Returns the sequence as a string of letters. The
          case of the letters is left up to the implementer.
          Suggested cases are upper case for proteins and lower case for
          DNA sequence (IUPAC standard),
          but implementations are suggested to keep an open mind about
          case (some users... want mixed case!)
Returns : A scalar

subseq

Title   : subseq
Usage   : $substring = $obj->subseq(10,40);
Function: returns the subseq from start to end, where the first base
          is 1 and the number is inclusive, ie 1-2 are the first two
          bases of the sequence

          Start cannot be larger than end but can be equal

Returns : a string
Args    :

display_id

Title   : display_id
Usage   : $id_string = $obj->display_id();
Function: returns the display id, aka the common name of the Sequence object.

          The semantics of this is that it is the most likely string
          to be used as an identifier of the sequence, and likely to
          have "human" readability.  The id is equivalent to the ID
          field of the GenBank/EMBL databanks and the id field of the
          Swissprot/sptrembl database. In fasta format, the >(\S+) is
          presumed to be the id, though some people overload the id
          to embed other information. Bioperl does not use any
          embedded information in the ID field, and people are
          encouraged to use other mechanisms (accession field for
          example, or extending the sequence object) to solve this.

          Notice that $seq->id() maps to this function, mainly for 
          legacy/convience issues
Returns : A string
Args    : None

accession_number

Title   : accession_number
Usage   : $unique_biological_key = $obj->accession_number;
Function: Returns the unique biological id for a sequence, commonly
          called the accession_number. For sequences from established
          databases, the implementors should try to use the correct
          accession number. Notice that primary_id() provides the
          unique id for the implemetation, allowing multiple objects
          to have the same accession number in a particular implementation.

          For sequences with no accession number, this method should return
          "unknown".
Returns : A string
Args    : None

desc

Title   : desc
Usage   : $seqobj->desc()
Function: Sets/Gets the description of the sequnce
Example :
Returns : 
Args    :

primary_id

Title   : primary_id
Usage   : $unique_implementation_key = $obj->primary_id;
Function: Returns the unique id for this object in this
          implementation. This allows implementations to manage
          their own object ids in a way the implementaiton can control
          clients can expect one id to map to one object.

          For sequences with no natural id, this method should return
          a stringified memory location.

          Also notice that this method is B<not> delegated to the
          internal PrimarySeq object
Returns : A string
Args    : None

can_call_new

 Title   : can_call_new
 Usage   : if( $obj->can_call_new ) {
             $newobj = $obj->new( %param );
	 }
 Function: can_call_new returns 1 or 0 depending
           on whether an implementation allows new
           constructor to be called. If a new constructor
           is allowed, then it should take the followed hashed
           constructor list.

           $myobject->new( -seq => $sequence_as_string,
			   -display_id  => $id
			   -accession_number => $accession
			   -moltype => 'dna',
			   );
 Example :
 Returns : 1 or 0
 Args    :

moltype

Title   : moltype
Usage   : if( $obj->moltype eq 'dna' ) { /Do Something/ }
Function: Returns the type of sequence being one of 
          'dna', 'rna' or 'protein'. This is case sensitive.

          This is not called <type> because this would cause
          upgrade problems from the 0.5 and earlier Seq objects.
          
Returns : a string either 'dna','rna','protein'. NB - the object must
          make a call of the type - if there is no type specified it
          has to guess.
Args    : none

Methods provided in the Bio::PrimarySeqI interface

These methods are inherieted from the PrimarySeq interface and work as one expects, building new Bio::Seq objects or other information as expected.

Sequence Features are not transfered to the new objects. This is possibly a mistake. Anyone who feels the urge in dealing with this is welcome to give it a go.

revcom

Title   : revcom
Usage   : $rev = $seq->revcom()
Function: Produces a new Bio::Seq object which
          is the reversed complement of the sequence. For protein
          sequences this throws an exception of "Sequence is a protein. Cannot revcom"

          The id is the same id as the orginal sequence, and the accession number
          is also indentical. If someone wants to track that this sequence has be
          reversed, it needs to define its own extensions

          To do an inplace edit of an object you can go:
  
          $seq = $seq->revcom();

          This of course, causes Perl to handle the garbage collection of the old
          object, but it is roughly speaking as efficient as an inplace edit.

Returns : A new (fresh) Bio::Seq object
Args    : none

trunc

Title   : trunc
Usage   : $subseq = $myseq->trunc(10,100);
Function: Provides a truncation of a sequence,
          
Example :
Returns : a fresh Bio::Seq object
Args    :

id

Title   : id
Usage   : $id = $seq->id()
Function:
Example :
Returns : 
Args    :

length

Title   : length
Usage   : $len = $seq->length()
Function:
Example :
Returns : 
Args    :

Methods for Backward Compatibility

These methods are here for backward compatibility with the old, 0.5 Seq objects. They all throw warnings that someone is using a deprecated method, and may eventually be removed completely from this object. However, they are important to ease the transition from the old system.

str

Title   : str
Usage   :
Function:
Example :
Returns : 
Args    :

ary

Title   : ary
Usage   :
Function:
Example :
Returns : 
Args    :

getseq

Title   : getseq
Usage   :
Function:
Example :
Returns : 
Args    :

type

Title   : type
Usage   :
Function:
Example :
Returns :
Args    :

Seq only methods

These methods are specific to the Bio::Seq object, and not found on the Bio::PrimarySeq object

primary_seq

Title   : seq
Usage   : $obj->primary_seq($newval)
Function: 
Example : 
Returns : value of primary_seq
Args    : newvalue (optional)

annotation

Title   : annotation
Usage   : $obj->annotation($seq_obj)
Function: 
Example : 
Returns : value of annotation
Args    : newvalue (optional)

add_SeqFeature

Title   : add_SeqFeature
Usage   : $annseq->add_SeqFeature($feat);
Function: Adds t
Example :
Returns : 
Args    :

top_SeqFeatures

Title   : top_SeqFeatures
Usage   :
Function:
Example :
Returns : 
Args    :

all_SeqFeatures

Title   : all_SeqFeatures
Usage   :
Function:
Example :
Returns : 
Args    :

fetch_SeqFeatures

Title   : fetch_SeqFeatures
Usage   :
Function:
Example :
Returns : 
Args    :

species

Title   : species
Usage   : 
Function: Gets or sets the species
Example : $species = $self->species();
Returns : Bio::Species object
Args    : Bio::Species object or none;

sub_species

Title   : sub_species
Usage   : 
Function: Gets or sets the sub_species
Example : $sub_species = $self->sub_species();
Returns : Bio::Species object
Args    : Bio::Species object or none;

EMBL/GenBank/DDBJ methods

These methods are here to support the EMBL/GenBank/DDBJ format. The problem is that these formats require a certain amount of additional information (eg, what division they are from), but to make bioperl slavishly involved with this is just a bad idea.

If you want to use these methods, please preface them with a $as->can('method-name'). If this fails, then do something sensible. This means that we do not have to think about being in lock-step with EMBL/GenBank/DDBJ but can still support all the information that is required.

division

Title   : division
Usage   : $obj->division($newval)
Function: 
Returns : value of division
Args    : newvalue (optional)

molecule

Title   : molecule
Usage   : $obj->molecule($newval)
Function: 
Returns : type of molecule (DNA, mRNA)
Args    : newvalue (optional)

add_date

Title   : add_date
Usage   : $self->add_domment($ref)
Function: adds a date
Example :
Returns : 
Args    :

each_date

Title   : each_date
Usage   : foreach $dt ( $self->each_date() )
Function: gets an array of dates
Example :
Returns : 
Args    :

accession

Title   : accession
Usage   : $obj->accession($newval)
Function: Whilst the underlying sequence object does not 
          have an accession, so we need one here. Wont stay
          when we do the reimplementation.
Example : 
Returns : value of accession
Args    : newvalue (optional)

add_secondary_accession

Title   : add_secondary_accession
Usage   : $self->add_domment($ref)
Function: adds a secondary_accession
Example :
Returns : 
Args    :

each_secondary_accession

Title   : each_secondary_accession
Usage   : foreach $dt ( $self->each_secondary_accession() )
Function: gets an array of secondary_accessions
Example :
Returns : 
Args    :

sv

Title   : sv
Usage   : $obj->sv($newval)
Function: 
Returns : value of sv
Args    : newvalue (optional)

keywords

Title   : keywords
Usage   : $obj->keywords($newval)
Function: 
Returns : value of keywords
Args    : newvalue (optional)