[Bioperl-l] Trouble retrieving multiple sequences from NCBI in a single list query

Dave Messina David.Messina at sbc.su.se
Wed Nov 4 04:52:53 EST 2009


>
> The code I´ve written seems to read mylist and retrive the sequences, but
> it kinda overwrites them so that I only get the last sequence on the list.
>

With this line

my $out = new Bio::SeqIO (-file => ">extracted_seqs.fasta", -format =>
'fasta');


you are opening the filehandle for the output file inside your loop, so each
time it is writing over the previous file with an empty file. Then, you
write a single sequence to that file with this line

$out->write_seq($seqobj);


So when you are done, you just have the last sequence in the output file.

If you move the opening of the output filehandle outside the loop (it needs
to be done only once), then it should work as you expect.

Also, I notice the newline characters are not being removed from your
sequence IDs  (actually I'm a little surprised that the sequences are being
retrieved). Just to be safe, you may want to add the line

chomp @lista;


after

my @lista = <INFILE>;




Dave



More information about the Bioperl-l mailing list