Commit b535e651 authored by peastman's avatar peastman
Browse files

Cleanup to PDBx/mmCIF reader

parent 2504cf1a
...@@ -44,11 +44,7 @@ except: ...@@ -44,11 +44,7 @@ except:
pass pass
class PDBxFile(object): class PDBxFile(object):
"""PDBxFile parses a PDBx/mmCIF file and constructs a Topology and a set of atom positions from it. """PDBxFile parses a PDBx/mmCIF file and constructs a Topology and a set of atom positions from it."""
This class also provides methods for creating PDBx/mmCIF files. To write a file containing a single model, call
writeFile(). You also can create files that contain multiple models. To do this, first call writeHeader(),
then writeModel() once for each model in the file, and finally writeFooter() to complete the file."""
def __init__(self, file): def __init__(self, file):
"""Load a PDBx/mmCIF file. """Load a PDBx/mmCIF file.
...@@ -93,7 +89,8 @@ class PDBxFile(object): ...@@ -93,7 +89,8 @@ class PDBxFile(object):
atomTable = {} atomTable = {}
models = [] models = []
for row in atomData.getRowList(): for row in atomData.getRowList():
atomKey = ((row[resIdCol], row[asymIdCol], row[atomNameCol])) asymId = ('A' if asymIdCol == -1 else row[asymIdCol])
atomKey = ((row[resIdCol], asymId, row[atomNameCol]))
model = ('1' if modelCol == -1 else row[modelCol]) model = ('1' if modelCol == -1 else row[modelCol])
if model not in models: if model not in models:
models.append(model) models.append(model)
...@@ -108,11 +105,11 @@ class PDBxFile(object): ...@@ -108,11 +105,11 @@ class PDBxFile(object):
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 != asymId:
# The start of a new residue. # The start of a new residue.
res = top.addResidue(row[resNameCol], chain) res = top.addResidue(row[resNameCol], chain)
lastResId = row[resIdCol] lastResId = row[resIdCol]
lastAsymId = row[asymIdCol] lastAsymId = asymId
element = None element = None
try: try:
element = elem.get_by_symbol(row[elementCol]) element = elem.get_by_symbol(row[elementCol])
......
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