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

Jason Stajich jason@cgt.mc.duke.edu
Thu, 19 Dec 2002 12:59:28 -0500 (EST)


It does handle multiple reports.  Each iteration of next_result will bring
you to the next result in the report file.

What version of bioperl, etc?  can you send an example report that does
this? I regularly use it parse files with many results with no problems.

-j

On Thu, 19 Dec 2002, Donald G. Jackson wrote:

> 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
>

--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu