[Biopython-dev] test_AlignIO to python 3
Peter Cock
p.j.a.cock at googlemail.com
Mon Jul 5 11:26:36 UTC 2010
2010/7/5 Tiago Antão <tiagoantao at gmail.com>:
> Hi,
>
> 2010/7/5 Peter Cock <p.j.a.cock at googlemail.com>:
>> I think Python 2.4 added support for the key argument, so can we
>> just unconditionally change it to:
>>
>> possible.sort(key=lambda x:self.ambiguous_protein[x])
>>
>> However, that isn't doing quite the same thing. The old sort was by
>> table length first to try and get the least ambiguous mapping or
>> something like that... we probably need some more unit tests first.
>
> erm, my mistake
> possible.sort(key=lambda x:len(self.ambiguous_protein[x]))
>
> I think this sorts this out?
Probably.
>> This is within our private _maketrans function only? That looks sensible
>> but I wonder why 2to3 doesn't handle this on its own.
>
> Because (I think), there are now 2 possible alternatives (one
> byte-wise and one string-wise), so 2to3 does not know which to choose.
True.
>> Would moving the "import string" into the function help for clarity?
>
> It it is only used there, maybe it makes sense.
OK.
>>> 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
>>
>> A lot of the things using sgmllib are already deprecated (e.g.
>> Bio.NetCatch and Bio.Prosite). I think that leaves just Bio.UniGene
>> and Bio.InterPro - which isn't such a big issue.
>
> I know very little about those parts of the code, but there was an
> import required for sgmllib in test_AlignIO.
This is due to Bio/File.py trying to import sgmllib, and Bio.File is used
by several of the SeqIO/AlignIO parsers (e.g. Bio.GenBank). That
code needing sgmllib was deprecated in Biopython 1.52 (Sept 2009),
and so we should be keeping it until Sept 2010... I think making it a
lazy import will do the trick.
Peter
P.S. I've just committed this, so do a pull before more changes:
http://github.com/biopython/biopython/commit/4f2650c309224e74bd18758b4ee2be24879c15dd
More information about the Biopython-dev
mailing list