[BioPython] Rethinking Seq objects

Michiel Jan Laurens de Hoon mdehoon at ims.u-tokyo.ac.jp
Thu May 5 03:30:50 EDT 2005


Gavin Crooks wrote:
> On May 2, 2005, at 23:45, Michiel Jan Laurens de Hoon wrote:
>> 1) Make Seq objects mutable, and get rid of MutableSeq.
> 
> Although I agree that we don't need a Seq and a MutableSeq class, I 
> don't follow why we need a mutable sequence class at all. What's the use 
> case?

Biopython itself uses a MutableSeq in various places, so there does seem to be a 
need for a mutable sequence class. However, in some places a MutableSeq is used 
where a Seq would do. As far as I can tell, Bio.GA and Bio.NeuralNetwork 
actually use the MutableSeq class; in this case, a simple array might work also. 
So maybe there is not much use for a mutable Seq class.

I'm a bit hesitant though to simply throw out MutableSeq, so I'd like to ask our 
users:
Can you give an example where you can't use an (immutable) Seq, but have to use 
a MutableSeq?

> If, in the alternative, Seq was a simple immutable object then it could 
> be implemented as a light weight subclass of str, with an alphabet 
> attribute that is also a subclass of str. You'd edit it like you would 
> edit any string in python;  split it into a list, do whatever 
> manipulations are necessary, and then join the list back together into a 
> new Seq.

There may be performance issues with this approach, if a Seq object is mutated 
often. So let's wait and see if any of our users actually want to mutate a 
sequence object, and if so, if the performance is critical.

--Michiel.


-- 
Michiel de Hoon, Assistant Professor
University of Tokyo, Institute of Medical Science
Human Genome Center
4-6-1 Shirokane-dai, Minato-ku
Tokyo 108-8639
Japan
http://bonsai.ims.u-tokyo.ac.jp/~mdehoon


More information about the BioPython mailing list