[Bioperl-l] named parameters
Jason Stajich
jason@chg.mc.duke.edu
Wed, 3 Jan 2001 12:20:17 -0500 (EST)
This is a bit on inconsistency when we specify parameters to new in some
of the bioperl modules. Whenever we don't use named parameters (ie
-file=> 'filename'), we are inconsistent with the fact that all modules
inherit from Bio::Root::RootI. This is because Bio::Root::RootI will
parse a couple of special parameters - specifically
-verbose, -strict, -name, -obj, -record_err
now we really don't use these that much, however, in the case of
Bio::Species
one would call
my @classification = qw( sapiens Homo Hominidae
Catarrhini Primates Eutheria
Mammalia Vertebrata Chordata
Metazoa Eukaryota )
my $sp = new Bio::Species(@classification);
but if one also wanted debugging turned on, one might call this
my $sp = new Bio::Species(-verbose=>1, @classification);
This won't bother RootI, but Bio::Species expects all the parameters to be
part of the classification array.
A solution is to change Bio::Species to expect named parameters so an
array ref is
$sp = new Bio::Species(-verbose=>1, -classification => \@classification );
What are people's reactions to this? If we can agree that this is
expected then we can add this to our programming conventions wiki page.
-Jason