Skip to content

Commit

Permalink
Merge pull request #260 from choderalab/gaff2-template-generator
Browse files Browse the repository at this point in the history
Gaff2 template generator
  • Loading branch information
bas-rustenburg authored May 22, 2017
2 parents 638651a + 2d41b7d commit 0a07b85
Show file tree
Hide file tree
Showing 3 changed files with 6,749 additions and 6 deletions.
16 changes: 10 additions & 6 deletions openmoltools/forcefield_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def _writeMolecule(molecule, output_filename, standardize=True):
#oechem.OEWriteMolecule(ofs, molecule)
#ofs.close()

def generateResidueTemplate(molecule, residue_atoms=None, normalize=True):
def generateResidueTemplate(molecule, residue_atoms=None, normalize=True, gaff_version='gaff'):
"""
Generate an residue template for simtk.openmm.app.ForceField using GAFF/AM1-BCC.
Expand All @@ -241,12 +241,14 @@ def generateResidueTemplate(molecule, residue_atoms=None, normalize=True):
normalize : bool, optional, default=True
If True, normalize the molecule by checking aromaticity, adding
explicit hydrogens, and renaming by IUPAC name.
gaff_version : str, default = 'gaff'
One of ['gaff', 'gaff2']; selects which atom types to use.
Returns
-------
template : simtk.openmm.app.forcefield._TemplateData
Residue template for ForceField using atom types and parameters from `gaff.xml`.
Residue template for ForceField using atom types and parameters from `gaff.xml` or `gaff2.xml`.
additional_parameters_ffxml : str
Contents of ForceField `ffxml` file defining additional parameters from parmchk(2).
Expand Down Expand Up @@ -285,7 +287,7 @@ def generateResidueTemplate(molecule, residue_atoms=None, normalize=True):
_writeMolecule(molecule, input_mol2_filename, standardize=normalize)

# Parameterize the molecule with antechamber.
run_antechamber(template_name, input_mol2_filename, charge_method=None, net_charge=net_charge, gaff_mol2_filename=gaff_mol2_filename, frcmod_filename=frcmod_filename)
run_antechamber(template_name, input_mol2_filename, charge_method=None, net_charge=net_charge, gaff_mol2_filename=gaff_mol2_filename, frcmod_filename=frcmod_filename, gaff_version=gaff_version)

# Read the resulting GAFF mol2 file as a ParmEd structure.
from openeye import oechem
Expand Down Expand Up @@ -341,7 +343,7 @@ def generateResidueTemplate(molecule, residue_atoms=None, normalize=True):
return template, ffxml.getvalue()


def generateForceFieldFromMolecules(molecules, ignoreFailures=False, generateUniqueNames=False, normalize=True):
def generateForceFieldFromMolecules(molecules, ignoreFailures=False, generateUniqueNames=False, normalize=True, gaff_version='gaff'):
"""
Generate ffxml file containing additional parameters and residue templates for simtk.openmm.app.ForceField using GAFF/AM1-BCC.
Expand All @@ -361,7 +363,9 @@ def generateForceFieldFromMolecules(molecules, ignoreFailures=False, generateUni
If True, will generate globally unique names for templates.
normalize : bool, optional, default=True
If True, normalize the molecule by checking aromaticity, adding
explicit hydrogens, and renaming by IUPAC name.
explicit hydrogens, and renaming by IUPAC name.
gaff_version : str, default = 'gaff'
One of ['gaff', 'gaff2']; selects which atom types to use.
Returns
-------
Expand Down Expand Up @@ -430,7 +434,7 @@ def generateForceFieldFromMolecules(molecules, ignoreFailures=False, generateUni
_writeMolecule(molecule, input_mol2_filename, standardize=normalize)

# Parameterize the molecule with antechamber.
run_antechamber(prefix, input_mol2_filename, charge_method=None, net_charge=net_charge, gaff_mol2_filename=gaff_mol2_filename, frcmod_filename=frcmod_filename)
run_antechamber(prefix, input_mol2_filename, charge_method=None, net_charge=net_charge, gaff_mol2_filename=gaff_mol2_filename, frcmod_filename=frcmod_filename, gaff_version=gaff_version)

# Append to leaprc input for parmed.
leaprc += '%s = loadmol2 %s\n' % (prefix, gaff_mol2_filename)
Expand Down
Loading

0 comments on commit 0a07b85

Please sign in to comment.