[Bioperl-l] Parsing a blast report with multiple queries into separate one query files that only contain the fasta sequences

maha ahmed mahakadry at aucegypt.edu
Tue Nov 20 18:44:53 UTC 2012

Dear BioPerl list,
I blasted a file that has several fasta queries against nr, however I need
to align each query with its hits for further computational analysis so I
need to parse the produced blast report into several files that each has
only the fasta query sequence and its hits in fasta format.
I found this script online,

use Bio::Search::Result::BlastResult;use Bio::SearchIO;
 my $report = Bio::SearchIO->new( -file=>'full-report.bls', -format
<http://perldoc.perl.org/functions/format.html> => blast);my $result =
$report->next_result;my %hits_by_query;while (my $hit =
$result->next_hit) {
  push <http://perldoc.perl.org/functions/push.html>
@{$hits_by_query{$hit->name}}, $hit;}
 foreach my $qid ( keys <http://perldoc.perl.org/functions/keys.html>
%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
<http://perldoc.perl.org/functions/format.html>=>'blast' );

however on using it this produced the following error message

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 /usr/local/share/perl/5.10.0/Bio/Root/Root.pm:472
STACK: Bio::Search::Result::BlastResult::iteration
STACK: Bio::Search::Result::BlastResult::add_hit
STACK: ./parsing.blast.results.into.per.query.files.pl:15

I tried to search for other scripts but I couldn't find any
I would really appreciate your comments to this
Thank you

More information about the Bioperl-l mailing list