[Biopython-dev] Problem with MutableSeq
Brad Chapman
chapmanb at uga.edu
Wed Mar 17 20:13:41 EST 2004
Hi Marc;
Thanks for the feedback on the documentation and MutableSeq. Sorry
for the delay in responding -- I've been out of town and am just
getting myself back together.
> I've been banging my head against my monitor over this for awhile. Here
> is the problem (using stuff from
> <http://www.biopython.org/docs/tutorial/Tutorial003.html#toc5>)
>
> I want to reverse my DNA Seq object, so I did this:
>
> mut_seq = my_seq.tomutable()
> mut_seq.reverse()
> my_seq = mut_seq
>
> I thought these behaved the same (silly me). Later on I translate it,
> however, I get a TypeError!
>
> I had to pull out the code to see what the hell was going on because
> print my_seq looks fine.
>
> The problem is that MutableSeq.data is an array whereas Seq.data is
> real data. So when you do this:
[...]
> which is a TypeError!!! This should be put in the doc that you need to
> call the lonely method .toseq to get back a real sequence. Or change
> MutableSeq.data to MutableSeq.array_data and make MutableSeq.data a
> string.
Yes, I definitely agree that this is confusing. When Andrew
implemented MutableSeq it uses the array to represent the sequence
instead of strings, as you correctly point out. This does confuse
things because many of the functions that deal with sequences aren't
set up to deal with both arrays and strings for the data object.
I do think the real answer to fix the problem is to adjust the docs
so they make this clear in the transition between the mutable seq
part and the translation part.
I am currently trying to re-do documentation into a more small sized
cookbook format, to make it easier to maintain and update (and for
people to contribute :-). I will try to put it on my list to pull
out this section and update it to avoid this kind of problem.
Sorry for the frustration and thanks for sharing your experience so
we can make the documentation better.
Brad
More information about the Biopython-dev
mailing list