-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Description
I do not think SMIRNOFFTemplateGenerator should be used on proteins
Reproduction (can be done with just about any multi-residue PDB file, mine is from proteinbenchmark):
In [1]: from openmmforcefields.generators import SMIRNOFFTemplateGenerator
In [2]: from openff.toolkit import Topology
In [3]: import openmm.app
In [4]: topology = Topology.from_pdb("ctr148a-2KO1-model-1.pdb")
In [5]: ff = openmm.app.ForceField()
In [6]: gen = SMIRNOFFTemplateGenerator(molecules=[*topology.molecules], forcefield='openff_no_water_unconstrained-3.0.0-alpha0.offxml')
In [7]: ff.registerTemplateGenerator(gen.generator)
In [8]: ff.createSystem(topology.to_openmm())
Did not recognize residue MET; did you forget to call .add_molecules() to add it?
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[8], line 1
----> 1 ff.createSystem(topology.to_openmm())
File ~/mamba/envs/openmmforcefields/lib/python3.13/site-packages/openmm/app/forcefield.py:1266, in ForceField.createSystem(self, topology, nonbondedMethod, nonbondedCutoff, constraints, rigidWater, removeCMMotion, hydrogenMass, residueTemplates, ignoreExternalBonds, switchDistance, flexibleConstraints, drudeMass, **args)
1262 rigidResidue = [False]*topology.getNumResidues()
1264 # Find the template matching each residue and assign atom types.
-> 1266 templateForResidue = self._matchAllResiduesToTemplates(data, topology, residueTemplates, ignoreExternalBonds)
1267 for res in topology.residues():
1268 if res.name == 'HOH':
1269 # Determine whether this should be a rigid water.
File ~/mamba/envs/openmmforcefields/lib/python3.13/site-packages/openmm/app/forcefield.py:1486, in ForceField._matchAllResiduesToTemplates(self, data, topology, residueTemplates, ignoreExternalBonds, ignoreExtraParticles, recordParameters)
1484 break
1485 if matches is None:
-> 1486 raise ValueError('No template found for residue %d (%s). %s For more information, see https://github.com/openmm/openmm/wiki/Frequently-Asked-Questions#template' % (res.index, res.name, _findMatchErrors(self, res)))
1487 else:
1488 if recordParameters:
ValueError: No template found for residue 0 (MET). The force field contains no residue templates. For more information, see https://github.com/openmm/openmm/wiki/Frequently-Asked-Questions#templateNote that this works (as in: can create a system) by using OpenFF tools directly:
In [1]: from openff.toolkit import Topology, ForceField
In [2]: topology = Topology.from_pdb("ctr148a-2KO1-model-1.pdb")
In [3]: ForceField('openff_no_water_unconstrained-3.0.0-alpha0.offxml').create_openmm_system(topology)
[13:37:59] WARNING: Proton(s) added/removed
Out[3]: <openmm.openmm.System; proxy of <Swig Object of type 'OpenMM::System *' at 0x107a2a870> >Metadata
Metadata
Assignees
Labels
No labels