[Bioperl-l] automation of translation based on alignment

Ross KK Leung ross at cuhk.edu.hk
Tue Mar 23 01:20:56 EDT 2010

my $streamobj = $gb->get_Stream_by_acc(@ids);

while (my $seqobj = $stream->next_seq) {
   # do stuff here

The above retrieves a stream of Bio::Seq objects (specifically, a Bio::SeqIO
stream). '$stream->next_seq()' iterates through them one at a time.  Unless
you call a stream in some way, that code will not work.  If you call the
methods below directly on the *sequence* object ($seqobj, retrieved from
get_Seq_by_*), NOT the *stream* object (get_Stream_by_*), it should work.

>  for my $feat_object ($seqobj->get_SeqFeatures) {
>      if ($feat_object->primary_tag eq "CDS") {
>          print $feat_object->spliced_seq->seq,"\n";
>          if ($feat_object->has_tag('gene')) {
>              for my $val ($feat_object->get_tag_values('gene')){
>                  print "gene: ",$val,"\n";
>              }
>          }
>      }
>  }                                         

Chris, in fact I did have this code before, but then it goes back to the old
problem that the spliced sequence is incorrect. Please try using the
following codes with "DQ089804" as the argument. If you check the printed
result with:


you'll discover, for example, the sequence of gene P, is derived from
splicing 1-1623 (starts with CTC...) and 2307-3215 (starts with ATG...),
rather than 2307-3215 and 1-1623.

use Bio::SeqIO::genbank; use Bio::DB::GenBank;

use Bio::SeqIO;


my ($acc) = @ARGV;

$gb = new Bio::DB::GenBank;


$streamobj = $gb->get_Stream_by_acc($acc);

my $seqobj = $streamobj->next_seq;


  for my $feat_object ($seqobj->get_SeqFeatures) {

      if ($feat_object->primary_tag eq "CDS") {

          print $feat_object->spliced_seq->seq,"\n";

          if ($feat_object->has_tag('gene')) {

              for my $val ($feat_object->get_tag_values('gene')){

                  print "gene: ",$val,"\n";






More information about the Bioperl-l mailing list