Skip to content

Commit

Permalink
Add validator method
Browse files Browse the repository at this point in the history
  • Loading branch information
IAlibay committed Jan 30, 2024
1 parent caabe57 commit d21dea7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions openfe/protocols/openmm_utils/settings_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,38 @@
from gufe import (
Component, ChemicalSystem, SolventComponent, ProteinComponent
)
from openfe.protocols.openmm_utils.omm_settings import OpenMMSolvationSettings


def validate_openmm_solvation_settings(
settings: OpenMMSolvationSettings
) -> None:
"""
Checks that the OpenMMSolvation settings are correct.
Raises
------
ValueError
If more than one of ``solvent_padding``, ``number_of_solvent_molecules``,
``box_vectors``, or ``box_size`` are defined.
If ``box_shape`` is defined alongside either ``box_vectors``,
or ``box_size``.
"""
unique_attributes = (
settings.solvent_padding, settings.number_of_solvent_molecules,
settings.box_vectors, settings.box_size,
)
if len([x for x in unique_attributes if x is not None]) > 1:
errmsg = ("Only one of solvent_padding, number_of_solvent_molecules, "
"box_vectors, and box_size can be defined in the solvation "
"settings.")
raise ValueError(errmsg)

if settings.box_shape is not None:
if settings.box_size is not None or settings.box_vectors is not None:
errmsg = ("box_shape cannot be defined alongside either box_size "
"or box_vectors in the solvation settings.")
raise ValueError(errmsg)


def validate_timestep(hmass: float, timestep: unit.Quantity):
Expand Down

0 comments on commit d21dea7

Please sign in to comment.