NAME
Bio::PrimarySeq - Bioperl lightweight sequence object
SYNOPSIS
# Bio::SeqIO for file reading, Bio::DB::GenBank for# database readinguse Bio::Seq;use Bio::SeqIO;use Bio::DB::GenBank;# make from memory$seqobj = Bio::PrimarySeq->new (-seq => 'ATGGGGTGGGCGGTGGGTGGTTTG',-id => 'GeneFragment-12',-accession_number => 'X78121',-alphabet => 'dna',-is_circular => 1,);print "Sequence ", $seqobj->id(), " with accession ",$seqobj->accession_number, "\n";# read from file$inputstream = Bio::SeqIO->new(-file => "myseq.fa",-format => 'Fasta',);$seqobj = $inputstream->next_seq();print "Sequence ", $seqobj->id(), " and desc ", $seqobj->desc, "\n";# to get out parts of the sequence.print "Sequence ", $seqobj->id(), " with accession ",$seqobj->accession_number, " and desc ", $seqobj->desc, "\n";$string = $seqobj->seq();$string2 = $seqobj->subseq(1,40);
DESCRIPTION
PrimarySeq is a lightweight sequence object, storing the sequence, its name, a computer-useful unique name, and other fundamental attributes. It does not contain sequence features or other information. To have a sequence with sequence features you should use the Seq object which uses this object.
Although new users will use Bio::PrimarySeq a lot, in general you will be using it from the Bio::Seq object. For more information on Bio::Seq see Bio::Seq. For interest you might like to know that Bio::Seq has-a Bio::PrimarySeq and forwards most of the function calls to do with sequence to it (the has-a relationship lets us get out of a otherwise nasty cyclical reference in Perl which would leak memory).
Sequence objects are defined by the Bio::PrimarySeqI interface, and this object is a pure Perl implementation of the interface. If that's gibberish to you, don't worry. The take home message is that this object is the bioperl default sequence object, but other people can use their own objects as sequences if they so wish. If you are interested in wrapping your own objects as compliant Bioperl sequence objects, then you should read the Bio::PrimarySeqI documentation
The documentation of this object is a merge of the Bio::PrimarySeq and Bio::PrimarySeqI documentation. This allows all the methods which you can call on sequence objects here.
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 _
new
Title : newUsage : $seqobj = Bio::PrimarySeq->new( -seq => 'ATGGGGGTGGTGGTACCCT',-id => 'human_id',-accession_number => 'AL000012',);Function: Returns a new primary seq object frombasic constructors, being a string for the sequenceand strings for id and accession_number.Note that you can provide an empty sequence string. However, inthis case you MUST specify the type of sequence you wish toinitialize by the parameter -alphabet. See alphabet() for possiblevalues.Returns : a new Bio::PrimarySeq objectArgs : -seq => sequence string-ref_to_seq => ... or reference to a sequence string-display_id => display id of the sequence (locus name)-accession_number => accession number-primary_id => primary id (Genbank id)-version => version number-namespace => the namespace for the accession-authority => the authority for the namespace-description => description text-desc => alias for description-alphabet => skip alphabet guess and set it to dna, rna or protein-id => alias for display id-is_circular => boolean to indicate that sequence is circular-direct => boolean to directly set sequences. The next time -seq,seq() or -ref_to_seq is use, the sequence will not bevalidated. Be careful with this...-nowarnonempty => boolean to avoid warning when sequence is empty
seq
Title : seqUsage : $string = $seqobj->seq();Function: Get or set the sequence as a string of letters. The case ofthe letters is left up to the implementer. Suggested cases areupper case for proteins and lower case for DNA sequence (IUPACstandard), but you should not rely on this. An error is thrown ifthe sequence contains invalid characters: see validate_seq().Returns : A scalarArgs : - Optional new sequence value (a string) to set- Optional alphabet (it is guessed by default)
validate_seq
Title : validate_seqUsage : if(! $seqobj->validate_seq($seq_str) ) {print "sequence $seq_str is not valid for an object ofalphabet ",$seqobj->alphabet, "\n";}Function: Test that the given sequence is valid, i.e. contains only validcharacters. The allowed characters are all letters (A-Z) and '-','.','*','?','=' and '~'. Spaces are not valid. Note that thisimplementation does not take alphabet() into account and that emptysequences are considered valid.Returns : 1 if the supplied sequence string is valid, 0 otherwise.Args : - Sequence string to be validated- Boolean to optionally throw an error if the sequence is invalid
subseq
Title : subseqUsage : $substring = $seqobj->subseq(10,40);$substring = $seqobj->subseq(10,40,'nogap');$substring = $seqobj->subseq(-start=>10, -end=>40, -replace_with=>'tga');$substring = $seqobj->subseq($location_obj);$substring = $seqobj->subseq($location_obj, -nogap => 1);Function: Return the subseq from start to end, where the first sequencecharacter has coordinate 1 number is inclusive, ie 1-2 are thefirst two characters of the sequence. The given start coordinatehas to be larger than the end, even if the sequence is circular.Returns : a stringArgs : integer for start positioninteger for end positionORBio::LocationI location for subseq (strand honored)Specify -NOGAP=>1 to return subseq with gap characters removedSpecify -REPLACE_WITH=>$new_subseq to replace the subseq returnedwith $new_subseq in the sequence object
length
Title : lengthUsage : $len = $seqobj->length();Function: Get the stored length of the sequence in number of symbols (basesor amino acids). In some circumstances, you can also set this attribute:1. For empty sequences, you can set the length to anything you want:my $seqobj = Bio::PrimarySeq->new( -length => 123 );my $len = $seqobj->len; # 1232. To save memory when using very long sequences, you can set thelength of the sequence to the length of the sequence (and nothingelse):my $seqobj = Bio::PrimarySeq->new( -seq => 'ACGT...' ); # 1 Mbp sequence# process $seqobj... then after you're done with it$seqobj->length($seqobj->length);$seqobj->seq(undef); # free memory!my $len = $seqobj->len; # 1 MbpNote that if you set seq() to a value other than undef at any time,the length attribute will be reset.Returns : integer representing the length of the sequence.Args : Optionally, the value on set
display_id
Title : display_id or display_nameUsage : $id_string = $seqobj->display_id();Function: Get or set the display id, aka the common name of the sequence object.The semantics of this is that it is the most likely string tobe used as an identifier of the sequence, and likely to have"human" readability. The id is equivalent to the ID field ofthe 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 id toembed other information. Bioperl does not use any embeddedinformation in the ID field, and people are encouraged to useother mechanisms (accession field for example, or extendingthe sequence object) to solve this.With the new Bio::DescribeableI interface, display_name aliasesto this method.Returns : A string for the display IDArgs : Optional string for the display ID to set
accession_number
Title : accession_number or object_idUsage : $unique_key = $seqobj->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 shouldreturn "unknown".[Note this method name is likely to change in 1.3]With the new Bio::IdentifiableI interface, this is aliasedto object_idReturns : A stringArgs : A string (optional) for setting
primary_id
Title : primary_idUsage : $unique_key = $seqobj->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 natural primary id, this methodshould return a stringified memory location.Returns : A stringArgs : A string (optional, for setting)
alphabet
Title : alphabetUsage : if( $seqobj->alphabet eq 'dna' ) { # Do something }Function: Get/set the alphabet of sequence, 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 type - if there is no alphabet specified ithas to guess.Args : optional string to set : 'dna' | 'rna' | 'protein'
desc
Title : desc or descriptionUsage : $seqobj->desc($newval);Function: Get/set description of the sequence.'description' is an alias for this for compliance with theBio::DescribeableI interface.Returns : value of desc (a string)Args : newvalue (a string or undef, optional)
can_call_new
Title : can_call_newUsage :Function:Example :Returns : trueArgs :
id
Title : idUsage : $id = $seqobj->id();Function: This is mapped on display_idExample :Returns :Args :
is_circular
Title : is_circularUsage : if( $seqobj->is_circular) { # Do something }Function: Returns true if the molecule is circularReturns : Boolean valueArgs : none
Methods for Bio::IdentifiableI compliance
object_id
Title : object_idUsage : $string = $seqobj->object_id();Function: Get or set a string which represents the stable primary identifierin this namespace of this object. For DNA sequences thisis its accession_number, similarly for protein sequences.This is aliased to accession_number().Returns : A scalarArgs : Optional object ID to set.
version
Title : versionUsage : $version = $seqobj->version();Function: Get or set a number which differentiates between versions ofthe same object. Higher numbers are considered to belater and more relevant, but a single object describedthe same identifier should represent the same concept.Returns : A numberArgs : Optional version to set.
authority
Title : authorityUsage : $authority = $seqobj->authority();Function: Get or set a string which represents the organisation whichgranted the namespace, written as the DNS name of theorganisation (eg, wormbase.org).Returns : A scalarArgs : Optional authority to set.
namespace
Title : namespaceUsage : $string = $seqobj->namespace();Function: Get or set a string representing the name space this identifieris valid in, often the database name or the name describing thecollection.Returns : A scalarArgs : Optional namespace to set.
Methods for Bio::DescribableI compliance
This comprises of display_name and description.
display_name
Title : display_nameUsage : $string = $seqobj->display_name();Function: Get or set a string which is what should be displayed to the user.The string should have no spaces (ideally, though a cautioususer of this interface would not assume this) and should beless than thirty characters (though again, double checkingthis is a good idea).This is aliased to display_id().Returns : A string for the display nameArgs : Optional string for the display name to set.
description
Title : descriptionUsage : $string = $seqobj->description();Function: Get or set a text string suitable for displaying to the user adescription. This string is likely to have spaces, butshould not have any newlines or formatting - just plaintext. The string should not be greater than 255 charactersand clients can feel justified at truncating strings at 255characters for the purposes of display.This is aliased to desc().Returns : A string for the descriptionArgs : Optional string for the description to set.
Methods Inherited from Bio::PrimarySeqI
These methods are available on Bio::PrimarySeq, although they are actually implemented on Bio::PrimarySeqI
revcom
Title : revcomUsage : $rev = $seqobj->revcom();Function: Produces a new Bio::SeqI implementing object whichis the reversed complement of the sequence. For proteinsequences this throws an exception of"Sequence is a protein. 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:$seqobj = $seqobj->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::SeqI objectArgs : none
trunc
Title : truncUsage : $subseq = $myseq->trunc(10,100);Function: Provides a truncation of a sequence,Returns : A fresh Bio::SeqI implementing object.Args : Numbers for the start and end positions
Internal methods
These are internal methods to PrimarySeq
_guess_alphabet
Title : _guess_alphabetUsage :Function: Automatically guess and set the type of sequence: dna, rna, proteinor '' if the sequence was empty. This method first removes dots (.),dashes (-) and question marks (?) before guessing the alphabetusing the IUPAC conventions for ambiguous residues. Since the DNA andRNA characters are also valid characters for proteins, there isno foolproof way of determining the right alphabet. This is our bestguess only!Returns : string 'dna', 'rna', 'protein' or ''.Args : none