in reply to Get Fasta file with Protein Sequences given a file with Genbank Ids using Perl
Hi dimitris852,
Just a guess: I haven't examined the doc for Bio::DB::GenBank::get_Seq_by_id() as I am sure you must have done, but by its name I would think that it only expects one ID at a time. You're trying to pass a list which wouldn't work. But ...
... you're actually passing a string with multiple IDs separated by newlines, because you're not calling chomp on your lines when you get them from your filehandle, and because you're passing the array in double quotes, which concatenates it to a string with elements separated by the current value of $, the list separator.
Just loop through your lines:
my $gb=new Bio::DB::GenBank; open my $handle, '<', 'sec.txt' or die !$; # check for success while ( my $line = <$handle> ) { # read one line at a time chomp $line; # strip new line chars print "Doing $line\n"; my $seq = $gb->get_Seq_by_id( $line ); write_sequence (">>roar.fa", 'fasta',$seq ); # ^^ # ( assuming write_sequence() supports appending ) } close $handle or die $!;
Hope this helps!
|
|---|