LynHsiong | 6 Jun 05:22 2013

Errors in a bioperl script, pls help me to have a check, thanks in advance

Dear friends:

I have a blast report, and want to extract following information for each
result(query): the Query_name, hit_number, name and description of the
hit(HSP) with the highest identity.

my bioperl script is:

#!/usr/bin/perl -w
use strict;
use warnings;
use Bio::SearchIO;

if ( <at> ARGV != 2){die "Usage: $0 <BLAST-report-file> <output-file>\n"};

my ($infile,$outfile) =  <at> ARGV;
print "Parsing the BLAST result ...";
my $blast = new Bio::SearchIO(
-format => 'blast',
-file   => $infile);
open (OUT,">$outfile") or die "Cannot open $outfile: $!";

print OUT "query\tNumber of hits\tGreatest identity %\tAccession (identity
%)\tDescription (identity %)\n";

while (my $result = $blast->next_result){
   print OUT $result->query_name . "\t";
   print OUT $result->num_hits. "\t";
        if (my $hit = &sort_hit($result)){
                         if (my $hsp=$hit->hsp){
                                        print OUT $hsp->percent_identity.
                                        print OUT $hit->accession. "\t";
                                        print OUT $hit->description. "\n";
 close OUT;
 print " DONE!!!\n";

 sub sort_hit{
                  my $result = shift;
                  my  <at> hits;
                  while (my $hit = $result->next_hit) {
                        push  <at> hits, $hit;
                  my  <at> hit_sort = sort { $b-> hsp ->percent_identity * 100
<=> $a-> hsp ->percent_identity * 100 }  <at> hits;
                  my $flag=0;
                  my $temp_hit;
                  while (my $hit=$result->next_hit){
                  return $temp_hit

error information:

-------------EXCEPTION: Bio::Root::Exception -------------
MSG: Can't get HSPs: data not collected.
STACK: Error::throw
STACK: Bio::Root::Root::throw
STACK: Bio::Search::Hit::GenericHit::hsp
STACK: main::sort_hit
Parsing the BLAST result ...

please give me some clues, all your words are welcome!

View this message in context:
Sent from the Bioperl-L mailing list archive at