Commit 4572d2e3 authored by Justin MacCallum's avatar Justin MacCallum
Browse files

Changed gb settings to use strings rather than named constants.

parent 960d2010
......@@ -40,11 +40,11 @@ import simtk.unit as unit
import simtk.openmm as mm
# Enumerated values for implicit solvent model
HCT = object()
OBC1 = object()
OBC2 = object()
GBn = object()
# Prefer to use strings now, but these are here for backwards compatibility
HCT = 'HCT'
OBC1 = 'OBC1'
OBC2 = 'OBC2'
GBn = 'GBn'
class AmberPrmtopFile(object):
"""AmberPrmtopFile parses an AMBER prmtop file and constructs a Topology and (optionally) an OpenMM System from it."""
......@@ -122,7 +122,8 @@ class AmberPrmtopFile(object):
- constraints (object=None) Specifies which bonds angles should be implemented with constraints.
Allowed values are None, HBonds, AllBonds, or HAngles.
- rigidWater (boolean=True) If true, water molecules will be fully rigid regardless of the value passed for the constraints argument
- implicitSolvent (object=None) If not None, the implicit solvent model to use. Allowed values are HCT, OBC1, OBC2, or GBn.
- implicitSolvent (object=None) If not None, the implicit solvent
model to use. Allowed values are 'HCT', 'OBC1', 'OBC2', or 'GBn'.
- soluteDielectric (float=1.0) The solute dielectric constant to use in the implicit solvent model.
- solventDielectric (float=78.5) The solvent dielectric constant to use in the implicit solvent model.
- removeCMMotion (boolean=True) If true, a CMMotionRemover will be added to the System
......@@ -148,21 +149,12 @@ class AmberPrmtopFile(object):
constraintString = constraintMap[constraints]
else:
raise ValueError('Illegal value for constraints')
if implicitSolvent is None:
implicitString = None
elif implicitSolvent == HCT:
implicitString = 'HCT'
elif implicitSolvent == OBC1:
implicitString = 'OBC1'
elif implicitSolvent == OBC2:
implicitString = 'OBC2'
elif implicitSolvent == GBn:
implicitString = 'GBn'
else:
raise ValueError('Illegal value for implicit solvent model')
sys = amber_file_parser.readAmberSystem(prmtop_loader=self._prmtop, shake=constraintString, nonbondedCutoff=nonbondedCutoff,
nonbondedMethod=methodMap[nonbondedMethod], flexibleConstraints=False, gbmodel=implicitString,
soluteDielectric=soluteDielectric, solventDielectric=solventDielectric, rigidWater=rigidWater)
sys = amber_file_parser.readAmberSystem(prmtop_loader=self._prmtop, shake=constraintString,
nonbondedCutoff=nonbondedCutoff, nonbondedMethod=methodMap[nonbondedMethod],
flexibleConstraints=False, gbmodel=implicitSolvent,
soluteDielectric=soluteDielectric, solventDielectric=solventDielectric,
rigidWater=rigidWater)
for force in sys.getForces():
if isinstance(force, mm.NonbondedForce):
force.setEwaldErrorTolerance(ewaldErrorTolerance)
......
......@@ -45,7 +45,7 @@ HBonds = ff.HBonds
AllBonds = ff.AllBonds
HAngles = ff.HAngles
OBC2 = prmtop.OBC2
OBC2 = 'OBC2'
class GromacsTopFile(object):
"""GromacsTopFile parses a Gromacs top file and constructs a Topology and (optionally) an OpenMM System from it."""
......@@ -426,7 +426,7 @@ class GromacsTopFile(object):
- constraints (object=None) Specifies which bonds and angles should be implemented with constraints.
Allowed values are None, HBonds, AllBonds, or HAngles.
- rigidWater (boolean=True) If true, water molecules will be fully rigid regardless of the value passed for the constraints argument
- implicitSolvent (object=None) If not None, the implicit solvent model to use. The only allowed value is OBC2.
- implicitSolvent (string=None) If not None, the implicit solvent model to use. The only allowed value is 'OBC2'.
- soluteDielectric (float=1.0) The solute dielectric constant to use in the implicit solvent model.
- solventDielectric (float=78.5) The solvent dielectric constant to use in the implicit solvent model.
- ewaldErrorTolerance (float=0.0005) The error tolerance to use if nonbondedMethod is Ewald or PME.
......@@ -443,7 +443,7 @@ class GromacsTopFile(object):
raise ValueError('Illegal nonbonded method for a non-periodic system')
nb = mm.NonbondedForce()
sys.addForce(nb)
if implicitSolvent is OBC2:
if implicitSolvent == 'OBC2':
gb = mm.GBSAOBCForce()
gb.setSoluteDielectric(soluteDielectric)
gb.setSolventDielectric(solventDielectric)
......@@ -656,7 +656,7 @@ class GromacsTopFile(object):
else:
q = float(params[3])
nb.addParticle(q, float(params[5]), float(params[6]))
if implicitSolvent is OBC2:
if implicitSolvent == 'OBC2':
if fields[1] not in self._implicitTypes:
raise ValueError('No implicit solvent parameters specified for atom type: '+fields[1])
gbparams = self._implicitTypes[fields[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