Commit 9025de4d authored by peastman's avatar peastman
Browse files

PDBxFile marks heterogens with HETATM

parent 36b6caa6
...@@ -400,6 +400,8 @@ class PDBxFile(object): ...@@ -400,6 +400,8 @@ class PDBxFile(object):
raise ValueError('Particle position is NaN') raise ValueError('Particle position is NaN')
if any(math.isinf(norm(pos)) for pos in positions): if any(math.isinf(norm(pos)) for pos in positions):
raise ValueError('Particle position is infinite') raise ValueError('Particle position is infinite')
nonHeterogens = PDBFile._standardResidues[:]
nonHeterogens.remove('HOH')
atomIndex = 1 atomIndex = 1
posIndex = 0 posIndex = 0
for (chainIndex, chain) in enumerate(topology.chains()): for (chainIndex, chain) in enumerate(topology.chains()):
...@@ -415,14 +417,18 @@ class PDBxFile(object): ...@@ -415,14 +417,18 @@ class PDBxFile(object):
else: else:
resId = resIndex + 1 resId = resIndex + 1
resIC = '.' resIC = '.'
if res.name in nonHeterogens:
recordName = "ATOM"
else:
recordName = "HETATM"
for atom in res.atoms(): for atom in res.atoms():
coords = positions[posIndex] coords = positions[posIndex]
if atom.element is not None: if atom.element is not None:
symbol = atom.element.symbol symbol = atom.element.symbol
else: else:
symbol = '?' symbol = '?'
line = "ATOM %5d %-3s %-4s . %-4s %s ? %5s %s %10.4f %10.4f %10.4f 0.0 0.0 ? ? ? ? ? . %5s %4s %s %4s %5d" line = "%s %5d %-3s %-4s . %-4s %s ? %5s %s %10.4f %10.4f %10.4f 0.0 0.0 ? ? ? ? ? . %5s %4s %s %4s %5d"
print(line % (atomIndex, symbol, atom.name, res.name, chainName, resId, resIC, coords[0], coords[1], coords[2], print(line % (recordName, atomIndex, symbol, atom.name, res.name, chainName, resId, resIC, coords[0], coords[1], coords[2],
resId, res.name, chainName, atom.name, modelIndex), file=file) resId, res.name, chainName, atom.name, modelIndex), file=file)
posIndex += 1 posIndex += 1
atomIndex += 1 atomIndex += 1
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