Garnet force field
If you use the force field, please cite the paper:
- A Blanco-González*, T K Schulze*, E Rovers, J G Greener. Training a force field for proteins and small molecules from scratch, Chemical Science (2026).
Using the force field
The model was trained in Julia as described below. To make it easier to parameterise molecules, it has been ported to PyTorch for inference.
Installation
Example conda/mamba commands:
conda create -n garnet python=3.12
conda activate garnet
conda install -c conda-forge pip 'openff-toolkit-base>=0.18.0' rustworkx rdkit openmm pyxdg gemmi
pip install torch torch_geometric igraph
pip install git+https://github.com/openforcefield/openff-pablo.git@v0.2.0
pip install garnetff
Should you want to run the tests, you can run the following from this directory:
pip install pytest
pytest
Assigning parameters
Garnet integrates with the OpenFF and OpenMM software ecosystem.
The recommended route to obtaining parameters for a system is to create an OpenFF Toolkit Topology, then call topology_to_openmm_system on it.
The Topology can come from a PDB file of the whole system, a SMILES string or a structure file.
In the first case, using OpenFF Pablo to read the PDB file can be more flexible than using Topology.from_pdb (for example, it supports nucleic acids and post-translational modifications).
from garnetff import garnet
from openff.pablo import topology_from_pdb
from openmm.app import PME, HBonds
from openmm.unit import nanometer
pdb_fp = "data/gb3.pdb"
topology = topology_from_pdb(pdb_fp)
system, top_openmm = garnet.topology_to_openmm_system(
topology,
nonbondedMethod=PME,
nonbondedCutoff=1*nanometer,
constraints=HBonds,
rigidWater=True,
)
# Run an OpenMM simulation
from openmm import LangevinMiddleIntegrator
from openmm.app import Simulation, PDBFile
from openmm.unit import picosecond, kelvin
temp = 300*kelvin
dt = 0.004*picosecond
integrator = LangevinMiddleIntegrator(temp, 1/picosecond, dt)
simulation = Simulation(top_openmm, system, integrator)
pdb = PDBFile(pdb_fp)
simulation.context.setPositions(pdb.positions)
simulation.minimizeEnergy()
simulation.context.setVelocitiesToTemperature(temp)
simulation.step(1000)
Disulfide bridges need to be explicitly given via CONECT records, unlike when reading in with OpenMM directly.
The Topology can also be written to an OpenMM force field XML file:
garnet.topology_to_openmm_xml("gb3.xml", topology)
In this case each molecule is written out as a single residue. The following gives a way to set up the above system using XML files:
garnet.topology_to_openmm_xml("gb3.xml", topology, write_pdb="gb3_garnet.cif")
pdb = PDBxFile("gb3_garnet.cif")
forcefield = ForceField("gb3.xml")
system = forcefield.createSystem(
pdb.topology,
nonbondedMethod=PME,
nonbondedCutoff=1*nanometer,
constraints=HBonds,
rigidWater=True,
)
However, currently only one force field XML can be loaded with ForceField from OpenMM due to the way custom non-bonded forces work.
topology_to_openmm_xml has optional keyword arguments:
mol_names: a list of strings to specify the name of each molecule.prefix: a string to give unique atom names and avoid clashes with other XML files.write_top: write an XML file of the bonding topology to the given file path.write_pdb: write a PDB or mmCIF file (determined by the extension) with molecules having a single residue name to the given file path.
From a SMILES string:
from garnetff import garnet
from openff.toolkit.topology import Molecule, Topology
smiles = "[H]O[H]"
mol = Molecule.from_smiles(smiles, hydrogens_are_explicit=True)
topology = Topology.from_molecules(molecules=[mol])
system, top_openmm = garnet.topology_to_openmm_system(topology)
From a structure file (see the OpenFF toolkit docs for available formats):
from garnetff import garnet
from openff.toolkit.topology import Molecule, Topology
mol = Molecule.from_file("data/zw_l_alanine.sdf")
topology = Topology.from_molecules(molecules=[mol])
system, top_openmm = garnet.topology_to_openmm_system(topology)
The default options for topology_to_openmm_system are nonbondedMethod=NoCutoff, nonbondedCutoff=1*nanometer, constraints=None and rigidWater=False.
It is important to select these parameters carefully as described in the the OpenMM documentation.
Assigning parameters is usually fast (a few seconds), but for some molecules it can take a minute or so due to graph isomorphism checks.
Due to the custom non-bonded interaction, Garnet runs 15-20% slower than standard simulations with the Lennard-Jones potential in OpenMM.
If you want to use Garnet with simulation software other than OpenMM, you could try conversion software such as ParmEd or OpenFF Interchange.
Binding free energy calculations
To run relative binding free energy calculations with Garnet using OpenFE, see the validation/rbfe directory.
Training
See the training directory for instructions on how to train the force field from scratch. Training made use of the Molly.jl software. Validation scripts are in the validation directory.
Feedback
We are interested in how people are using Garnet and in cases where it performs well or poorly. Do let us know by opening an issue or via email, user requests will inform future development.
Release files for garnetff 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| garnetff-1.0.0.tar.gz | 858.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| garnetff-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.7 MB
Release files / garnetff-1.0.0.tar.gz
| Download URL | garnetff-1.0.0.tar.gz |
|---|---|
| Size | 858.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5546248ad0a39ebf8678cb898d09eae7254471dc14efcef025a0f04285d903ef
|
|
BLAKE2b-256 checksum How to use checksums |
b85282e0304d05b47705b06f478b68cabdd7665816b96d54e194a3876be637e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / garnetff-1.0.0-py3-none-any.whl
| Download URL | garnetff-1.0.0-py3-none-any.whl |
|---|---|
| Size | 854.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3285224860c691436544a8c4c35f8f82c0135e366fea87007bc63d2046388108
|
|
BLAKE2b-256 checksum How to use checksums |
ac30a11f1264de58a81a6121fd75a9001d4f8fa4d0931d6189a18a5de65f20e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|