[Bioperl-l] "jump" to the right sequence in a SeqIO object

Chris Fields cjfields at uiuc.edu
Mon Jan 29 22:18:53 EST 2007


On Jan 29, 2007, at 8:23 PM, zhihua li wrote:

> hi netters,
>
> suppose I read in a multi-fasta file to a SeqIO object:
>
> my $seqinput=Bio::SeqIO->new(-file=>'~/file.txt',
>                                             -format=>'Fasta');
>
> This file contains 100 fasta sequences.  Right now I only want to  
> deal with two of them, with the display ID "X" and "Y" respectively.
> Normally what I'd do is to write a loop to "capture" these two:
> my ($X, $Y);
> while($seqinput->nextseq){
>     if($_->id="X"){$X=$_;}
>     if($_->id="Y"){$Y=$_;}
>    }
>
> My question is, is there some other way to do that? Is it possible  
> to locate the two
> sequences that have the display ID as "X" and "Y" directly, without  
> looping through
> the whole list?

There are several flat database implementations which would do what  
you want.  Look at the POD for Bio::DB::Fasta, Bio::Index::Fasta, as  
well as the FAQ, the tutorial, and the Flat Database HOWTO, all of  
which have more information.

chris



More information about the Bioperl-l mailing list