Commit e1f412f3 by peastman Committed by GitHub

Merge pull request #189 from peastman/pdbx

Fixed exception loading PDBx/mmCIF files with missing blocks
parents 6343731b 695125cc
...@@ -306,9 +306,10 @@ class PDBFixer(object): ...@@ -306,9 +306,10 @@ class PDBFixer(object):
# Load the sequence data. # Load the sequence data.
sequenceData = block.getObj('entity_poly_seq') sequenceData = block.getObj('entity_poly_seq')
sequences = {}
if sequenceData is not None:
entityIdCol = sequenceData.getAttributeIndex('entity_id') entityIdCol = sequenceData.getAttributeIndex('entity_id')
residueCol = sequenceData.getAttributeIndex('mon_id') residueCol = sequenceData.getAttributeIndex('mon_id')
sequences = {}
for row in sequenceData.getRowList(): for row in sequenceData.getRowList():
entityId = row[entityIdCol] entityId = row[entityIdCol]
residue = row[residueCol] residue = row[residueCol]
...@@ -320,9 +321,10 @@ class PDBFixer(object): ...@@ -320,9 +321,10 @@ class PDBFixer(object):
# convert from entities to chains. # convert from entities to chains.
asymData = block.getObj('struct_asym') asymData = block.getObj('struct_asym')
self.sequences = []
if asymData is not None:
asymIdCol = asymData.getAttributeIndex('id') asymIdCol = asymData.getAttributeIndex('id')
entityIdCol = asymData.getAttributeIndex('entity_id') entityIdCol = asymData.getAttributeIndex('entity_id')
self.sequences = []
for row in asymData.getRowList(): for row in asymData.getRowList():
asymId = row[asymIdCol] asymId = row[asymIdCol]
entityId = row[entityIdCol] entityId = row[entityIdCol]
...@@ -332,11 +334,12 @@ class PDBFixer(object): ...@@ -332,11 +334,12 @@ class PDBFixer(object):
# Load the modified residues. # Load the modified residues.
modData = block.getObj('pdbx_struct_mod_residue') modData = block.getObj('pdbx_struct_mod_residue')
self.modifiedResidues = []
if modData is not None:
asymIdCol = modData.getAttributeIndex('label_asym_id') asymIdCol = modData.getAttributeIndex('label_asym_id')
resNameCol = modData.getAttributeIndex('label_comp_id') resNameCol = modData.getAttributeIndex('label_comp_id')
resNumCol = modData.getAttributeIndex('auth_seq_id') resNumCol = modData.getAttributeIndex('auth_seq_id')
standardResCol = modData.getAttributeIndex('parent_comp_id') standardResCol = modData.getAttributeIndex('parent_comp_id')
self.modifiedResidues = []
if -1 not in (asymIdCol, resNameCol, resNumCol, standardResCol): if -1 not in (asymIdCol, resNameCol, resNumCol, standardResCol):
for row in modData.getRowList(): for row in modData.getRowList():
self.modifiedResidues.append(ModifiedResidue(row[asymIdCol], int(row[resNumCol]), row[resNameCol], row[standardResCol])) self.modifiedResidues.append(ModifiedResidue(row[asymIdCol], int(row[resNumCol]), row[resNameCol], row[standardResCol]))
......
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