[Biopython-dev] SeqRecord id behavior

Lenna Peterson arklenna at gmail.com
Tue May 29 21:32:47 UTC 2012

Hi all,

I have some questions/comments regarding how SeqRecord handles various

>>> print SeqRecord(seq="G")
ID: <unknown id>
Name: <unknown name>
Description: <unknown description>
Number of features: 0
>>> print SeqRecord(seq="G", id=2)
TypeError: id argument should be a string
>>> print SeqRecord(seq="G", id=None)
Name: <unknown name>
Description: <unknown description>
Number of features: 0

1. Couldn't a sequence id hypothetically be an integer? In which case,
it could be converted to a string.

2. Regarding this comment on line 180:

    if id is not None and not isinstance(id, basestring):
        #Lots of existing code uses id=None... this may be a bad idea.
        raise TypeError("id argument should be a string")

Why might that be a bad idea? id=None will currently set self.id to
None, so it doesn't affect the type checking.

3. Is it desirable to be able to remove the id from the __str__
representation, or would it be more consistent to do this:

    if id == "<unknown id>" or id is None:
        self.id = "<unknown id>"
        (typecheck here)


More information about the Biopython-dev mailing list