[Bioperl-l] Errors with Bio::Seq objects

Jim Hu jimhu at tamu.edu
Wed Jul 11 14:01:27 EDT 2012


Hi Dejian,

On Jul 11, 2012, at 12:31 PM, De-Jian Zhao wrote:

> Hi,
> 
> I downloaded a nucleotide sequence from Genbank (file name: nt.gb) and tested the Bio::SeqIO module as follows. The first 3 commands succeeded; however the last 2 failed.
> 
> I think $seqio->next_seq() produces a Bio::Seq object which contains the sequence, features and annotation (according to the DESCRIPTION of "perldoc Bio::Seq") and thus the invocation of the methods get_SeqFeatures() and translate() should be valid. However, the results denied this idea.

That's correct about Bio::Seq objects being returned. Actually, it is probably a kind of Bio::Seq object. For example, SeqIO may return a Bio::Seq::RichSeq object that inherits methods from Bio::Seq objects.  However, as explained below, the methods are working as they should... they are just returning objects when you are expecting something else.

> 
> Will anyone explain what happened to the last 2 commands? I have encountered numerous cases of failures when testing the bioperl methods. I want to translate the mRNA sequence and extract the sequence features. What are the right commands? Thanks a lot!
> 
> Best,
> Dejian
> 
> 
> 
> PS: The commands and results
> 
> $ perl -e ' use Bio::SeqIO; my $seqio=Bio::SeqIO->new(-file=>shift); print $seqio->next_seq()->display_id(); ' nt.gb
> NM_053056
> 
> $ perl -e ' use Bio::SeqIO; my $seqio=Bio::SeqIO->new(-file=>shift); print $seqio->next_seq()->molecule(); ' nt.gb
> mRNA
> 
> $ perl -e ' use Bio::SeqIO; my $seqio=Bio::SeqIO->new(-file=>shift); print $seqio->next_seq()->subseq(1,6); ' nt.gb
> CACACG
> 
> $ perl -e ' use Bio::SeqIO; my $seqio=Bio::SeqIO->new(-file=>shift); print $seqio->next_seq()->get_SeqFeatures(); ' nt.gb
> Bio::SeqFeature::Generic=HASH(0x20a30898)Bio::SeqFeature::Generic=HASH(0x20a30bb0)Bio::SeqFeature::Generic=HASH(0x20a30cd0)Bio::SeqFeature::Generic=HASH(0x20a317b0)Bio::SeqFeature::Generic=HASH(0x20a31720)Bio::SeqFeature::Generic=HASH(0x20a39a18)Bio::SeqFeature::Generic=HASH(0x20a317e0)Bio::SeqFeature::Generic=HASH(0x20a398b0)Bio::SeqFeature::Generic=HASH(0x20a39838)Bio::SeqFeature::Generic=HASH(0x20a39e98)Bio::SeqFeature::Generic=HASH(0x20a3b898)Bio::SeqFeature::Generic=HASH(0x20a3a120)Bio::SeqFeature::Generic=HASH(0x20a3bda8)Bio::SeqFeature::Generic=HASH(0x20a3c030)Bio::SeqFeature::Generic=HASH(0x20a3c2b8)Bio::SeqFeature::Generic=HASH(0x20a3be20)Bio::SeqFeature::Generic=HASH(0x20a3c0a8)Bio::SeqFeature::Generic=HASH(0x20a3bb98)Bio::SeqFeature::Generic=HASH(0x20a3c300)Bio::SeqFeature::Generic=HASH(0x20a3c588)Bio::SeqFeature::Generic=HASH(0x20a3d838)Bio::SeqFeature::Generic=HASH(0x20a3dfb8)Bio::SeqFeature::Generic=HASH(0x20a3dd18)

http://doc.bioperl.org/bioperl-live/Bio/Seq.html#POD24

$seq_obj->get_SeqFeatures() returns an array of SeqFeature objects, which are references.  So this worked as expected.

I usually write this as script files, so I've never done it all with perl -e.  But you need to iterate over the array and query the objects for the information you want about the features.


> 
> $ perl -e ' use Bio::SeqIO; my $seqio=Bio::SeqIO->new(-file=>shift); print $seqio->next_seq()->translate(); ' nt.gb
> Bio::Seq::RichSeq=HASH(0x20a3e7b0)

->translate returns a new Seq object.  I think 

$ perl -e ' use Bio::SeqIO; my $seqio=Bio::SeqIO->new(-file=>shift); print $seqio->next_seq()->translate()->seq(); ' nt.gb

should work (haven't tried it).

Jim

> 
> 
> 
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

=====================================
Jim Hu
Professor
Dept. of Biochemistry and Biophysics
2128 TAMU
Texas A&M Univ.
College Station, TX 77843-2128
979-862-4054





More information about the Bioperl-l mailing list