NAME
Bio::PrimarySeqI - Interface definition for a Bio::PrimarySeq
SYNOPSIS
# Bio::PrimarySeqI is the interface class for sequences.# If you are a newcomer to bioperl, you might want to start with# Bio::Seq documentation.# Test if 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 manipulationeval {$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 implemented 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 considers 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 inherit 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.
[email protected] - General discussionhttp://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support
Please direct usage questions or support issues to the mailing list:
rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.
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 the web:
https://github.com/bioperl/bioperl-live/issues
AUTHOR - Ewan Birney
Email [email protected]
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 : seqUsage : $string = $obj->seq()Function: Returns the sequence as a string of letters. Thecase of the letters is left up to the implementer.Suggested cases are upper case for proteins and lower case forDNA sequence (IUPAC standard), but implementations are suggested tokeep an open mind about case (some users... want mixed case!)Returns : A scalarStatus : Virtual
subseq
Title : subseqUsage : $substring = $obj->subseq(10,40);Function: Returns the subseq from start to end, where the first baseis 1 and the number is inclusive, i.e. 1-2 are the first twobases of the sequence.Start cannot be larger than end but can be equal.Returns : A stringArgs :Status : Virtual
display_id
Title : display_idUsage : $id_string = $obj->display_id();Function: Returns the display id, also known as the common name of the Sequenceobject.The semantics of this is that it is the most likely stringto be used as an identifier of the sequence, and likely tohave "human" readability. The id is equivalent to the IDfield of the GenBank/EMBL databanks and the id field of theSwissprot/sptrembl database. In fasta format, the >(\S+) ispresumed to be the id, though some people overload the idto embed other information. Bioperl does not use anyembedded information in the ID field, and people areencouraged to use other mechanisms (accession field forexample, or extending the sequence object) to solve this.Notice that $seq->id() maps to this function, mainly forlegacy/convenience reasons.Returns : A stringArgs : NoneStatus : Virtual
accession_number
Title : accession_numberUsage : $unique_biological_key = $obj->accession_number;Function: Returns the unique biological id for a sequence, commonlycalled the accession_number. For sequences from establisheddatabases, the implementors should try to use the correctaccession number. Notice that primary_id() provides theunique id for the implementation, allowing multiple objectsto have the same accession number in a particular implementation.For sequences with no accession number, this method should return"unknown".Returns : A stringArgs : NoneStatus : Virtual
primary_id
Title : primary_idUsage : $unique_implementation_key = $obj->primary_id;Function: Returns the unique id for this object in thisimplementation. This allows implementations to manage theirown object ids in a way the implementation can controlclients can expect one id to map to one object.For sequences with no accession number, this method shouldreturn a stringified memory location.Returns : A stringArgs : NoneStatus : Virtual
can_call_new
Title : can_call_newUsage : if( $obj->can_call_new ) {$newobj = $obj->new( %param );}Function: Can_call_new returns 1 or 0 dependingon whether an implementation allows newconstructor to be called. If a new constructoris allowed, then it should take the followed hashedconstructor list.$myobject->new( -seq => $sequence_as_string,-display_id => $id-accession_number => $accession-alphabet => 'dna',);Returns : 1 or 0Args :
alphabet
Title : alphabetUsage : 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 causeupgrade problems from the 0.5 and earlier Seq objects.Returns : A string either 'dna','rna','protein'. NB - the object mustmake a call of the alphabet, if there is no alphabet specified ithas to guess.Args : NoneStatus : Virtual
moltype
Title : moltypeUsage : Deprecated. Use alphabet() instead.
Implementation-optional 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.
The revcom(), trunc(), and translate() methods 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 : revcomUsage : $rev = $seq->revcom()Function: Produces a new Bio::PrimarySeqI implementing object whichis the reversed complement of the sequence. For proteinsequences this throws an exception of "Sequence is aprotein. Cannot revcom".The id is the same id as the original sequence, and theaccession number is also identical. If someone wants totrack that this sequence has be reversed, it needs todefine 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 garbagecollection of the old object, but it is roughly speaking asefficient as an inplace edit.Returns : A new (fresh) Bio::PrimarySeqI objectArgs : None
trunc
Title : truncUsage : $subseq = $myseq->trunc(10,100);Function: Provides a truncation of a sequence.Returns : A fresh Bio::PrimarySeqI implementing object.Args : Two integers denoting first and last base of the sub-sequence.
translate
Title : translateUsage : $protein_seq_obj = $dna_seq_obj->translateOr if you expect a complete coding sequence (CDS) translation,with initiator at the beginning and terminator at the end:$protein_seq_obj = $cds_seq_obj->translate(-complete => 1);Or if you want translate() to find the first initiationcodon and return the corresponding protein:$protein_seq_obj = $cds_seq_obj->translate(-orf => 1);Function: Provides the translation of the DNA sequence using fullIUPAC ambiguities in DNA/RNA and amino acid codes.The complete CDS translation is identical to EMBL/TREMBLdatabase translation. Note that the trailing terminatorcharacter is removed before returning the translated proteinobject.Note: if you set $dna_seq_obj->verbose(1) you will get awarning if the first codon is not a valid initiator.Returns : A Bio::PrimarySeqI implementing objectArgs : -terminatorcharacter for terminator, default '*'-unknowncharacter for unknown, default 'X'-framepositive integer frame shift (in bases), default 0-codontable_idinteger codon table id, default 1-completeboolean, if true, complete CDS is expected. default false-complete_codonsboolean, if true, codons which are incomplete are translated if asuitable amino acid is found. For instance, if the incompletecodon is 'GG', the completed codon is 'GGN', which is glycine(G). Defaults to 'false'; setting '-complete' also makes thistrue.-throwboolean, throw exception if ORF not complete, default false-orfif 'longest', find longest ORF. other true value, findfirst ORF. default 0-codontableoptional L<Bio::Tools::CodonTable> object to use fortranslation-startoptional three-character string to force as initiationcodon (e.g. 'atg'). If unset, start codons aredetermined by the CodonTable. Case insensitive.-offsetoptional positive integer offset for fuzzy locations.if set, must be either 1, 2, or 3
Notes
The -start argument only applies when -orf is set to 1. By default all initiation codons found in the given codon table are used but when "start" is set to some codon this codon will be used exclusively as the initiation codon. Note that the default codon table (NCBI "Standard") has 3 initiation codons!
By default translate() translates termination codons to the some character (default is *), both internal and trailing codons. Setting "-complete" to 1 tells translate() to remove the trailing character.
-offset is used for seqfeatures which contain the the \codon_start tag and can be set to 1, 2, or 3. This is the offset by which the sequence translation starts relative to the first base of the feature
For details on codon tables used by translate() see Bio::Tools::CodonTable.
Deprecated argument set (v. 1.5.1 and prior versions) where each argument is an element in an array:
1: character for terminator (optional), defaults to '*'.2: character for unknown amino acid (optional), defaults to 'X'.3: frame (optional), valid values are 0, 1, 2, defaults to 0.4: codon table id (optional), defaults to 1.5: complete coding sequence expected, defaults to 0 (false).6: boolean, throw exception if not complete coding sequence(true), defaults to warning (false)7: codontable, a custom Bio::Tools::CodonTable object (optional).
transcribe()
Title : transcribeUsage : $xseq = $seq->transcribeFunction: Convert base T to base UReturns : PrimarySeqI object of alphabet 'rna' orundef if $seq->alphabet ne 'dna'Args :
rev_transcribe()
Title : rev_transcribeUsage : $rtseq = $seq->rev_transcribeFunction: Convert base U to base TReturns : PrimarySeqI object of alphabet 'dna' orundef if $seq->alphabet ne 'rna'Args :
id
Title : idUsage : $id = $seq->id()Function: ID of the sequence. This should normally be (and actually is inthe implementation provided here) just a synonym for display_id().Returns : A string.Args :
length
Title : lengthUsage : $len = $seq->length()Function:Returns : Integer representing the length of the sequence.Args :
desc
Title : descUsage : $seq->desc($newval);$description = $seq->desc();Function: Get/set description text for a seq objectReturns : Value of descArgs : newvalue (optional)
is_circular
Title : is_circularUsage : if( $obj->is_circular) { # Do something }Function: Returns true if the molecule is circularReturns : Boolean valueArgs : none
Private functions
These are some private functions for the PrimarySeqI interface. You do not need to implement these functions
_find_orfs_nucleotide
Title : _find_orfs_nucleotideUsage :Function: Finds ORF starting at 1st initiation codon in nucleotide sequence.The ORF is not required to have a termination codon.Example :Returns : a list of string coordinates of ORF locations (0-based half-open),sorted descending by length (so that the longest is first)as: [ start, end, frame, length ], [ start, end, frame, length ], ...Args : Nucleotide sequence,CodonTable object,(optional) alternative initiation codon (e.g. 'ATA'),(optional) boolean that, if true, stops after finding thefirst available ORF
_attempt_to_load_Seq
Title : _attempt_to_load_SeqUsage :Function:Example :Returns :Args :