Commit 2a816abe by peastman

Fixed exception loading PDBx/mmCIF files with missing blocks

parent 6343731b
...@@ -306,40 +306,43 @@ class PDBFixer(object): ...@@ -306,40 +306,43 @@ class PDBFixer(object):
# Load the sequence data. # Load the sequence data.
sequenceData = block.getObj('entity_poly_seq') sequenceData = block.getObj('entity_poly_seq')
entityIdCol = sequenceData.getAttributeIndex('entity_id')
residueCol = sequenceData.getAttributeIndex('mon_id')
sequences = {} sequences = {}
for row in sequenceData.getRowList(): if sequenceData is not None:
entityId = row[entityIdCol] entityIdCol = sequenceData.getAttributeIndex('entity_id')
residue = row[residueCol] residueCol = sequenceData.getAttributeIndex('mon_id')
if entityId not in sequences: for row in sequenceData.getRowList():
sequences[entityId] = [] entityId = row[entityIdCol]
sequences[entityId].append(residue) residue = row[residueCol]
if entityId not in sequences:
sequences[entityId] = []
sequences[entityId].append(residue)
# Sequences are stored by "entity". There could be multiple chains that are all the same entity, so we need to # Sequences are stored by "entity". There could be multiple chains that are all the same entity, so we need to
# convert from entities to chains. # convert from entities to chains.
asymData = block.getObj('struct_asym') asymData = block.getObj('struct_asym')
asymIdCol = asymData.getAttributeIndex('id') if asymData is not None:
entityIdCol = asymData.getAttributeIndex('entity_id') self.sequences = []
self.sequences = [] asymIdCol = asymData.getAttributeIndex('id')
for row in asymData.getRowList(): entityIdCol = asymData.getAttributeIndex('entity_id')
asymId = row[asymIdCol] for row in asymData.getRowList():
entityId = row[entityIdCol] asymId = row[asymIdCol]
if entityId in sequences: entityId = row[entityIdCol]
self.sequences.append(Sequence(asymId, sequences[entityId])) if entityId in sequences:
self.sequences.append(Sequence(asymId, sequences[entityId]))
# Load the modified residues. # Load the modified residues.
modData = block.getObj('pdbx_struct_mod_residue') modData = block.getObj('pdbx_struct_mod_residue')
asymIdCol = modData.getAttributeIndex('label_asym_id')
resNameCol = modData.getAttributeIndex('label_comp_id')
resNumCol = modData.getAttributeIndex('auth_seq_id')
standardResCol = modData.getAttributeIndex('parent_comp_id')
self.modifiedResidues = [] self.modifiedResidues = []
if -1 not in (asymIdCol, resNameCol, resNumCol, standardResCol): if modData is not None:
for row in modData.getRowList(): asymIdCol = modData.getAttributeIndex('label_asym_id')
self.modifiedResidues.append(ModifiedResidue(row[asymIdCol], int(row[resNumCol]), row[resNameCol], row[standardResCol])) resNameCol = modData.getAttributeIndex('label_comp_id')
resNumCol = modData.getAttributeIndex('auth_seq_id')
standardResCol = modData.getAttributeIndex('parent_comp_id')
if -1 not in (asymIdCol, resNameCol, resNumCol, standardResCol):
for row in modData.getRowList():
self.modifiedResidues.append(ModifiedResidue(row[asymIdCol], int(row[resNumCol]), row[resNameCol], row[standardResCol]))
def _addAtomsToTopology(self, heavyAtomsOnly, omitUnknownMolecules): def _addAtomsToTopology(self, heavyAtomsOnly, omitUnknownMolecules):
"""Create a new Topology in which missing atoms have been added. """Create a new Topology in which missing atoms have been added.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment