Commit e4022a59 authored by peastman's avatar peastman
Browse files

Minor improvements to loading PDBx files

parent b32e5832
...@@ -91,6 +91,7 @@ class PDBxFile(object): ...@@ -91,6 +91,7 @@ class PDBxFile(object):
lastResId = None lastResId = None
lastAsymId = None lastAsymId = None
atomTable = {} atomTable = {}
atomsInResidue = set()
models = [] models = []
for row in atomData.getRowList(): for row in atomData.getRowList():
atomKey = ((row[resIdCol], row[asymIdCol], row[atomNameCol])) atomKey = ((row[resIdCol], row[asymIdCol], row[atomNameCol]))
...@@ -108,17 +109,16 @@ class PDBxFile(object): ...@@ -108,17 +109,16 @@ class PDBxFile(object):
if lastChainId != row[chainIdCol]: if lastChainId != row[chainIdCol]:
# The start of a new chain. # The start of a new chain.
chain = top.addChain(row[chainIdCol]) chain = top.addChain(row[asymIdCol])
lastChainId = row[chainIdCol] lastChainId = row[chainIdCol]
lastResId = None lastResId = None
lastAsymId = None lastAsymId = None
if lastResId != row[resIdCol] or lastAsymId != row[asymIdCol]: if lastResId != row[resIdCol] or lastAsymId != row[asymIdCol] or (lastResId == '.' and row[atomNameCol] in atomsInResidue):
# The start of a new residue. # The start of a new residue.
res = top.addResidue(row[resNameCol], chain, None if resNumCol == -1 else row[resNumCol]) res = top.addResidue(row[resNameCol], chain, None if resNumCol == -1 else row[resNumCol])
lastResId = row[resIdCol] lastResId = row[resIdCol]
if lastResId == '.':
lastResId = None
lastAsymId = row[asymIdCol] lastAsymId = row[asymIdCol]
atomsInResidue.clear()
element = None element = None
try: try:
element = elem.get_by_symbol(row[elementCol]) element = elem.get_by_symbol(row[elementCol])
...@@ -126,6 +126,7 @@ class PDBxFile(object): ...@@ -126,6 +126,7 @@ class PDBxFile(object):
pass pass
atom = top.addAtom(row[atomNameCol], element, res, row[atomIdCol]) atom = top.addAtom(row[atomNameCol], element, res, row[atomIdCol])
atomTable[atomKey] = atom atomTable[atomKey] = atom
atomsInResidue.add(row[atomNameCol])
else: else:
# This row defines coordinates for an existing atom in one of the later models. # This row defines coordinates for an existing atom in one of the later models.
......
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