[Biopython] subclassing SeqRecord
Peter Cock
p.j.a.cock at googlemail.com
Sat Apr 30 06:21:57 EDT 2011
On Saturday, April 30, 2011, Björn Johansson
<bjorn_johansson at bio.uminho.pt> wrote:
> Hi, and thanks for the answer,
>
> I could use the annotations but it is a dict and I suppose that I
> could not be entirely sure that whatever key I choose is not already
> used?
Well, yes, if you pick a generic key that is a small risk - but
for most of the SeqIO parsers that won't be a problem.
> This is also an exercise in python an inheritance to teach me
> this technique.
>
> What added to my confusion in my old code was that I initiated a
> SeqRecord object with a SeqRecord object as the seq property.
> The seq property can apparently be anything for which there is
> a len() method..?
That could be made stricter, e.g. A Seq or MutableSeq or a
subclass of those. Maybe we should do that...
> I ended up doing a class that can be initialized with a string,
> Seq object or a SeqRecord object.
Making your code too flexible can make it overly complex,
but I have sometimes wondered if the SeqRecord should
Automatically upgrade a string argument to a Seq object.
Peter
More information about the Biopython
mailing list