[Bioperl-l] Bio::Species validation broken

Hilmar Lapp hlapp@gnf.org
Fri, 30 Aug 2002 12:42:21 -0700


I just came across this by chance as the test case in bioperl-db 
gave wrong results for binomial, the reason being that the order of 
@classification on instantiation was reversed, which should have 
been caught by $species->validate_[species_]name() but wasn't. It 
turns out these validations are completely broken.

First off,

	return $string =~ /yourregexp here/ or $self->throw("oops");

will always return and never throw the exception. (Why? Doesn't look 
intuitively so, but it is true at least on Perl 5.6.0, Mac OS X). 
Safe, and more readable is

	return 1 if $string =~ /yourregexp here/;
	$self->throw("oops");

Second, can anyone explain why the validating regexp for species 
name was set to be

	/^[\S\d\.]+$||""/

This regexp is not only redundant in itself, it also matches every 
possible string.

I'm going to fix this now, expect exceptions to be thrown finally ...

	-hilmar
--
-------------------------------------------------------------
Hilmar Lapp                            email: lapp at gnf.org
GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
-------------------------------------------------------------