Bioperl: Bio::Tools::Blast->new on sequence file w/no hits,
throws fatal exception. Any ideas?
Steve Chervitz
sac@neomorphic.com (Steve A. Chervitz)
Fri, 28 May 1999 10:57:20 -0700 (PDT)
Steve (and Tim, Michael, Nathan, and perhaps untold others),
I've also thought about this situation some more and I agree that the
behavior of the blast object in this regard is "exceptional". Throwing
exceptions during object construction is serious since it prevents any
use of the object and this should only occur under dire circumstances
(e.g., file not found).
Having no hits below a significance threshold is not so much an
exception as a condition or observation; one of a range of valid
states. I can also see that other features could be of interest in a
blast object that lacks any hits. So I must confess some guilt in
violating the OO precept that one should not use exception throwing
for programmatic flow control. Let this be a lesson!
However, there might be situations where an attempt to *use* a blast
object lacking hits as if it had hits could lead to an exception being
thrown. For example:
print $blast_obj->hit->expect
where the hit() call returns a hit object for the top hit. Here, hit()
becomes an unsafe operation and should probably be deprecated in favor
of using hits() to get a list of zero or more hit objects.
I will change the bioperl Blast object so that it does not throw an
exception if there are no hits when using a -signif criterion. This
will go into effect for the 0.051 release. If anyone has objections,
speak up now.
SteveC
Steven E. Brenner writes:
> Steve,
>
> > You might wonder: why does the blast object throw an exception when
> > I gave it a perfectly valid, parsable blast report? Well, when you
> > specify a -signif criterion, you are adding a requirement that the
> > blast object should only contain hits at or below the indicated
> > significance value. Since hits are the raison d'etre of a parsed blast
> > object, the object dies since it cannot attach any hits to itself (am
> > I personifying the blast object too much?).
>
> I am afraid I have to disagree with your logic here. I think that finding
> nothing is a perfectly valid behavior. It doesn't seem reasonable to me
> that it would throw an exception.
>
> An exception would indicate (to me) that the operation failed in some
> technical way (e.g., the file wasn't found; the file was corrupted).
>
>
> > Throwing an exception guarantees that a blast object won't be used any
> > further. It also provides a convenient screen, since you know that
> > every object created will have at least one hit at or below your
> > -signif cutoff.
>
> This does not seem a convenient screen to me! This lumps illegal calls
> (to bad or missing files) with valid calls on files with no matches. I
> would much rather have the exception status indicate whether or not the
> parsing worked. It's easy to check for matches later.
>
>
> > BTW, I'd strongly recommend using the above eval {} strategy when
> > doing any reasonably complex operation in a situation where an
> > exception could halt a long-running script prematurely. It's a good
> > "safe scripting" practice.
>
> Agreed. But an exeception should basically only be thrown when the
> program cannot continue in its documented manner. (Hence, the need for an
> exeption to the standard behavior.) Finding no hits definitely doesn't
> meet this criterion for me.
>
> Steve
>
>
> P.S. No angered Bioperl modules were used in the composition of this message.
>
> =========== 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
> ====================================================================
>
=========== 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
====================================================================