-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST: Add some round-trip tests between GROMACS files
- Loading branch information
1 parent
2ea3d50
commit 92e6e3a
Showing
7 changed files
with
84 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Helpers for testing GROMACS interoperability.""" | ||
|
||
from openff.utilities import temporary_cd | ||
|
||
from openff.interchange import Interchange | ||
from openff.interchange.components.mdconfig import get_smirnoff_defaults | ||
from openff.interchange.drivers import get_gromacs_energies | ||
|
||
|
||
def gmx_roundtrip(state: Interchange, apply_smirnoff_defaults: bool = False): | ||
with temporary_cd(): | ||
state.to_gromacs(prefix="state", decimal=8) | ||
new_state = Interchange.from_gromacs(topology_file="state.top", gro_file="state.gro") | ||
|
||
get_smirnoff_defaults(periodic=True).apply(new_state) | ||
|
||
# TODO: More helpful handling of failures, i.e. | ||
# * Detect differences in positions | ||
# * Detect differences in box vectors | ||
# * Detect differences in non-bonded settings | ||
get_gromacs_energies(state).compare(get_gromacs_energies(new_state)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
openff/interchange/_tests/interoperability_tests/gromacs/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Interoperability tests with GROMACS.""" |
24 changes: 24 additions & 0 deletions
24
openff/interchange/_tests/interoperability_tests/gromacs/test_systems.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from openff.toolkit import Quantity | ||
|
||
from openff.interchange._tests._gromacs import gmx_roundtrip | ||
|
||
|
||
def test_ligand_vacuum(ligand, sage_unconstrained, monkeypatch): | ||
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", 1) | ||
|
||
topology = ligand.to_topology() | ||
topology.box_vectors = Quantity([4, 4, 4], "nanometer") | ||
|
||
gmx_roundtrip(sage_unconstrained.create_interchange(topology)) | ||
|
||
|
||
def test_water_dimer(water_dimer, tip3p, monkeypatch): | ||
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", 1) | ||
|
||
gmx_roundtrip(tip3p.create_interchange(water_dimer)) | ||
|
||
|
||
def test_alanine_dipeptide(alanine_dipeptide, ff14sb, monkeypatch): | ||
monkeypatch.setenv("INTERCHANGE_EXPERIMENTAL", 1) | ||
|
||
gmx_roundtrip(ff14sb.create_interchange(alanine_dipeptide)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters