[Bioperl-l] get cds from genbank record

Pedro Antonio Reche reche at research.dfci.harvard.edu
Thu Jan 15 15:35:04 EST 2004


Hi,
I got this code from Jason Stajich a while a go to get the translated 
CDS from a genbank record and after I updated bioperl to 1.4 version it 
does work not more. Any help to make this thing to work again will be 
apreciated.
The code
!/usr/sbin/perl -w
#use strict;
use Bio::SeqIO;
use Bio::Seq;


my $in = new Bio::SeqIO(-file => "$ARGV[0]", -format => 'genbank');
my $out = new Bio::SeqIO(-file => ">$ARGV[0].tfa");

while( my $seq = $in->next_seq ) {

    foreach my $f ( grep { $_->primary_tag eq 'CDS' }
       $seq->top_SeqFeatures ) {
    my ($gname);
    if( $f->has_tag('gene') ) {
        ($gname) = $f->each_tag_value('gene');
    } elsif( $f->has_tag('product') ) {
        ($gname) = $f->each_tag_value('product');
    }

    my ($ref) = $f->has_tag('protein_id') && 
$f->each_tag_value('protein_id');
    my ($gi)  = $f->has_tag('db_xref') && $f->each_tag_value('db_xref');

    my ($translation) = $f->has_tag('translation') &&
                          $f->each_tag_value('translation');

    unless( $gi && $ref && $gname && $translation ) {
      print STDERR "not fully annotated CDS ($gi,$ref,$gname), 
skipping...\n";
      next;
    }
    my $outseq = Bio::PrimarySeq->new(-seq => $translation,
                                      -display_id =>
            sprintf("gi|%s|gb|%s|%s",$gi,$gname,$ref));
    $out->write_seq($outseq);
  }

The error message

Use of uninitialized value in -d at /usr/share/perl/5.6.1/CGI.pm line 3327.
[Thu Jan 15 18:03:37 2004] bio_get_cds.pl: Filehandle 
Bio::Tools::GuessSeqFormat::$fh opened only for output at 
/usr/local/share/perl/5.6.1/Bio/Tools/GuessSeqFormat.pm line 472.
Content-type: text/html

Content-Type: text/html; charset=ISO-8859-1

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
        "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
lang="en-US"><head><title>Error</title>
</head><body><h1>Error</h1><p>Sorry, the following error has occurred: 
</p><p><i>Can't locate object method &quot;throw&quot; via package 
&quot;Bio::Root::Exception&quot; (perhaps you forgot to load 
&quot;Bio::Root::Exception&quot;?) at 
/usr/local/share/perl/5.6.1/Bio/Root/Root.pm line 328.




More information about the Bioperl-l mailing list