"...reference/src/SimTKReference/ReferenceCCMAAlgorithm.cpp" did not exist on "76e2849ccf0aea4dd118a77e8d7d7e66b1107ab0"
Commit d7e7c69e authored by Jason Swails's avatar Jason Swails
Browse files

Make the nonpolar part of GBSA available via an input parameter to

createSystem for both Amber and CHARMM files.
parent cab098d7
...@@ -161,7 +161,7 @@ class AmberPrmtopFile(object): ...@@ -161,7 +161,7 @@ class AmberPrmtopFile(object):
implicitSolventKappa=None, temperature=298.15*u.kelvin, implicitSolventKappa=None, temperature=298.15*u.kelvin,
soluteDielectric=1.0, solventDielectric=78.5, soluteDielectric=1.0, solventDielectric=78.5,
removeCMMotion=True, hydrogenMass=None, ewaldErrorTolerance=0.0005, removeCMMotion=True, hydrogenMass=None, ewaldErrorTolerance=0.0005,
switchDistance=0.0*u.nanometer): switchDistance=0.0*u.nanometer, gbsaModel='ACE'):
"""Construct an OpenMM System representing the topology described by this """Construct an OpenMM System representing the topology described by this
prmtop file. prmtop file.
...@@ -208,6 +208,11 @@ class AmberPrmtopFile(object): ...@@ -208,6 +208,11 @@ class AmberPrmtopFile(object):
turned on for Lennard-Jones interactions. If the switchDistance is 0 turned on for Lennard-Jones interactions. If the switchDistance is 0
or evaluates to boolean False, no switching function will be used. or evaluates to boolean False, no switching function will be used.
Values greater than nonbondedCutoff or less than 0 raise ValueError Values greater than nonbondedCutoff or less than 0 raise ValueError
gbsaModel : str='ACE'
The SA model used to model the nonpolar solvation component of GB
implicit solvent models. If GB is active, this must be 'ACE' or None
(the latter indicates no SA model will be used). Other values will
result in a ValueError
Returns Returns
------- -------
...@@ -273,7 +278,7 @@ class AmberPrmtopFile(object): ...@@ -273,7 +278,7 @@ class AmberPrmtopFile(object):
nonbondedCutoff=nonbondedCutoff, nonbondedMethod=methodMap[nonbondedMethod], nonbondedCutoff=nonbondedCutoff, nonbondedMethod=methodMap[nonbondedMethod],
flexibleConstraints=False, gbmodel=implicitString, soluteDielectric=soluteDielectric, flexibleConstraints=False, gbmodel=implicitString, soluteDielectric=soluteDielectric,
solventDielectric=solventDielectric, implicitSolventKappa=implicitSolventKappa, solventDielectric=solventDielectric, implicitSolventKappa=implicitSolventKappa,
rigidWater=rigidWater, elements=self.elements) rigidWater=rigidWater, elements=self.elements, gbsaModel=gbsaModel)
if hydrogenMass is not None: if hydrogenMass is not None:
for atom1, atom2 in self.topology.bonds(): for atom1, atom2 in self.topology.bonds():
......
...@@ -678,7 +678,8 @@ class CharmmPsfFile(object): ...@@ -678,7 +678,8 @@ class CharmmPsfFile(object):
hydrogenMass=None, hydrogenMass=None,
ewaldErrorTolerance=0.0005, ewaldErrorTolerance=0.0005,
flexibleConstraints=True, flexibleConstraints=True,
verbose=False): verbose=False,
gbsaModel=None):
"""Construct an OpenMM System representing the topology described by the """Construct an OpenMM System representing the topology described by the
prmtop file. You MUST have loaded a parameter set into this PSF before prmtop file. You MUST have loaded a parameter set into this PSF before
calling createSystem. If not, AttributeError will be raised. ValueError calling createSystem. If not, AttributeError will be raised. ValueError
...@@ -733,10 +734,16 @@ class CharmmPsfFile(object): ...@@ -733,10 +734,16 @@ class CharmmPsfFile(object):
Are our constraints flexible or not? Are our constraints flexible or not?
verbose : bool=False verbose : bool=False
Optionally prints out a running progress report Optionally prints out a running progress report
gbsaModel : str=None
Can be ACE (to use the ACE solvation model) or None. Other values
raise a ValueError
""" """
# Load the parameter set # Load the parameter set
self.loadParameters(params.condense()) self.loadParameters(params.condense())
hasbox = self.topology.getUnitCellDimensions() is not None hasbox = self.topology.getUnitCellDimensions() is not None
# Check GB input parameters
if implicitSolvent is not None and gbsaModel not in ('ACE', None):
raise ValueError('gbsaModel must be ACE or None')
# Set the cutoff distance in nanometers # Set the cutoff distance in nanometers
cutoff = None cutoff = None
if nonbondedMethod is not ff.NoCutoff: if nonbondedMethod is not ff.NoCutoff:
...@@ -1189,19 +1196,19 @@ class CharmmPsfFile(object): ...@@ -1189,19 +1196,19 @@ class CharmmPsfFile(object):
implicitSolventKappa = implicitSolventKappa.value_in_unit( implicitSolventKappa = implicitSolventKappa.value_in_unit(
(1.0/u.nanometer).unit) (1.0/u.nanometer).unit)
if implicitSolvent is HCT: if implicitSolvent is HCT:
gb = GBSAHCTForce(solventDielectric, soluteDielectric, None, gb = GBSAHCTForce(solventDielectric, soluteDielectric, gbsaModel,
cutoff, kappa=implicitSolventKappa) cutoff, kappa=implicitSolventKappa)
elif implicitSolvent is OBC1: elif implicitSolvent is OBC1:
gb = GBSAOBC1Force(solventDielectric, soluteDielectric, None, gb = GBSAOBC1Force(solventDielectric, soluteDielectric, gbsaModel,
cutoff, kappa=implicitSolventKappa) cutoff, kappa=implicitSolventKappa)
elif implicitSolvent is OBC2: elif implicitSolvent is OBC2:
gb = GBSAOBC2Force(solventDielectric, soluteDielectric, None, gb = GBSAOBC2Force(solventDielectric, soluteDielectric, gbsaModel,
cutoff, kappa=implicitSolventKappa) cutoff, kappa=implicitSolventKappa)
elif implicitSolvent is GBn: elif implicitSolvent is GBn:
gb = GBSAGBnForce(solventDielectric, soluteDielectric, None, gb = GBSAGBnForce(solventDielectric, soluteDielectric, gbsaModel,
cutoff, kappa=implicitSolventKappa) cutoff, kappa=implicitSolventKappa)
elif implicitSolvent is GBn2: elif implicitSolvent is GBn2:
gb = GBSAGBn2Force(solventDielectric, soluteDielectric, None, gb = GBSAGBn2Force(solventDielectric, soluteDielectric, gbsaModel,
cutoff, kappa=implicitSolventKappa) cutoff, kappa=implicitSolventKappa)
gb_parms = gb.getStandardParameters(self.topology) gb_parms = gb.getStandardParameters(self.topology)
for atom, gb_parm in zip(self.atom_list, gb_parms): for atom, gb_parm in zip(self.atom_list, gb_parms):
......
...@@ -525,7 +525,7 @@ class PrmtopLoader(object): ...@@ -525,7 +525,7 @@ class PrmtopLoader(object):
iScnb = float(self._raw_data["SCNB_SCALE_FACTOR"][iidx]) iScnb = float(self._raw_data["SCNB_SCALE_FACTOR"][iidx])
except KeyError: except KeyError:
iScnb = 2.0 iScnb = 2.0
returnList.append((iAtom, lAtom, chargeProd, rMin, epsilon, iScee, iScnb)) returnList.append((iAtom, lAtom, chargeProd, rMin, epsilon, iScee, iScnb))
return returnList return returnList
...@@ -579,7 +579,8 @@ def readAmberSystem(topology, prmtop_filename=None, prmtop_loader=None, shake=No ...@@ -579,7 +579,8 @@ def readAmberSystem(topology, prmtop_filename=None, prmtop_loader=None, shake=No
soluteDielectric=1.0, solventDielectric=78.5, soluteDielectric=1.0, solventDielectric=78.5,
implicitSolventKappa=0.0*(1/units.nanometer), nonbondedCutoff=None, implicitSolventKappa=0.0*(1/units.nanometer), nonbondedCutoff=None,
nonbondedMethod='NoCutoff', scee=None, scnb=None, mm=None, verbose=False, nonbondedMethod='NoCutoff', scee=None, scnb=None, mm=None, verbose=False,
EwaldErrorTolerance=None, flexibleConstraints=True, rigidWater=True, elements=None): EwaldErrorTolerance=None, flexibleConstraints=True, rigidWater=True, elements=None,
gbsaModel='ACE'):
""" """
Create an OpenMM System from an Amber prmtop file. Create an OpenMM System from an Amber prmtop file.
...@@ -603,6 +604,7 @@ def readAmberSystem(topology, prmtop_filename=None, prmtop_loader=None, shake=No ...@@ -603,6 +604,7 @@ def readAmberSystem(topology, prmtop_filename=None, prmtop_loader=None, shake=No
verbose (boolean) - if True, print out information on progress (default: False) verbose (boolean) - if True, print out information on progress (default: False)
flexibleConstraints (boolean) - if True, flexible bonds will be added in addition ot constrained bonds flexibleConstraints (boolean) - if True, flexible bonds will be added in addition ot constrained bonds
rigidWater (boolean=True) If true, water molecules will be fully rigid regardless of the value passed for the shake argument rigidWater (boolean=True) If true, water molecules will be fully rigid regardless of the value passed for the shake argument
gbsaModel (str='ACE') The string representing the SA model to use for GB calculations. Must be 'ACE' or None
NOTES NOTES
...@@ -648,6 +650,9 @@ def readAmberSystem(topology, prmtop_filename=None, prmtop_loader=None, shake=No ...@@ -648,6 +650,9 @@ def readAmberSystem(topology, prmtop_filename=None, prmtop_loader=None, shake=No
warnings.warn("1-4 scaling parameters in topology file are being ignored. " warnings.warn("1-4 scaling parameters in topology file are being ignored. "
"This is not recommended unless you know what you are doing.") "This is not recommended unless you know what you are doing.")
if gbmodel is not None and gbsaModel not in ('ACE', None):
raise ValueError('gbsaModel must be ACE or None')
has_1264 = 'LENNARD_JONES_CCOEF' in prmtop._raw_data.keys() has_1264 = 'LENNARD_JONES_CCOEF' in prmtop._raw_data.keys()
if has_1264: if has_1264:
parm_ccoef = [float(x) for x in prmtop._raw_data['LENNARD_JONES_CCOEF']] parm_ccoef = [float(x) for x in prmtop._raw_data['LENNARD_JONES_CCOEF']]
...@@ -1121,7 +1126,7 @@ class AmberAsciiRestart(object): ...@@ -1121,7 +1126,7 @@ class AmberAsciiRestart(object):
self.natom = int(words[0]) self.natom = int(words[0])
except (IndexError, ValueError): except (IndexError, ValueError):
raise TypeError('Unrecognized file type [%s]' % self.filename) raise TypeError('Unrecognized file type [%s]' % self.filename)
if len(words) >= 2: if len(words) >= 2:
self.time = float(words[1]) * units.picoseconds self.time = float(words[1]) * units.picoseconds
...@@ -1290,7 +1295,7 @@ class AmberNetcdfRestart(object): ...@@ -1290,7 +1295,7 @@ class AmberNetcdfRestart(object):
from scipy.io.netcdf import NetCDFFile from scipy.io.netcdf import NetCDFFile
except ImportError: except ImportError:
raise ImportError('scipy is necessary to parse NetCDF restarts') raise ImportError('scipy is necessary to parse NetCDF restarts')
self.filename = filename self.filename = filename
self.velocities = self.boxVectors = self.time = None self.velocities = self.boxVectors = self.time = None
......
...@@ -88,8 +88,8 @@ class TestAmberPrmtopFile(unittest.TestCase): ...@@ -88,8 +88,8 @@ class TestAmberPrmtopFile(unittest.TestCase):
parameter. parameter.
""" """
for implicitSolvent_value in [HCT, OBC1, OBC2, GBn]: for implicitSolvent_value, gbsa in zip([HCT, OBC1, OBC2, GBn], ['ACE', None, 'ACE', None]):
system = prmtop2.createSystem(implicitSolvent=implicitSolvent_value) system = prmtop2.createSystem(implicitSolvent=implicitSolvent_value, gbsaModel=gbsa)
forces = system.getForces() forces = system.getForces()
if implicitSolvent_value in set([HCT, OBC1, GBn]): if implicitSolvent_value in set([HCT, OBC1, GBn]):
force_type = CustomGBForce force_type = CustomGBForce
......
...@@ -60,7 +60,7 @@ class TestCharmmFiles(unittest.TestCase): ...@@ -60,7 +60,7 @@ class TestCharmmFiles(unittest.TestCase):
"""Test implicit solvent using the implicitSolvent parameter. """Test implicit solvent using the implicitSolvent parameter.
""" """
system = self.psf_v.createSystem(self.params, implicitSolvent=OBC2) system = self.psf_v.createSystem(self.params, implicitSolvent=OBC2, gbsaModel='ACE')
self.assertTrue(any(isinstance(f, CustomGBForce) for f in system.getForces())) self.assertTrue(any(isinstance(f, CustomGBForce) for f in system.getForces()))
def test_ImplicitSolventParameters(self): def test_ImplicitSolventParameters(self):
......
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