[Biopython-dev] [Bug 2351] Make Seq more like a string, even subclass string?

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Thu Nov 1 08:49:44 UTC 2007


http://bugzilla.open-bio.org/show_bug.cgi?id=2351





------- Comment #9 from biopython-bugzilla at maubp.freeserve.co.uk  2007-11-01 04:49 EST -------
> For my research, I do need a mutable sequence.

Diffent work, different needs.

> > Having the basic Seq non-mutable means we can leverage existing
> > string functionality and optimizations.
> 
> Thinking this over, I can see one more pressing reason to keep the
> basic Seq immutable: If Seq is immutable, it can be used as the key
> in a dictionary, and as a member of a set. With a mutable Seq, neither
> is possible. So I guess we need to keep both a Seq and a MutableSeq class. 

Those are both good points.  The dictionary key thing is something I have used,
but hadn't thought about in my last comment.

> We'll have to write a clearer explanation though in the tutorial as to
> why two classes are needed.

Fair point.

> The array of characters approach allows us fast modification of sequences.
> On the other hand, things like taking the complement is much slower than for
> strings. I looked around a bit in the Python standard library and found that
> there already is a MutableString class (located in the UserString module).
> Since this class stores a immutable string internally, it is as fast as a
> string. So how about letting the basic Seq class inherit from string, and
> the MutableSeq class from MutableString?

That does sound sensible.  One side effect of subclassing directly is the .data
property will vanish (the internal string/array of the Seq/MutableSeq object). 
Some people will be using this (especially as it was actually used in some
older versions of the tutorial).

I propose we make the Seq/MutableSeq object act more string like (fix
str(my_seq) etc) for the next release and officially declare the .data
deprecated in the documentation.  This should be backwards compatible - expect
where anyone used the str(my_seq) to get a truncated string deliberately.  Then
shift to actual subclasses for a later release.


-- 
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