[Bioperl-l] Fetch sequences from a fasta file using a list of idenifiers

Chris Fields cjfields at uiuc.edu
Wed Dec 12 10:22:45 EST 2007

If you use Bio::Index::Fasta (which is what bp_index.pl uses for FASTA  
files) then you can write up your own script.  From 'perldoc  

# Once the index is made it can accessed, either in the
# same script or a different one
use Bio::Index::Fasta;
use strict;

my $Index_File_Name = shift;
my $inx = Bio::Index::Fasta−>new(−filename => $Index_File_Name);
my $out = Bio::SeqIO−>new(−format => ’Fasta’,
                           −fh => \*STDOUT);

foreach my $id (@ARGV) {
     my $seq = $inx−>fetch($id); # Returns Bio::Seq object

# or, alternatively
my $id;
my $seq = $inx−>get_Seq_by_id($id); # identical to fetch()



On Dec 12, 2007, at 7:29 AM, Nadav Y. Denekamp wrote:

> Hello,
> I am trying to retrieve a list of sequences from an indexed flast  
> FASTA file. I tried to use the script bp_fetch.pl but I could only  
> retrieve one sequence for one identifier. I am looking for a way to  
> provide a list of accession numbers to a script and to retrieve the  
> sequences. I don't have much experience with perl so I appologize if  
> this question is very basic
> thanks - Nadav
> ------------------------------------------------------------------------------------------------------------
> Nadav Y. Denekamp, Ph.D.,
> Israel Oceanographic and Limnological Research,
> National Institute for Oceanography
> Tel-Shikmona, Haifa, 31080.
> Tel: 972-4-8565259
> Fax: 972-4-8511911
> mobile: 972-50-2167318
> Skype: nadavden
> Email: nadavd at ocean.org.il; nadav.denekamp at gmail.com;
> Visit the “Sleeping Beauty” website:
> http://www.gmm.gu.se/SB
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

Christopher Fields
Postdoctoral Researcher
Lab of Dr. Robert Switzer
Dept of Biochemistry
University of Illinois Urbana-Champaign

More information about the Bioperl-l mailing list