Skip to content

Commit

Permalink
update LomapAtomMapper default settings to established best practices (
Browse files Browse the repository at this point in the history
…#730)

* update LomapAtomMapper default settings to established best practices

* fixup tests for relative_alchemical_network_planner following lomap default change

make these tests use the legacy default settings for Lomap, they're just smoke testing and the actual mappings don't matter

* fixup regression tests for command line plan-rbfe

these are different now that the lomap defaults have been changed for 1.0

---------

Co-authored-by: Mike Henry <[email protected]>
  • Loading branch information
richardjgowers and mikemhenry authored Mar 27, 2024
1 parent 0a64694 commit 1dd5d7e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ def __init__(
if protocol is None:
protocol = RelativeHybridTopologyProtocol(RelativeHybridTopologyProtocol.default_settings())
if mappers is None:
mappers = [LomapAtomMapper(time=20, threed=True,
element_change=False, max3d=1)]
mappers = [LomapAtomMapper(time=20,
threed=True,
max3d=1.0,
element_change=True,
shift=False,
)]

self.name = name
self._mappers = mappers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from gufe import SolventComponent, AlchemicalNetwork
from openfe.setup.alchemical_network_planner import RHFEAlchemicalNetworkPlanner, RBFEAlchemicalNetworkPlanner
from .edge_types import r_complex_edge, r_solvent_edge, r_vacuum_edge
import openfe


def test_rhfe_alchemical_network_planner_init():
Expand All @@ -22,7 +23,15 @@ def test_rbfe_alchemical_network_planner_init():


def test_rbfe_alchemical_network_planner_call(atom_mapping_basic_test_files, T4_protein_component):
alchem_planner = RBFEAlchemicalNetworkPlanner()
alchem_planner = RBFEAlchemicalNetworkPlanner(
# these aren't default settings, but the test ligands aren't aligned
mappers=[openfe.LomapAtomMapper(
time=20,
element_change=False,
max3d=1,
shift=True,
)]
)
alchem_network = alchem_planner(
ligands=atom_mapping_basic_test_files.values(),
solvent=SolventComponent(),
Expand All @@ -34,14 +43,20 @@ def test_rbfe_alchemical_network_planner_call(atom_mapping_basic_test_files, T4_
edges = alchem_network.edges
assert len(edges) == 14 # we build 2envs*8ligands-2startLigands = 14 relative edges.

print(edges)
assert sum([r_complex_edge(e) for e in edges]) == 7 # half of the transformations should be complex (they always are)!
assert sum([r_solvent_edge(e) for e in edges]) == 7 # half of the transformations should be solvent!
assert sum([r_vacuum_edge(e) for e in edges]) == 0 # no vacuum here!


def test_rhfe_alchemical_network_planner_call_multigraph(atom_mapping_basic_test_files):
alchem_planner = RHFEAlchemicalNetworkPlanner()
alchem_planner = RHFEAlchemicalNetworkPlanner(
mappers=[openfe.LomapAtomMapper(
time=20,
element_change=False,
max3d=1,
shift=True,
)]
)

ligand_network = alchem_planner._construct_ligand_network(atom_mapping_basic_test_files.values())
ligand_network_edges = list(ligand_network.edges)
Expand All @@ -59,7 +74,14 @@ def test_rhfe_alchemical_network_planner_call_multigraph(atom_mapping_basic_test


def test_rhfe_alchemical_network_planner_call(atom_mapping_basic_test_files):
alchem_planner = RHFEAlchemicalNetworkPlanner()
alchem_planner = RHFEAlchemicalNetworkPlanner(
mappers=[openfe.LomapAtomMapper(
time=20,
element_change=False,
max3d=1,
shift=True,
)]
)
alchem_network = alchem_planner(ligands=atom_mapping_basic_test_files.values(), solvent=SolventComponent())

assert isinstance(alchem_network, AlchemicalNetwork)
Expand Down
9 changes: 7 additions & 2 deletions openfecli/parameters/plan_network_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,13 @@ def load_yaml_planner_options(path: Optional[str], context) -> PlanNetworkOption
raise KeyError(f"Bad mapper choice: '{opt.mapper.method}'")
mapper_obj = cls(**opt.mapper.settings)
else:
mapper_obj = LomapAtomMapper(time=20, threed=True, element_change=False,
max3d=1)
mapper_obj = LomapAtomMapper(
time=20,
threed=True,
max3d=1.0,
element_change=True,
shift=False
)

# todo: choice of scorer goes here
mapping_scorer = default_lomap_score
Expand Down
30 changes: 15 additions & 15 deletions openfecli/tests/test_rbfe_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ def tyk2_protein():

@pytest.fixture
def expected_transformations():
return ['easy_rbfe_lig_ejm_31_complex_lig_ejm_42_complex.json',
'easy_rbfe_lig_ejm_31_solvent_lig_ejm_50_solvent.json',
'easy_rbfe_lig_ejm_31_complex_lig_ejm_46_complex.json',
'easy_rbfe_lig_ejm_42_complex_lig_ejm_43_complex.json',
return ['easy_rbfe_lig_ejm_31_complex_lig_ejm_46_complex.json',
'easy_rbfe_lig_ejm_31_complex_lig_ejm_47_complex.json',
'easy_rbfe_lig_ejm_42_solvent_lig_ejm_43_solvent.json',
'easy_rbfe_lig_ejm_31_complex_lig_ejm_48_complex.json',
'easy_rbfe_lig_ejm_46_complex_lig_jmc_23_complex.json',
'easy_rbfe_lig_ejm_31_complex_lig_ejm_50_complex.json',
'easy_rbfe_lig_ejm_46_complex_lig_jmc_27_complex.json',
'easy_rbfe_lig_ejm_31_solvent_lig_ejm_42_solvent.json',
'easy_rbfe_lig_ejm_46_complex_lig_jmc_28_complex.json',
'easy_rbfe_lig_ejm_31_solvent_lig_ejm_46_solvent.json',
'easy_rbfe_lig_ejm_46_solvent_lig_jmc_23_solvent.json',
'easy_rbfe_lig_ejm_31_solvent_lig_ejm_47_solvent.json',
'easy_rbfe_lig_ejm_46_solvent_lig_jmc_27_solvent.json',
'easy_rbfe_lig_ejm_31_solvent_lig_ejm_48_solvent.json',
'easy_rbfe_lig_ejm_46_solvent_lig_jmc_28_solvent.json']
'easy_rbfe_lig_ejm_31_solvent_lig_ejm_50_solvent.json',
'easy_rbfe_lig_ejm_42_complex_lig_ejm_43_complex.json',
'easy_rbfe_lig_ejm_42_complex_lig_ejm_50_complex.json',
'easy_rbfe_lig_ejm_42_solvent_lig_ejm_43_solvent.json',
'easy_rbfe_lig_ejm_42_solvent_lig_ejm_50_solvent.json',
'easy_rbfe_lig_ejm_46_complex_lig_jmc_27_complex.json',
'easy_rbfe_lig_ejm_46_solvent_lig_jmc_27_solvent.json',
'easy_rbfe_lig_jmc_23_complex_lig_jmc_27_complex.json',
'easy_rbfe_lig_jmc_23_solvent_lig_jmc_27_solvent.json',
'easy_rbfe_lig_jmc_27_complex_lig_jmc_28_complex.json',
'easy_rbfe_lig_jmc_27_solvent_lig_jmc_28_solvent.json']


def test_plan_tyk2(tyk2_ligands, tyk2_protein, expected_transformations):
Expand Down Expand Up @@ -88,15 +88,15 @@ def fake_execute(*args, **kwargs):
def ref_gather():
return """\
ligand_i\tligand_j\tDDG(i->j) (kcal/mol)\tuncertainty (kcal/mol)
lig_ejm_31\tlig_ejm_42\t0.0\t0.0
lig_ejm_31\tlig_ejm_46\t0.0\t0.0
lig_ejm_31\tlig_ejm_47\t0.0\t0.0
lig_ejm_31\tlig_ejm_48\t0.0\t0.0
lig_ejm_31\tlig_ejm_50\t0.0\t0.0
lig_ejm_42\tlig_ejm_43\t0.0\t0.0
lig_ejm_46\tlig_jmc_23\t0.0\t0.0
lig_ejm_42\tlig_ejm_50\t0.0\t0.0
lig_ejm_46\tlig_jmc_27\t0.0\t0.0
lig_ejm_46\tlig_jmc_28\t0.0\t0.0
lig_jmc_23\tlig_jmc_27\t0.0\t0.0
lig_jmc_27\tlig_jmc_28\t0.0\t0.0
"""


Expand Down

0 comments on commit 1dd5d7e

Please sign in to comment.