[Bioperl-l] Should be simple accession number script, but it' s not.

Marc Logghe Marc.Logghe@devgen.com
Fri, 13 Dec 2002 21:57:50 +0100


Hi,
I'd definately would use the get_Stream_by_batch method when you want to
fetch multiple sequences.
Something like this should do the job:
#!/usr/bin/perl -w
use strict;
use Bio::SeqIO;
use Bio::DB::GenBank;

local $/ = undef;
my $gi_file = 'Accession.txt';
open FILE, "<$gi_file" || die (Cannot open file $gi_file:$!\n");
my @id = split "\n", (<FILE>); 
my $out = Bio::SeqIO->new;
my $db   = Bio::DB::GenBank->new;
$db->proxy(['http','ftp'], 'http://proxy');

my $seqio = $db->get_Stream_by_batch(\@id);

while (my $seq = $seqio->next_seq)
{
  $out->write_seq($seq)

}
HTH,
Marc

> -----Original Message-----
> From: Agrin, Nathan [mailto:Nathan.Agrin@umassmed.edu]
> Sent: Friday, December 13, 2002 9:24 PM
> To: bioperl-l@bioperl.org
> Subject: [Bioperl-l] Should be simple accession number 
> script, but it's
> not.
> 
> 
> I'm writing a simple script:
> 1) I want it to take a list of accession numbers in a .txt file,
> 2) pull out the entries from GenBank,
> 3) and output the names and sequences to a new .txt file.
> 
> The problem is that when I write something like;
> 
> $seq = $db->get_Seq_by_acc($accession);
> print $seq->seq();
> 
> I get an error saying cannot preform command on an undefined variable.
> Anyone had similar problems?  What's really wierd is that it 
> seems to work some of the time.  Below is the code so far:
> 
> #!perl
> 
> use Bio::DB::GenBank;
> 
> 
> open SEQ, "<accession.txt";
> @anum = "<SEQ>";
> 
> my $db = new Bio::DB::GenBank;
> 
> foreach my $accession ( @anum ) {
> 	# just get things by accession number
> 	my $seq = $db->get_Seq_by_acc($accession);
> 	print $seq->seq();
> }
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>