[Bioperl-l] All roads lead to Bio::Seq
Ewan Birney
birney@ebi.ac.uk
Mon, 2 Dec 2002 18:10:07 +0000 (GMT)
I will soon commit this which is reorganise the documentation in
Bio::Seq, Bio::SeqI, Bio::PrimarySeqI and Bio::PrimarySeq to stress
that Bio::Seq has the best documentation and starting point for users
of the package. I am also using [Developers] in the =head1 NAME line to
indicate that a package is for developers only.
I will commit this because I think this is much much better than what is
there at the moment, which was pretty confusing, but recent-newbies - any
other thoughts about this synopsis and also any other reassuring words
to make in Bio::Seq?
Here is the Bio::Seq synopsis...
# This is the main sequence object in Bioperl
# gets a sequence from a file
$seqio = Bio::SeqIO->new( '-format' => 'embl' , -file => 'myfile.dat');
$seqobj = $seqio->next_seq();
# SeqIO can both read and write sequences; see Bio::SeqIO
# for more information and examples
# get from database
$db = Bio::DB::GenBank->new();
$seqobj = $db->get_Seq_by_acc('X78121');
# make from strings in script
$seqobj = Bio::Seq->new( -display_id => 'my_id',
-seq => $sequence_as_string);
# gets sequence as a string from sequence object
$seqstr = $seqobj->seq(); # actual sequence as a string
$seqstr = $seqobj->subseq(10,50); # slice in biological coordinates
# retrieves information from the sequence
# features must implement Bio::SeqFeatureI interface
@features = $seqobj->get_SeqFeatures(); # just top level
foreach my $feat ( @features ) {
print "Feature ",$feat->primary_tag," starts ",$feat->start," ends ",
$feat->end," strand ",$feat->strand,"\n";
# features retain link to underlying sequence object
print "Feature sequence is ",$feat->seq->seq(),"\n"
}
# sequences may have a species
if( defined $seq->species ) {
print "Sequence is from ",$species->binomial_name," [",$species->common_name,"]\n";
}
# annotation objects are Bio::AnnotationCollectionI's
$ann = $seqobj->annotation(); # annotation object
# references is one type of annotations to get. Also get
# comment and dblink. Look at Bio::AnnotationCollection for
# more information
foreach my $ref ( $ann->get_Annotations('reference') ) {
print "Reference ",$ref->title,"\n";
}
# you can get truncations, translations and reverse complements, these
# all give back Bio::Seq objects themselves, though currently with no
# features transfered
my $trunc = $seqobj->trunc(100,200);
my $rev = $seqobj->revcom();
# there are many options to translate
my $trans = $seqobj->translate();
# these functions can be chained together
my $trans_trunc_rev = $seqobj->trunc(100,200)->revcom->translate();