[Biopython-dev] test_AlignIO to python 3
Tiago Antão
tiagoantao at gmail.com
Mon Jul 5 10:34:17 UTC 2010
Hi,
test_AlignIO provides a far more interesting case (but not
complicated, not at all).
The issues are as follows:
1. list sorting
Bio.Data.CodonTable has a:
possible.sort(_sort)
Py3 has no compare function (that _sort is a 5 line function defined
just above). That can be "forced in", but there is normally a simpler
dialect, with keywords. The line above becomes:
if sys.version_info[0] == 3:
possible.sort(key=lambda x:self.ambiguous_protein[x])
else:
possible.sort(_sort)
2. Strings and bytes
Bio.Seq requires
if sys.version_info[0] == 3 :
return str.maketrans(before, after)
else:
return string.maketrans(before, after)
The way p3 handles strings and bytes are the biggest issue that I
think we will face from a technical perspective.
3. The big one: No sgmllib in p3.
The obvious solution is to include it (I suppose the licenses are
compatible?). The alternative (using htmllib) might be more long-term,
in my opinion
This is all that is needed (plus 1 import sys line).
I was inclined to commit 1 and 2. But 3 needs to be discussed...
Tiago
More information about the Biopython-dev
mailing list