[Biopython-dev] [Bug 1936] New: Bio.PDB.PDBParser throws PDBException, 'No parent' in error

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Sun Jan 22 12:09:50 EST 2006


http://bugzilla.open-bio.org/show_bug.cgi?id=1936

           Summary: Bio.PDB.PDBParser throws PDBException, 'No parent' in
                    error
           Product: Biopython
           Version: Not Applicable
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main Distribution
        AssignedTo: biopython-dev at biopython.org
        ReportedBy: biopython-bugzilla at maubp.freeserve.co.uk


Tested on Linux with Python 2.4, BioPython 1.41

I have also updated the Bio/PDB/ directory to CVS, and the problem is the same.

Test script using file 5NUL.pdb which was downloaded from the the PDB (one of
several files which will trigger this error):

from Bio.PDB.PDBParser import PDBParser
parser=PDBParser(PERMISSIVE=True)
pdb = "5NUL"
filename = pdb + ".pdb"
structure=parser.get_structure(pdb, filename)
print structure.id
for model in structure :
    for chain in model :
        print "%s:%i:%s" % (structure.id,model.id,chain.id)


Traceback (most recent call last):
  File "/home/maubp/ramachandran/test_bio.py", line 5, in -toplevel-
    structure=parser.get_structure(pdb, filename)
  File "/usr/lib/python2.4/site-packages/Bio/PDB/PDBParser.py", line 66, in
get_structure
    self._parse(file.readlines())
  File "/usr/lib/python2.4/site-packages/Bio/PDB/PDBParser.py", line 87, in
_parse
    self.trailer=self._parse_coordinates(coords_trailer)
  File "/usr/lib/python2.4/site-packages/Bio/PDB/PDBParser.py", line 179, in
_parse_coordinates
    structure_builder.init_residue(resname, hetero_flag, resseq, icode)
  File "/usr/lib/python2.4/site-packages/Bio/PDB/StructureBuilder.py", line
155, in init_residue
    self.chain.add(residue)
  File "/usr/lib/python2.4/site-packages/Bio/PDB/Entity.py", line 80, in add
    raise PDBConstructionException, "%s defined twice" % entity.get_full_id()
  File "/usr/lib/python2.4/site-packages/Bio/PDB/Entity.py", line 132, in
get_full_id
    parent=self.get_parent()
  File "/usr/lib/python2.4/site-packages/Bio/PDB/Entity.py", line 102, in
get_parent
    raise PDBException, 'No parent'
PDBException: No parent

It looks like it tries to raise a PDBConstructionException for some entity
being defined twice, but getting the full ID for the exception message fails.

Possible fix in Bio/PDB/Entity.py class Entity add method:

def add(self, entity):
    "Add a child to the Entity."
    entity_id=entity.get_id()
    if self.has_id(entity_id):
        #PJC change
        #raise PDBConstructionException, \
        #"%s defined twice" % entity.get_full_id()
        try :
            full_id = entity.get_full_id()
        except:
            full_id = "%s/%s/%s" % entity_id
        raise PDBConstructionException, "%s defined twice" % full_id
    entity.set_parent(self)
    self.child_list.append(entity)
    #self.child_list.sort(self._sort)
    self.child_dict[entity_id]=entity


Results in this output from my example:

PDBConstructionException: W/285/  defined twice at line 1684.
Exception ignored.
Some atoms or residues will be missing in the data structure.
PDBConstructionException: Atom O defined twice in residue <Residue HOH het=W
resseq=589 icode= > at line 1684.
Exception ignored.
Some atoms or residues will be missing in the data structure.
5NUL
5NUL:0:




------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


More information about the Biopython-dev mailing list