Skip to content

Commit

Permalink
Fix endstate validation handling in PointMutationExecutor (#866)
Browse files Browse the repository at this point in the history
* fix endstate validation handling

* added a test to catch regressions like this

Co-authored-by: Mike Henry <11765982+mikemhenry@users.noreply.github.com>
  • Loading branch information
schallerdavid and mikemhenry authored Sep 14, 2021
1 parent 410ca4f commit c1f5769
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
6 changes: 3 additions & 3 deletions perses/app/relative_point_mutation_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ def __init__(self,
else:
subtracted_valence_energy = geometry_engine.reverse_final_context_reduced_potential - geometry_engine.reverse_atoms_with_positions_reduced_potential


if conduct_endstate_validation and repartitioned_endstate is None:
zero_state_error, one_state_error = validate_endstate_energies(forward_htf._topology_proposal, forward_htf, added_valence_energy, subtracted_valence_energy, beta=beta, ENERGY_THRESHOLD=ENERGY_THRESHOLD)
if conduct_endstate_validation and generate_unmodified_hybrid_topology_factory:
htf = self.get_complex_htf() if is_complex else self.get_apo_htf()
zero_state_error, one_state_error = validate_endstate_energies(htf._topology_proposal, htf, added_valence_energy, subtracted_valence_energy, beta=beta, ENERGY_THRESHOLD=ENERGY_THRESHOLD)
if zero_state_error > ENERGY_THRESHOLD:
_logger.warning(f"Reduced potential difference of the nonalchemical and alchemical Lambda = 0 state is above the threshold ({ENERGY_THRESHOLD}): {zero_state_error}")
if one_state_error > ENERGY_THRESHOLD:
Expand Down
42 changes: 32 additions & 10 deletions perses/tests/test_relative_point_mutation_setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
def test_PointMutationExecutor():
from pkg_resources import resource_filename
from simtk import unit

from perses.app.relative_point_mutation_setup import PointMutationExecutor

pdb_filename = resource_filename("perses", "data/ala_vacuum.pdb")
PointMutationExecutor(
pdb_filename,
"1",
"2",
"ASP",
ionic_strength=0.15 * unit.molar,
flatten_torsions=True,
flatten_exceptions=True,
conduct_endstate_validation=False,
)


def test_PointMutationExecutor_endstate_validation():
from pkg_resources import resource_filename
from simtk import unit
pdb_filename = resource_filename('perses', 'data/ala_vacuum.pdb')
solvent_delivery = PointMutationExecutor(pdb_filename,
'1',
'2',
'ASP',
ionic_strength=0.15*unit.molar,
flatten_torsions=True,
flatten_exceptions=True,
conduct_endstate_validation=False
)

from perses.app.relative_point_mutation_setup import PointMutationExecutor

pdb_filename = resource_filename("perses", "data/ala_vacuum.pdb")
PointMutationExecutor(
pdb_filename,
"1",
"2",
"ASP",
ionic_strength=0.15 * unit.molar,
flatten_torsions=False,
flatten_exceptions=False,
conduct_endstate_validation=True,
)

0 comments on commit c1f5769

Please sign in to comment.