NAME
Bio::PrimarySeqI [Developers] - Interface definition for a Bio::PrimarySeq
SYNOPSIS
# Bio::PrimarySeqI is the interface class for sequences.
# If you are a newcomer to bioperl, you should
# start with Bio::Seq documentation. This
# documentation is mainly for developers using
# Bioperl.
# to test this is a seq object
$obj->isa("Bio::PrimarySeqI") ||
$obj->throw("$obj does not implement the Bio::PrimarySeqI interface");
# accessors
$string = $obj->seq();
$substring = $obj->subseq(12,50);
$display = $obj->display_id(); # for human display
$id = $obj->primary_id(); # unique id for this object,
# implementation defined
$unique_key= $obj->accession_number();
# unique biological id
# object manipulation
eval {
$rev = $obj->revcom();
};
if( $@ ) {
$obj->throw("Could not reverse complement. ".
"Probably not DNA. Actual exception\n$@\n");
}
$trunc = $obj->trunc(12,50);
# $rev and $trunc are Bio::PrimarySeqI compliant objects
DESCRIPTION
This object defines an abstract interface to basic sequence information - for most users of the package the documentation (and methods) in this class are not useful - this is a developers only class which defines what methods have to be implmented by other Perl objects to comply to the Bio::PrimarySeqI interface. Go "perldoc Bio::Seq" or "man Bio::Seq" for more information on the main class for sequences.
PrimarySeq is an object just for the sequence and its name(s), nothing more. Seq is the larger object complete with features. There is a pure perl implementation of this in Bio::PrimarySeq. If you just want to use Bio::PrimarySeq objects, then please read that module first. This module defines the interface, and is of more interest to people who want to wrap their own Perl Objects/RDBs/FileSystems etc in way that they "are" bioperl sequence objects, even though it is not using Perl to store the sequence etc.
This interface defines what bioperl consideres necessary to "be" a sequence, without providing an implementation of this. (An implementation is provided in Bio::PrimarySeq). If you want to provide a Bio::PrimarySeq 'compliant' object which in fact wraps another object/database/out-of-perl experience, then this is the correct thing to wrap, generally by providing a wrapper class which would inheriet from your object and this Bio::PrimarySeqI interface. The wrapper class then would have methods lists in the "Implementation Specific Functions" which would provide these methods for your object.
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
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://bugzilla.bioperl.org/
AUTHOR - Ewan Birney
Email birney@sanger.ac.uk
APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
Implementation Specific Functions
These functions are the ones that a specific implementation must define.
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
Status : Virtual
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 :
Status : Virtual
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
Status : Virtual
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
Status : Virtual
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 accession number, this method should
return a stringified memory location.
[Note this method name is likely to change in 1.3]
Returns : A string
Args : None
Status : Virtual
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
-alphabet => 'dna',
);
Example :
Returns : 1 or 0
Args :
alphabet
Title : alphabet
Usage : if( $obj->alphabet 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
Status : Virtual
Optional Implementation Functions
The following functions rely on the above functions. An implementing class does not need to provide these functions, as they will be provided by this class, but is free to override these functions.
All of revcom(), trunc(), and translate() create new sequence objects. They will call new() on the class of the sequence object instance passed as argument, unless can_call_new() returns FALSE. In the latter case a Bio::PrimarySeq object will be created. Implementors which really want to control how objects are created (eg, for object persistence over a database, or objects in a CORBA framework), they are encouraged to override these methods
revcom
Title : revcom
Usage : $rev = $seq->revcom()
Function: Produces a new Bio::PrimarySeqI implementing 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 original 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::PrimarySeqI object
Args : none
trunc
Title : trunc
Usage : $subseq = $myseq->trunc(10,100);
Function: Provides a truncation of a sequence,
Example :
Returns : a fresh Bio::PrimarySeqI implementing object
Args : Two integers denoting first and last base of the sub-sequence.
translate
Title : translate
Usage : $protein_seq_obj = $dna_seq_obj->translate
#if full CDS expected:
$protein_seq_obj = $cds_seq_obj->translate(undef,undef,undef,undef,1);
Function:
Provides the translation of the DNA sequence using full
IUPAC ambiguities in DNA/RNA and amino acid codes.
The full CDS translation is identical to EMBL/TREMBL
database translation. Note that the trailing terminator
character is removed before returning the translation
object.
Note: if you set $dna_seq_obj->verbose(1) you will get a
warning if the first codon is not a valid initiator.
Returns : A Bio::PrimarySeqI implementing object
Args : character for terminator (optional) defaults to '*'
character for unknown amino acid (optional) defaults to 'X'
frame (optional) valid values 0, 1, 2, defaults to 0
codon table id (optional) defaults to 1
complete coding sequence expected, defaults to 0 (false)
boolean, throw exception if not complete CDS (true) or defaults to
warning (false)
coding sequence expected to be complete at 5', defaults to false
coding sequence expected to be complete at 3', defaults to false
id
Title : id
Usage : $id = $seq->id()
Function: ID of the sequence. This should normally be (and actually is in
the implementation provided here) just a synonym for display_id().
Example :
Returns : A string.
Args :
length
Title : length
Usage : $len = $seq->length()
Function:
Example :
Returns : integer representing the length of the sequence.
Args :
desc
Title : desc
Usage : $seq->desc($newval);
$description = $seq->desc();
Function: Get/set description text for a seq object
Example :
Returns : value of desc
Args : newvalue (optional)
is_circular
Title : is_circular
Usage : if( $obj->is_circular) { /Do Something/ }
Function: Returns true if the molecule is circular
Returns : Boolean value
Args : none
Private functions
These are some private functions for the PrimarySeqI interface. You do not need to implement these functions
_attempt_to_load_Seq
Title : _attempt_to_load_Seq
Usage :
Function:
Example :
Returns :
Args :