Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def generate_gaff_xml():
"""
Return a file-like object for `gaff.xml`
"""
#TODO this function isn't used anywhere
from openmoltools import amber
gaff_dat_filename = amber.find_gaff_dat()
# Generate ffxml file contents for parmchk-generated frcmod output.
leaprc = StringIO("parm = loadamberparams %s" % gaff_dat_filename)
import parmed
params = parmed.amber.AmberParameterSet.from_leaprc(leaprc)
params = parmed.openmm.OpenMMParameterSet.from_parameterset(params)
citations = """\
Wang, J., Wang, W., Kollman P. A.; Case, D. A. "Automatic atom type and bond type perception in molecular mechanical calculations". Journal of Molecular Graphics and Modelling , 25, 2006, 247260.
Wang, J., Wolf, R. M.; Caldwell, J. W.;Kollman, P. A.; Case, D. A. "Development and testing of a general AMBER force field". Journal of Computational Chemistry, 25, 2004, 1157-1174.
"""
ffxml = str()
gaff_xml = StringIO(ffxml)
provenance=dict(OriginalFile='gaff.dat', Reference=citations)
params.write(gaff_xml, provenance=provenance)
return gaff_xml
charge = atom.GetPartialCharge()
parameters = { 'charge' : charge }
atom_template = ForceField._TemplateAtomData(atomname, typename, element, parameters)
template.atoms.append(atom_template)
for bond in molecule.GetBonds():
if (bond.GetBgn() in residue_atoms) and (bond.GetEnd() in residue_atoms):
template.addBondByName(bond.GetBgn().GetName(), bond.GetEnd().GetName())
elif (bond.GetBgn() in residue_atoms) and (bond.GetEnd() not in residue_atoms):
template.addExternalBondByName(bond.GetBgn().GetName())
elif (bond.GetBgn() not in residue_atoms) and (bond.GetEnd() in residue_atoms):
template.addExternalBondByName(bond.GetEnd().GetName())
# Generate ffxml file contents for parmchk-generated frcmod output.
leaprc = StringIO('parm = loadamberparams %s' % frcmod_filename)
params = parmed.amber.AmberParameterSet.from_leaprc(leaprc)
params = parmed.openmm.OpenMMParameterSet.from_parameterset(params, remediate_residues=False)
ffxml = StringIO()
params.write(ffxml)
return template, ffxml.getvalue()
frcmod_filename = prefix + '.frcmod'
# Write Tripos mol2 file as antechamber input.
_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, gaff_version=gaff_version, resname=True)
# Append to leaprc input for parmed.
leaprc += '%s = loadmol2 %s\n' % (prefix, gaff_mol2_filename)
leaprc += 'loadamberparams %s\n' % frcmod_filename
# Generate ffxml file contents for parmchk-generated frcmod output.
leaprc = StringIO(leaprc)
params = parmed.amber.AmberParameterSet.from_leaprc(leaprc)
params = parmed.openmm.OpenMMParameterSet.from_parameterset(params, remediate_residues=False)
ffxml = StringIO()
params.write(ffxml)
# TODO: Clean up temporary directory.
os.chdir(olddir)
if ignoreFailures:
return ffxml.getvalue(), failed_molecule_list
else:
return ffxml.getvalue()