[Bioperl-l] Bio::SeqIO -- Reading Formated sequence file (Fasta) into Array
Edward WIJAYA
ewijaya at singnet.com.sg
Tue Feb 28 10:01:23 UTC 2006
Hi,
Does Bio::SeqIO has a method specially designed for
reading all the sequences from a fasta file into array.
What I have currently is this subroutine, it seems to me
__very inefficient__. I was wondering
is there a better way to achieve it.
sub get_sequence_from_fasta {
my $file = shift;
my @seqs= ();
open INFILE, "<$file" or die "$0: Can't open file $file: $!";
my $in = Bio::SeqIO->new(-format => 'fasta',
-noclose => 1 ,
-fh => \*INFILE);
while ( my $seq = $in->next_seq() ) {
push @seqs, $seq->seq();
}
return @seqs;
}
BTW, I also have tried to do this. I thought
this might be a better way to do the above job.
but it doesn't work.
sub get_sequence_from_fasta_that_doesnot_work {
my $file = shift;
open my fh, "<$file" or die "$0: Can't open file $file: $!";
my $in = Bio::SeqIO->newFh( -format => 'fasta', -fh => $fh );
return <$in>;
}
Hope to hear from you again.
--
Regards,
Edward WIJAYA
SINGAPORE
More information about the Bioperl-l
mailing list