Commit 6c1caa96 by peastman Committed by GitHub

Merge pull request #168 from peastman/single

Fixed error when a file contains only one residue
parents 733dc3ae 13a801ab
......@@ -928,25 +928,26 @@ class PDBFixer(object):
context.setPositions(newPositions)
mm.LocalEnergyMinimizer.minimize(context)
state = context.getState(getPositions=True)
nearest = self._findNearestDistance(context, newTopology, newAtoms)
if nearest < 0.13:
# Some atoms are very close together. Run some dynamics while slowly increasing the strength of the
# repulsive interaction to try to improve the result.
for i in range(10):
context.setParameter('C', 0.15*(i+1))
integrator.step(200)
d = self._findNearestDistance(context, newTopology, newAtoms)
if d > nearest:
nearest = d
state = context.getState(getPositions=True)
if nearest >= 0.13:
break
context.setState(state)
context.setParameter('C', 1.0)
mm.LocalEnergyMinimizer.minimize(context)
state = context.getState(getPositions=True)
if newTopology.getNumResidues() > 1:
nearest = self._findNearestDistance(context, newTopology, newAtoms)
if nearest < 0.13:
# Some atoms are very close together. Run some dynamics while slowly increasing the strength of the
# repulsive interaction to try to improve the result.
for i in range(10):
context.setParameter('C', 0.15*(i+1))
integrator.step(200)
d = self._findNearestDistance(context, newTopology, newAtoms)
if d > nearest:
nearest = d
state = context.getState(getPositions=True)
if nearest >= 0.13:
break
context.setState(state)
context.setParameter('C', 1.0)
mm.LocalEnergyMinimizer.minimize(context)
state = context.getState(getPositions=True)
# Now create a new Topology, including all atoms from the original one and adding the missing atoms.
......
......@@ -10,9 +10,10 @@ def test_mutate_1():
fixer.findMissingAtoms()
fixer.addMissingAtoms()
fixer.addMissingHydrogens(7.0)
temp_pdb = tempfile.NamedTemporaryFile(mode='w+')
app.PDBFile.writeFile(fixer.topology, fixer.positions, temp_pdb)
pdb = app.PDBFile(temp_pdb.name)
with tempfile.NamedTemporaryFile(mode='w+') as temp_pdb:
app.PDBFile.writeFile(fixer.topology, fixer.positions, temp_pdb)
temp_pdb.flush()
pdb = app.PDBFile(temp_pdb.name)
new_residue57 = list(fixer.topology.residues())[16]
assert new_residue57.name == "GLY", "Name of mutated residue did not change correctly!"
......
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