[Bioperl-l] Question about Bio::SearchIO behavior

Donald G. Jackson donald.jackson@bms.com
Thu, 19 Dec 2002 12:49:33 -0500


Hi Jason,

I'm running into some behavior from the Bio::SearchIO package which 
doesn't match my understanding of the documentation.

I'm trying to parse a blast report with multiple query sequences using 
the following code:

    my $search = new Bio::SearchIO( -file => $infile, -format => 'blast');
    while (my $report = $search->next_result) {
        print "Parsing query ", $report->query_name, "\n";

        while($sbjct = $report->next_hit) {
        print "Next subject: ", $sbjct->name, "\n";
    ....


This works fine for the first query, but on the second query it gives 
the following error:

Can't call method "query_name" on an undefined value at 
/net/hox/home/jacksod/lstein_genome_browser_stuff/troubleshooting/blast2table_searchio.pl 
line 19, <GEN1> line 1.

I also tried generating my output in xml and using the blastxml format; 
I get the same behavior

I looked at blast.pm module and noticed the following (lines 204-216)

   while( defined ($_ = $self->_readline )) {
       next if( /^\s+$/); # skip empty lines
       next if( /CPU time:/);
       if( /^([T]?BLAST[NPX])\s*(\S+)/i ) {
       if( $seentop ) {
           $self->_pushback($_);
           $self->end_element({ 'Name' => 'BlastOutput'});
           return $self->end_document();
       }
       $self->start_element({ 'Name' => 'BlastOutput' } );
       $seentop = 1;
       $reporttype = $1;

This looks to me like blast.pm is set to only look at the first 'report' 
in an output file.  I assumed that since there was a next_report method 
in SearchIO that it would be able to handle multiple reports - is that 
not the case?

Thanks,

Don Jackson
BMS Bioinformatics