[Bioperl-l] Using SeqIO

Brian Carlson bcarlson at genetics.emory.edu
Thu Mar 13 12:40:24 EST 2003


I have the need to extract 1000's of 36bp sequences from a fasta file. 
>From previous help, I've have this sample code (snippet) extracting some
sequence:

$in = new Bio::SeqIO ( -format=>'fasta', -file=>'mouse_T3.fasta');
while (my $seq = $in->next_seq)
{
  if ($seq->desc eq $target_description)
  {
    print "Description : " . $seq->desc . "\n";
    $seq = $seq->trunc($start, $stop);
    print "BP $start-$stop : " . $seq->seq . "\n";
    last;
  }
}


But it would seem slow to keep re-reading the fasta each time I wanted
to extract the sequence.  How do you just "rewind" it back to the
beginning?  Or do I have to just re-read it?



More information about the Bioperl-l mailing list