[Bioperl-l] Problem Parsing BLAST output

Ben Saville bgs500 at york.ac.uk
Fri Aug 20 09:07:50 EDT 2010

Hi Everyone,

I'm very much new to the world of sequence data analysis (and this  
mailing list!), and have reached a roadblock.

I have BLASTed some contigs against a series of databases that I  
created. From this I would like to parse through the data and separate  
it before extracting the information of interest at a later point. I  
would like to separate the data by query ID. I found the following  
Bioperl script;


use Bio::Search::Result::BlastResult;
use Bio::SearchIO;

my $report = Bio::SearchIO->new( -file=>'All_BCM_results.bls', -format  
=> blast);
my $result = $report->next_result;
my %hits_by_query;
while (my $hit = $result->next_hit) {
   push @{$hits_by_query{$hit->name}}, $hit;

foreach my $qid ( keys %hits_by_query ) {
   my $result = Bio::Search::Result::BlastResult->new();
   $result->add_hit($_) for ( @{$hits_by_query{$qid}} );
   my $blio = Bio::SearchIO->new( -file => ">$qid\.bls", - 
format=>'blast' );

running this script resulted in the following error;

BlastResult::new(): Not adding iterations.

------------- EXCEPTION: Bio::Root::NoSuchThing -------------
MSG: No such iteration number: 0. Valid range=1-0
VALUE: The number zero (0)
STACK: Error::throw
STACK: Bio::Root::Root::throw /sw/lib/perl5/5.8.8/Bio/Root/Root.pm:368
STACK: Bio::Search::Result::BlastResult::iteration /sw/lib/perl5/5.8.8/ 
STACK: Bio::Search::Result::BlastResult::add_hit /sw/lib/perl5/5.8.8/ 
STACK: /Users/bsaville/Desktop/Parsing_BLAST_by_query.pl:15

So I added
my $result = Bio::Search::Result::BlastResult->new(1);
The 1 to the line shown above, as it told me this was within the valid  
range. This produced the following error;

------------- EXCEPTION: Bio::Root::Exception -------------
MSG: Must define arrayref of Iterations when initializing a  

STACK: Error::throw
STACK: Bio::Root::Root::throw /sw/lib/perl5/5.8.8/Bio/Root/Root.pm:368
STACK: Bio::Search::Result::BlastResult::new /sw/lib/perl5/5.8.8/Bio/ 
STACK: /Users/bsaville/Desktop/Parsing_BLAST_by_query.pl:14

I know that it is my inexperience that is causing this problem, but I  
really can't figure this out.

Ben Saville

More information about the Bioperl-l mailing list