[Biopython-dev] Bio.PDB on Python 3

Peter biopython at maubp.freeserve.co.uk
Tue Aug 24 08:06:15 EDT 2010


On Mon, Aug 16, 2010 at 2:47 PM, Peter <biopython at maubp.freeserve.co.uk> wrote:
> Hi all,
>
> A while back I installed NumPy from their svn under Python 3, so that I
> could test more of Biopython. I hadn't really looked at Bio.PDB until
> recently because test_PDB.py depended on Bio.KDTree which needs
> some C code to be compiled (which we haven't tried yet).
>
> I recently added a few doctests to Bio/PDB/Polypeptide.py which
> showed a problem with the code using "next" as a variable name.
> This is a built in function on Python 3, taking the place of the next
> method on iterator objects. That's fixed now:
>
> http://github.com/biopython/biopython/commit/1eb48feb5520094bf7f0177be804a953024e6938
>
> In order to test more of Bio.PDB under Python 3, I have just split
> test_PDB.py into two, creating a small test_PDB_KDtree.py file
> for the neighbour search functionality which requires the C code.
>
> This has revealed there are at least two issues with Bio.PDB to be
> addressed (see below).
>
> Peter
>
>
> ======================================================================
> ERROR: test_1_warnings (__main__.A_ExceptionTest)
> Check warnings: Parse a flawed PDB file in permissive mode.
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "/home/xxx/lib/python3.1/site-packages/Bio/PDB/PDBParser.py",
> line 200, in _parse_coordinates
>    fullname, serial_number, element)
>  File "/home/xxx/lib/python3.1/site-packages/Bio/PDB/StructureBuilder.py",
> line 232, in init_atom
>    residue.add(atom)
>  File "/home/xxx/lib/python3.1/site-packages/Bio/PDB/Residue.py",
> line 82, in add
>    "Atom %s defined twice in residue %s" % (atom_id, self))
> Bio.PDB.PDBExceptions.PDBConstructionException: Atom N defined twice
> in residue <Residue ARG het=  resseq=2 icode= >
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>  File "test_PDB.py", line 57, in test_1_warnings
>    p.get_structure("example", "PDB/a_structure.pdb")
>  File "/home/xxx/lib/python3.1/site-packages/Bio/PDB/PDBParser.py",
> line 64, in get_structure
>    self._parse(file.readlines())
>  File "/home/xxx/lib/python3.1/site-packages/Bio/PDB/PDBParser.py",
> line 84, in _parse
>    self.trailer=self._parse_coordinates(coords_trailer)
>  File "/home/xxx/lib/python3.1/site-packages/Bio/PDB/PDBParser.py",
> line 202, in _parse_coordinates
>    self._handle_PDB_exception(message, global_line_counter)
>  File "/home/xxx/lib/python3.1/site-packages/Bio/PDB/PDBParser.py",
> line 256, in _handle_PDB_exception
>    % message, PDBConstructionWarning)
>  File "test_PDB.py", line 53, in showwarning
>    all_warns.append(*args[0])
> TypeError: append() argument after * must be a sequence, not
> PDBConstructionWarning

Eric fixes this one, thanks:
http://github.com/biopython/biopython/commit/f4917021cbb8a4ed4cc72dc50a2abf0066da7131

> ======================================================================
> ERROR: test_ExposureCN (__main__.Exposure)
> HSExposureCN.
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "test_PDB.py", line 612, in setUp
>    structure=PDBParser(PERMISSIVE=True).get_structure('X', pdb_filename)
>  File "/home/xxx/lib/python3.1/site-packages/Bio/PDB/PDBParser.py",
> line 64, in get_structure
>    self._parse(file.readlines())
>  File "/home/xxx/lib/python3.1/site-packages/Bio/PDB/PDBParser.py",
> line 84, in _parse
>    self.trailer=self._parse_coordinates(coords_trailer)
>  File "/home/xxx/lib/python3.1/site-packages/Bio/PDB/PDBParser.py",
> line 200, in _parse_coordinates
>    fullname, serial_number, element)
>  File "/home/xxx/lib/python3.1/site-packages/Bio/PDB/StructureBuilder.py",
> line 185, in init_atom
>    duplicate_atom=residue[name]
> TypeError: 'DisorderedResidue' object is not subscriptable

This and the others like it remain. I haven't looked into what is wrong.

Peter



More information about the Biopython-dev mailing list