[Biopython-dev] test_AlignIO to python 3
Peter Cock
p.j.a.cock at googlemail.com
Mon Jul 5 11:44:54 UTC 2010
2010/7/5 Tiago Antão <tiagoantao at gmail.com>:
> 2010/7/5 Peter Cock <p.j.a.cock at googlemail.com>:
>> Or just test_seq.py or test_Seq_objs.py which are more low level ;)
>
> Glad you raise these 2, as I want to discuss them.
> 2 changes:
> 1. to test_Seq_objs.py add
> import sys
> if sys.version_info[0] == 3:
> maketrans = str.maketrans
> else:
> from string import maketrans
OK, do a "git pull origin master" and then make that change (and
move the import string into the function too). It seems to be a
fairly simple way to cope with Python 2.x and Python 3.x.
> 2. (more serious) array.array("c", ...) is no more (the c).
> Maybe self.data = array.array("u", data) ? With ifs per version. This
> affects test_seq.py and Seq.py
This is the MutableSeq object, right? Try some local changes and see,
but I fear we may have to redo the internals of that more substantially.
> Regarding commits (e.g. the sort case).
> I can commit general corrections, e.g. a single sort with a key for
> all versions or put some ifs (use the old code for 2.x and new code
> for 3). The first option is cleaner, the second safer. I warm up to
> the cleaner version: the changes are trivial (and trivial to roll
> back, should the need arise).
For the codon sort case, the old code effectively did two sorts
(one by length with a tie breaker). If you can write some unit tests
to check we don't alter the behaviour, the clean fix is nicer.
Also 2to3 is suggesting we use for loops in Bio/Sequencing/Ace.py
in place of side effects with a map call (lines 474, 480, 484). That
does seem like good advice.
Peter
More information about the Biopython-dev
mailing list