Address review comments

This commit is contained in:
hannahbaumann
2026-06-01 10:18:19 +02:00
parent f508d3442e
commit 2cb287af63
3 changed files with 7 additions and 19 deletions

View File

@@ -166,7 +166,7 @@ def _get_ion_parameters(
continue
charge, _, _ = nbf.getParticleParameters(atom.index)
charge_val = charge.value_in_unit(omm_unit.elementary_charge)
if (abs(abs(charge_val) - 1.0) < 0.01 and np.sign(charge_val) == desired_sign):
if np.isclose(abs(charge_val), 1.0, atol=0.01) and np.sign(charge_val) == desired_sign:
ion_counts[residue.name] += 1
if residue.name not in ion_atom_indices:
ion_atom_indices[residue.name] = atom.index

View File

@@ -437,22 +437,11 @@ class RelativeHybridTopologyProtocol(gufe.Protocol):
)
raise ValueError(errmsg)
# resolve ion names from SolventComponent or topology
if isinstance(solvent_component, SolventComponent):
positive_ion = solvent_component.positive_ion.strip("-+").upper()
negative_ion = solvent_component.negative_ion.strip("-+").upper()
ion = {-1: positive_ion, 1: negative_ion}[difference]
wmsg = (
f"A charge difference of {difference} is observed "
"between the end states. This will be addressed by "
f"transforming a water into a {ion} ion"
)
elif isinstance(solvent_component, SolvatedPDBComponent):
wmsg = (
f"A charge difference of {difference} is observed "
"between the end states. This will be addressed by "
"transforming a water into an ion."
)
wmsg = (
f"A charge difference of {difference} is observed "
"between the end states. This will be addressed by "
"transforming a water into an ion of opposite charge."
)
logger.info(wmsg)
@staticmethod

View File

@@ -441,11 +441,10 @@ def test_get_charge_difference(mapping_name, result, request, caplog):
mapping = request.getfixturevalue(mapping_name)
caplog.set_level(logging.INFO)
ion = r"NA" if result == -1 else r"CL"
msg = (
f"A charge difference of {result} is observed "
"between the end states. This will be addressed by "
f"transforming a water into a {ion} ion"
f"transforming a water into an ion of opposite charge"
)
openmm_rfe.RelativeHybridTopologyProtocol._validate_charge_difference(