Skip to content

Commit

Permalink
Merge pull request #845 from openforcefield/amber-virtual-site-error
Browse files Browse the repository at this point in the history
Raise exception when writing Amber files with virtual sites
  • Loading branch information
mattwthompson committed Nov 16, 2023
2 parents db845ef + 0cf361e commit f349fb7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/releasehistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Dates are given in YYYY-MM-DD format.

Please note that all releases prior to a version 1.0.0 are considered pre-releases and many API changes will come before a stable release.

## Current development

### Behavior changes

* #845 Adds an exception when unimplemented virtual sites are present while writing to Amber files. Previously this was a silent error producing invalid files.

## 0.3.17 - 2023-11-02

### New Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from openff.interchange import Interchange
from openff.interchange._tests import get_test_file_path, requires_openeye
from openff.interchange.exceptions import UnsupportedExportError

if has_package("openmm"):
import openmm
Expand Down Expand Up @@ -60,3 +61,11 @@ def exclusions_in_rings(molecule):
for force in loaded_system.getForces():
if isinstance(force, openmm.NonbondedForce):
assert force.getNumExceptions() == reference


def test_virtual_site_error(tip4p, water):
with pytest.raises(
UnsupportedExportError,
match="not yet supported in Amber writers",
):
tip4p.create_interchange(water.to_topology()).to_prmtop("foo")
7 changes: 7 additions & 0 deletions openff/interchange/interop/amber/export/_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@ def to_prmtop(interchange: "Interchange", file_path: Union[Path, str]):
if interchange["vdW"].mixing_rule != "lorentz-berthelot":
raise UnsupportedMixingRuleError(interchange["vdW"].mixing_rule)

if "VirtualSites" in interchange.collections:
if len(interchange["VirtualSites"].key_map) > 0:
raise UnsupportedExportError(
"Virtual sites are not yet supported in Amber writers. See issues labeled "
"'amber' or 'virtual sites' for status and updates of this feature.",
)

if interchange.box is None:
if interchange["Electrostatics"].periodic_potential != _PME:
raise UnsupportedExportError(
Expand Down

0 comments on commit f349fb7

Please sign in to comment.