[Biopython-dev] Problem with MutableSeq

Marc Colosimo mcolosimo at mitre.org
Wed Mar 10 15:12:47 EST 2004


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:

s = my_seq.data
n = len(s)
for i in range(0, n-n%3, 3):
	print s[i:i+3]

for Seq it prints

CGC

for MutableSeq it prints things like

array('c', 'ACG')

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.





More information about the Biopython-dev mailing list