[Bioperl-l] using Bio::DB::GenBank get translation

Heikki Lehvaslaiho heikki at nildram.co.uk
Fri Dec 12 15:17:06 EST 2003


Vince,

That 
	while (not(defined($seq)));
line does not make sense. Something like:
	exit unless $seq; 
would do the trick.

The seqfeature part of the code works, so you have a problem accessing 
sequences. 

The following code:

---------------- /tmp/cds.pl -------------------------------------------
use Bio::SeqIO;

$in  = Bio::SeqIO->new(-file => shift -format => 'genbank');
my $seq = $in->next_seq();

foreach my $feat ($seq->all_SeqFeatures){
    my $CDS = "";
    if ($feat->has_tag('translation')){
        $CDS = $feat->start."..".$feat->end;
        print "$CDS\n";
    }else{
        print "Not found\n";
    }
}
---------------- /tmp/cds.pl -------------------------------------------

when run like this:
  	perl /tmp/cds.pl ~/src/bioperl/core/t/data/AB077698.gb

print  out:

Not found
Not found
Not found
80..1144
Not found
Not found
Not found
Not found
Not found
Not found
Not found


which, I suppose, is what you wanted.

Yours,
		-Heikki


On Friday 12 Dec 2003 3:13 pm, Vince Forgetta wrote:
> Hi all,
>
> i have seen on some previous posts that you can retrieve the CDS start
> and stop from a GenBank DNA sequence accessionif the file is stored
> locally and read in using Bio::SeqIO. How would I retrieve the
> translation start and stop of a GenBank accession downloaded using
> Bio::DB::GenBank. For example, the code below does not seem to find a
> tag "translation":
>
> use Bio::DB::GenBank;
> my $gb = new Bio::DB::GenBank;
> my $seq;
>  my $accession;
>  $seq = $gb->get_Seq_by_acc($accession);
>  while (not(defined($seq)));
> foreach my $feat ($seq->all_SeqFeatures()){
>         my $CDS = "";
>         if ($feat->has_tag('translation')){
>         $CDS = $feat->start."..".$feat->end;
>         return "$CDS\n";
>     }else{
>         return "Not found\n";
>     }
>
>
> Thank you for your time.
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l

-- 
______ _/      _/_____________________________________________________
      _/      _/                      http://www.ebi.ac.uk/mutations/
     _/  _/  _/  Heikki Lehvaslaiho    heikki_at_ebi ac uk
    _/_/_/_/_/  EMBL Outstation, European Bioinformatics Institute
   _/  _/  _/  Wellcome Trust Genome Campus, Hinxton
  _/  _/  _/  Cambs. CB10 1SD, United Kingdom
     _/      Phone: +44 (0)1223 494 644   FAX: +44 (0)1223 494 468
___ _/_/_/_/_/________________________________________________________


More information about the Bioperl-l mailing list