[Bioperl-l] Bio::Tools::GuessSeqFormat unknown return value?
Andreas Kahari
ak at ebi.ac.uk
Wed Dec 10 05:06:56 EST 2003
On Wed, Dec 10, 2003 at 09:35:55AM +0000, Heikki Lehvaslaiho wrote:
>
> Bio::Tools::GuessSeqFormat returns now string 'unknown'. My question is: how
> strongly should we enforce the convention that unknown values return undef?
>
> In practice, the choises are (1) undef, (2) empty string, (3) zero, (4)
> predefined string value. What are are the advantages and disadvantages of
> this. Discuss.
>
> I seem to remember that Hilmar felt strongly about this. ;-)
I chosed to return "unknown" when the module wasn't able to
come up with one single good guess because I thought it would
be better than to default to a valid format, such as "fasta"
(this was the way of bioperl-1.2.3, see the new() method of
e.g. Bio::SeqIO).
In retrospect, I think undef would probably be a better value.
Here's a patch for it:
Index: GuessSeqFormat.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/Tools/GuessSeqFormat.pm,v
retrieving revision 1.2
diff -u -r1.2 GuessSeqFormat.pm
--- GuessSeqFormat.pm 2003/12/04 13:32:35 1.2
+++ GuessSeqFormat.pm 2003/12/10 10:03:05
@@ -50,7 +50,7 @@
The guess() method of a Bio::Tools::GuessSeqFormat object will
examine the data, line by line, until it finds a line to which
only one format can be assigned. If no conclusive guess can be
-made, the "unknown" format is returned.
+made, undef is returned.
If the Bio::Tools::GuessSeqFormat object is given a filehandle
which is seekable, it will be restored to its original position
@@ -383,8 +383,7 @@
Function : Guesses the format of the data accociated with the
object.
Returns : A format string such as "swiss" or "pir". If a
- format can not be found, the "unknown" format will
- be returned.
+ format can not be found, undef is returned.
Arguments : None.
If the object is associated with a filehandle and if that
@@ -502,7 +501,7 @@
# Seek to the start position.
$fh->setpos($start_pos);
}
- return ($done ? $fmt_string : "unknown");
+ return ($done ? $fmt_string : undef);
}
Cheers,
Andreas
--
|(--)| Andreas Kähäri |-][-|
|-)(-| EMBL, European Bioinformatics Institute |[--]|
|(--)| Wellcome Trust Genome Campus, Hinxton |-][-|
|-)(-| Cambridge, CB10 1SD |[--]|
|(--)| United Kingdom |-][-|
More information about the Bioperl-l
mailing list