[Biopython-dev] sequence class proposal
jblanca at btc.upv.es
Fri May 23 11:10:13 UTC 2008
After reding the suggestions in Bug 2351 I've coded a MutableSeq class that
inherits from UserString.MutableString instead of using an array stored in
self.data. It's quite easily to do it work as the MutableSeq present in
Biopytyhon 1.45, but there's some problems to solve.
I don't know if this class would be faster or easier to maintain than the
MutableSeq that uses array.array. I've just done that as an experiment to
learn something about Biopython.
Now the compatibility problems that I have found...
self.data is not an array but an str. That's not easy to solve becase
MutableString uses self.data internaly. I tried to define a property class,
but MutableString is an old style class. Maybe I don't know enough python,
but I don't know how to solve this type mismatch.
append() and extend() could be coded using __add__(). insert() and remove()
are not supported by MutableSeq and would have to be coded. But I don't see
the point of this methods in a sequence class. I think that the Seq and the
MutableSeq API should be as similar as possible and since Seq uses __add__()
I don't understand why MutableSeq should use append() and extend().
I also have problems with del seq[2:4:-1] and seq[2::3] = "N" * len(seq[2::3])
All the other tests for MutableSeq just work.
Jose M. Blanca Postigo
Instituto Universitario de Conservacion y
Mejora de la Agrodiversidad Valenciana (COMAV)
Universidad Politecnica de Valencia (UPV)
Edificio CPI (Ciudad Politecnica de la Innovacion), 8E
46022 Valencia (SPAIN)
Tlf.:+34-96-3877000 (ext 88473)
More information about the Biopython-dev