[Bioperl-l] Bio::Index::Fasta foreach loop
Ann Hedley
ann.hedley at ed.ac.uk
Thu Apr 10 14:31:26 EDT 2003
Hi
I've used Bio::Index::Fasta to make the index $inxdc from a fasta file.
I now want a loop to to examine each sequence in turn.
This script prints the correct sequence...
my $seqdc = $inxdc->fetch("CEC00023");
print $seqdc->seq;
... so the index file is OK, but how do I put that in a loop for each
sequence $id?
Any ideas much appreciated
Many Thanks
Ann
#!/usr/bin/perl -w
use strict;
use Bio::Index::Fasta; # using fasta file format
##########get decoder seqs into $idxdc
#########################################
my $Index_File_name = shift;
my $filedc = "/home/user1/alldc5.fsa";
my $inxdc = Bio::Index::Fasta->new( -filename => $filedc . ".idx",
-write_flag => 1 );
# pass a reference to the critical function to the Bio::Index object
$inxdc->id_parser(\&get_id);
# make the index
$inxdc->make_index($filedc);
###########print sequence and length for all
seqs###############################
foreach $inxdc($id) #????????????
{
my $seqdc = $inxdc->fetch("$id");
print $seqdc->seq;
print " length is ",$seqdc->length(), ", decoder\n";
}
#########################################################################
# here is where the retrieval key is specified
sub get_id
{
my $header = shift;
$header =~ /^>(CEC\d{5})/;
$1;
}
More information about the Bioperl-l
mailing list