[Bioperl-l] Is it possible to parse BLAST output using IO:String?

Ryan Golhar golharam at umdnj.edu
Mon Oct 30 21:54:45 UTC 2006

Hmmm.  Yes, I suppose I could.  
I did it with the backtick because I based my code off of the "To and
>From a String" from the SeqIO HOWTO...

-----Original Message-----
From: Jason Stajich [mailto:jason.stajich at gmail.com] On Behalf Of Jason
Sent: Monday, October 30, 2006 4:44 PM
To: Sendu Bala
Cc: golharam at umdnj.edu; 'bioperl-l'
Subject: Re: [Bioperl-l] Is it possible to parse BLAST output using

right - can't you just do: 

my $fh;
open($fh, "megablast -d ... | ") || die $!;
my $searchIO = Bio::SearchIO->new(-format => 'blast', -fh => $fh);

On Oct 30, 2006, at 1:27 PM, Sendu Bala wrote:

Ryan Golhar wrote:

I'm trying to parse some blast output w/o actually creating the output
file.  Instead, I'm capturing the output in a variable and would like to
use IO::String to represent the file:

$_ = `megablast -d somedatabase -i somesequence -D 2`;
my $blast_file = new IO::String($_);
my $searchio = new Bio::SearchIO(-format => 'blast', -fh =>
my $results = $searchio->next_result;
my $hit = $results->next_hit;
if (! defined($hit)) {
warn "No BLAST hit for $accession on chr $chr for

Now, when Bio::SearchIO tries to read the output line by line, instead
it reads the entire output as 1 line.

If I provide the output in a file and use:

my $searchio = new Bio::SearchIO(-format => 'blast', -file =>

This works...so is it possible to use IO::String to provide
Bio::SearchIO with BLAST output?

Why must it be IO::String? Why not just open() your megablast and 
provide $searchio the real filehandle? It would be faster that way as

Read the docs for `. Your usage above is inappropriate.

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

Jason Stajich, PhD 
Miller Research Fellow
University of California
Dept of Plant and Microbial Biology
321 Koshland Hall #3102
Berkeley, CA 94720-3102
lab: 510.642.8441

More information about the Bioperl-l mailing list