[Biopython-dev] Bio.PDB on Python 3

Peter biopython at maubp.freeserve.co.uk
Mon Aug 16 13:47:30 UTC 2010


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

======================================================================
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

======================================================================
ERROR: test_HSExposureCA (__main__.Exposure)
HSExposureCA.
----------------------------------------------------------------------
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

======================================================================
ERROR: test_HSExposureCB (__main__.Exposure)
HSExposureCB.
----------------------------------------------------------------------
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

======================================================================
ERROR: test_c_n (__main__.ParseTest)
Extract polypeptides using C-N.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_PDB.py", line 138, in setUp
    self.structure = 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 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

======================================================================
ERROR: test_ca_ca (__main__.ParseTest)
Extract polypeptides using CA-CA.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_PDB.py", line 138, in setUp
    self.structure = 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 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

======================================================================
ERROR: test_details (__main__.ParseTest)
Verify details of the parsed example PDB file.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_PDB.py", line 138, in setUp
    self.structure = 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 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

======================================================================
ERROR: test_structure (__main__.ParseTest)
Verify the structure of the parsed example PDB file.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_PDB.py", line 138, in setUp
    self.structure = 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 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

----------------------------------------------------------------------
Ran 14 tests in 1.205s

FAILED (errors=8)



More information about the Biopython-dev mailing list