0

This code was working properly but now it complains, does the genbank structure changed?

#!/usr/bin/perl -w                                                                                                                                                                 
#use strinct ;                                                                                                                                                                     

use Bio::SeqIO;
use Bio::Seq;
use Bio::DB::EUtilities;


    @refSeqIDs=qw(NC_000915.1 NC_017379.1 NC_017371.1 NC_017354.1);
    foreach my $refSeqIDs (@refSeqIDs){
        my $factory = Bio::DB::EUtilities->new(-eutil   => 'efetch',-db=> 'protein',-  rettype => 'gb',
                                           -email   => 'x@y.com',-id=> $refSeqIDs);
        my $rawfile = "$refSeqIDs.gbk";
        $factory->get_Response(-file =>"$refSeqIDs.gbk");
        my $seqio_object = Bio::SeqIO->new(-format=>"Genbank",-file =>"$refSeqIDs.gbk");
        while ( my $seq_object=$seqio_object->next_seq){
            $sequence=$seq_object->seq;
            print ("$sequence\n");
        }
    }
user1876128
  • 91
  • 14

1 Answers1

0

Your $sequence variable is empty because there are no sequences in these genbank records. If you just want to download the full genome sequences for these IDs, just specify that you want a fasta instead of a genbank record.

#!/usr/bin/env perl

use strict;
use warnings;
use Bio::DB::EUtilities;


my @refSeqIDs = qw(NC_000915.1 NC_017379.1 NC_017371.1 NC_017354.1);

my $factory = Bio::DB::EUtilities->new(-eutil   => 'efetch', 
                                       -db      => 'nucleotide', 
                                       -rettype => 'fasta',
                                       -email   => 'x@y.com',
                                       -id      => \@refSeqIDs);

print $factory->get_Response->content;

If you wanted something different, please indicate what you were trying to fetch. Also, it is good to always put use strict; and use warnings; at the top of your script for diagnosing these types of messages.

SES
  • 850
  • 1
  • 9
  • 21