[Bioperl-l] Sorting BLAST hits by score
Lorenzo Carretero
lcpaulet at googlemail.com
Thu Apr 7 15:37:24 UTC 2011
Hi all,
I'm wrinting a subroutine to parse blast reports . The script:
*my $in = new Bio::SearchIO(-file => $filename ,
-format => $format) or die "No $filename BLAST file with
$format found";
while( my $result = $in->next_result )
{
$result->sort_hits();
my $query = $result->query_name();
my $number_of_hits = $result->num_hits();
print "Query Name : " ,$query,"\n";
print "Number of Hits : ", $number_of_hits,"\n";
my $pointer = 0;
while( my $hit = $result->next_hit()) ## $hit is a
Bio::Search::Hit::HitI compliant object
{
my $hitname = $hit->name();
my $evalue = $hit->significance();
while( my $hsp = $hit->next_hsp ) ## $hsp is a Bio::Search::HSP::HSPI
compliant object
{
my $querylen = $hsp->length( 'query' );
my $hitlen = $hsp->length( 'hit' );
my $alnlen = $hsp->length( 'total' );
my $identity = $hsp->percent_identity();
my $value =
"$query\t$hitname\t$identity\t$evalue\t$querylen\t$hitlen\t$alnlen\t$number_of_hits\n";
print "Value Content : $value\n";
}
}
#if($pointer > 0){last;}
}*
is within a sub to get the best non redundant hit from -m8/9 NCBI format
blast reports
According to the documentation for *Bio::Search::Result::ResultI* objects,
the sort_hits method "sorts the available hit objects by a user-supplied
function. *Defaults to sort by descending score.* "
However, I get the following error message:
Use of uninitialized value in numeric comparison (<=>) at
/Library/Perl//5.10.0/Bio/Search/Result/ResultI.pm line 202, <GEN1> line
2773.
Furthermore, every iteration through the hsps returns the warnig message:
--------------------- WARNING ---------------------
MSG: Did not define the number of conserved matches in the HSP; assuming
conserved == identical (152)
I can't see where the problem is!!!
Thank you a lot for your help,
Lorenzo
More information about the Bioperl-l
mailing list