"platforms/brook/tests/TestBrookHarmonicBondForce.cpp" did not exist on "8c3878b27503402cf889d7a06feb9115cc1724ed"
Commit ed57e864 authored by João Rodrigues's avatar João Rodrigues
Browse files

Fix position of existing atoms on addHydrogens()

parent c7441b96
......@@ -712,6 +712,8 @@ class Modeller(object):
automatically, this function will only add hydrogens. It will never remove ones that are already present in the
model, regardless of the specified pH.
In all cases, the positions of existing atoms (including existing hydrogens) are not modified.
Definitions for standard amino acids and nucleotides are built in. You can call loadHydrogenDefinitions() to load
additional definitions for other residue types.
......@@ -930,14 +932,16 @@ class Modeller(object):
# The hydrogens were added at random positions. Now perform an energy minimization to fix them up.
addedH = set(newIndices) # keep track of Hs added
if forcefield is not None:
# Use the ForceField the user specified.
system = forcefield.createSystem(newTopology, rigidWater=False, nonbondedMethod=CutoffNonPeriodic)
atoms = list(newTopology.atoms())
for i in range(system.getNumParticles()):
if atoms[i].element != elem.hydrogen:
# This is a heavy atom, so make it immobile.
if i not in addedH:
# Existing atom, make it immobile.
system.setParticleMass(i, 0)
else:
# Create a System that restrains the distance of each hydrogen from its parent atom
......@@ -955,7 +959,7 @@ class Modeller(object):
bondedTo = []
for atom in newTopology.atoms():
nonbonded.addParticle([])
if atom.element != elem.hydrogen:
if atom.index not in addedH: # make immobile
system.addParticle(0.0)
else:
system.addParticle(1.0)
......
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