[Bioperl-l] getting top blast hit

Nandita Mullapudi nandita at uga.edu
Fri Apr 2 10:32:34 EST 2004

Thanks, Sean,
I tried the suggestion below in my script, which starts with a loop 
to read through a list of files..
however, now, my script stops parsing as soon as it reaches a file 
with no hits in it.

this is the error message:

can't call method "name" on an undefined value at 
/home/nandita/parse_blast-onlytophit.pl line 26, <GEN123> line 65.

I realise I am not looping through completely or...
Any suggestions?

use strict;
use Bio::SearchIO;
use Bio::SimpleAlign;
my (@list, $filename);
my $files= "/scratch/nandita/list";
open (FH,"$files") or die "cannot create list :$!";
while (<FH>) {
     push (@list, $_);
# print " $_\n";                                                               

foreach  (@list) {
#    print "$filename\n";                                                      

     my $in = new Bio::SearchIO(-format => 'blast',
                                -file   => "$filename");

while( my $result = $in->next_result ) {
print  "\n", $result->query_name, "\t";
  my $top_hit = $result->next_hit ; {
     print  $top_hit->name, "\t";
print   $top_hit->significance,. "\n";

>You can do something like (from Bio::SearchIO):
>    use Bio::SearchIO;
>    # format can be 'fasta', 'blast', 'exonerate', ...
>    my $searchio = new Bio::SearchIO( -format => 'blastxml',
>                                      -file   => 'blastout.xml' );
>    while ( my $result = $searchio->next_result() ) {
>        #get first hit and do something with it.
>        my $top_hit = $result->next_hit;
>        #do some stuff such as saving a it in a hash
>        #move on to next result (next query)
>    }
>On 3/30/04 6:19 PM, "Nandita Mullapudi" <nandita at uga.edu> wrote:
>>  I am currently using  Bio::SearchIO to parse tons of blast files by
>>  setting limits on E- value, % identity etc. I now want to parse a
>>  huge blast job, by getting just the top hit out of each file.
>>  (Assuming blast was run and hits were returned with hit with lowest E
>>  value first)
>>  Is there a quick way to do this?
>>  thanks,
>>  -Nandita
>>  _______________________________________________
>>  Bioperl-l mailing list
>>  Bioperl-l at portal.open-bio.org
>>  http://portal.open-bio.org/mailman/listinfo/bioperl-l

More information about the Bioperl-l mailing list