Bioperl: Bio::Tools::Blast->new on sequence file w/no hits, throws fatal exception. Any ideas?

Timothy M. Kunau (CBC) kunau@mail.ahc.umn.edu
Thu, 27 May 1999 17:39:52 -0500


I hope this is a silly question,

I have a PERL script to parse BLASTX files and format the data
for our databases. This operation fails:


    $blastObj = Bio::Tools::Blast->new( -file => $seqfile,
        -parse  => 1,  
        -signif => '1e-1',
        -stats => 1 );


The EXCEPTION report looks like this:


    -------------------- EXCEPTION --------------------
    MSG: No hits were found.
    CONTEXT: Error in object Bio::Tools::Blast "3201671"
    SCRIPT: ./parse
    STACK: 
    Bio::Tools::Blast::_parse(1521)
    Bio::Tools::Blast::parse(1476)
    Bio::Tools::SeqAnal::_initialize(286)
    Bio::Tools::Blast::_initialize(1051)
    Bio::Root::Object::new(455)
    main::parse_file(348)
    main::prepare_file(291)
    File::Find::finddir(155)
    File::Find::finddir(182)
    File::Find::find_opt(109)
    File::Find::find(202)
    main::./parse-em.pl(99)
---------------------------------------------------


where $seqfile is a normal BLASTX result file with no hits. 
The $seqfile also contains the following line:


     ***** No hits found ******


The EXCEPTION then aborts my script.

Short of grep'ing the file for the existence of this line, is 
there a preferred method to trap and handle this exception more
gracefully? I had thought:


     @bohits = $blastObj->num_hits('total');


where the number of elements in the array could be tested to be
greater than zero (0). However, the error occurs in the Blast->new
invocation so there is no new $blastObj to test. <sigh>

Does anyone else have a better work-around?

Thanks,

Tim
-- 
Timothy M. Kunau  kunau@ahc.umn.edu  Computational Biology Ctrs.
Genomic Database Administrator, Computing and Bioinformatics, AHC
612-626-6937  http://www.cbc.umn.edu/~kunau  http://www.cbc.umn.edu
=========== Bioperl Project Mailing List Message Footer =======
Project URL: http://bio.perl.org/
For info about how to (un)subscribe, where messages are archived, etc:
http://www.techfak.uni-bielefeld.de/bcd/Perl/Bio/vsns-bcd-perl.html
====================================================================