[Biopython-dev] [Bug 2639] SeqRecord.init doesn't check for arguments for their types
bugzilla-daemon at portal.open-bio.org
bugzilla-daemon at portal.open-bio.org
Fri Jan 30 11:54:26 UTC 2009
http://bugzilla.open-bio.org/show_bug.cgi?id=2639
biopython-bugzilla at maubp.freeserve.co.uk changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |FIXED
------- Comment #6 from biopython-bugzilla at maubp.freeserve.co.uk 2009-01-30 06:54 EST -------
(In reply to comment #5)
> Ok, understood. I didn't thought of these cases.
> However, having not a Seq causes errors that are difficult to
> understand in other functions that use SeqRecord.
> For example, if you do:
>
> >>> a = SeqRecord(id = '1')
> >>> a.format('fasta')
>
> you get the error:
> <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute
> 'tostring'
>
> This could scary an eventual biopython newbie, an exception like to
> 'error - current SeqRecord object doesn't have a Seq' could be better.
Well, if you want to create a SeqRecord where the sequence is None, you'd have
to do SeqRecord(None, id="1") - your suggestion of SeqRecord(id="1") doesn't
work as the sequence is a mandatory argument.
However, I see your point that the current AttributeError isn't helpful in this
special case. I've updated the Bio/SeqIO/FastaIO.py file in CVS (revision
1.15) to give a TypeError in this situation which will try to explain the
problem.
> What do you think about creating a 'NullSeq' object, which represent a
> Seq with no value, and using it as a default for SeqRecord?
> Later we could modify the other functions like .format e Seq.translate to
> intercept these objects and return the right error message.
Hmm. It seems rather complicated for a rare case. Using None to mean
"missing" or "null" is done in other python libraries/code (e.g. database
access), which is why I suggested someone might want to do this.
Marking this bug as fixed.
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Biopython-dev
mailing list