[Bioperl-l] Bio::DB::Fasta

Brian Osborne brian_osborne at cognia.com
Fri Jun 27 09:38:03 EDT 2003


This comes directly from the module's documentation:

use Bio::DB::Fasta;

# Bio::SeqIO-style access
my $stream  = Bio::DB::Fasta->new('test.fa')->get_PrimarySeq_stream;

while ( my $seq = $stream->next_seq ) {
   print $seq->seq;

You also asked about "customizing" the indexing so you can use ids you have
in hand, which partially match the ids in the file. See the bptutorial
section on "Indexing or accessing..." or FAQ question 2.5.

Brian O.

-----Original Message-----
From: bioperl-l-bounces at portal.open-bio.org
[mailto:bioperl-l-bounces at portal.open-bio.org]On Behalf Of Michael R Olson
Sent: Thursday, June 26, 2003 6:01 PM
To: Bioperl Mailing List
Subject: [Bioperl-l] Bio::DB::Fasta

A couple days ago someone gave me the advice to use Bio::DB::Fasta to
locate pieces of a large sequence database.  I finally got around to
trying it and I have a frustrating problem.

I want to use the stream-based input, ie

my $seq = $db->next_seq()

because I don't know the sequence ids and can't use get_Seq_by_id().
So, I said:

$db = new Bio::DB::Fasta($filename);

$db->next_seq() doesn't work, because that method, although part of the
same file, is part of a different class, Bio::DB::Fasta::Stream, so I

$db = new Bio::DB::Fasta::Stream($filename);

and I get this error:

Can't call method "FIRSTKEY" without a package or object reference at
/usr/local/bio/www/cgi-bin/BPPNew/Bio/DB/Fasta.pm line 1049.

so I thought, "maybe the argument to the Bio::DB::Fasta::Stream
constructor is a Bio::DB::Fasta object!  However, that gives this error

------------- EXCEPTION  -------------
MSG: Bio::DB::Fasta=HASH(0x8b3d690): Invalid file or dirname
STACK Bio::DB::Fasta::new

As though whatever method line 472 is part of expected me to pass in a
filename, but the constructor expected an object.  Am I doing something
wrong, is this a bug, or perhaps there's another way for me to do it.
Because when I said I don't have the ids, that's not entirely true.  I
have them, but with any punctuation stripped out.  Does get_Seq_by_id
have any kind of way to get a sequence whose id matches a certain
regular expression or something like that?

Bioperl-l mailing list
Bioperl-l at portal.open-bio.org

More information about the Bioperl-l mailing list