Skip to content

Commit

Permalink
tests: test water bridge params and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
cbouy committed Dec 28, 2024
1 parent 1a6631c commit 2066772
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions tests/test_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,21 @@ def test_edgetoface_phe331(self, ligand_mol, protein_mol):


class TestBridgedInteractions:
@pytest.mark.parametrize(
("kwargs", "match"),
[
({"order": 0}, "order must be greater than 0"),
({"order": 1, "min_order": 2}, "min_order cannot be greater than order"),
],
)
def test_water_bridge_validation(self, water_params, kwargs, match):
*_, water = water_params
with pytest.raises(ValueError, match=match):
Fingerprint(
["WaterBridge"],
parameters={"WaterBridge": {"water": water, **kwargs}},
)

def test_direct_water_bridge(self, water_u, water_params):
ligand, protein, water = water_params
fp = Fingerprint(["WaterBridge"], parameters={"WaterBridge": {"water": water}})
Expand All @@ -359,16 +374,24 @@ def test_direct_water_bridge(self, water_u, water_params):
assert int_data.interaction == "WaterBridge"
assert str(int_data.protein) == "TRP400.X"

def test_higher_order_water_bridge(self, water_u):
@pytest.mark.parametrize(
("kwargs", "num_expected"),
[
({}, 3),
({"min_order": 2}, 2),
],
)
def test_higher_order_water_bridge(self, water_u, kwargs, num_expected):
ligand = water_u.select_atoms("resname QNB")
pocket = water_u.select_atoms("protein and resid 399:403")
water = water_u.select_atoms("segid WAT and (resid 17 or resid 83)")
fp = Fingerprint(
["WaterBridge"], parameters={"WaterBridge": {"water": water, "order": 2}}
["WaterBridge"],
parameters={"WaterBridge": {"water": water, "order": 2, **kwargs}},
)
fp.run(water_u.trajectory[:1], ligand, pocket)
all_int_data = list(fp.ifp[0].interactions())

assert len(all_int_data) == 3
int_data = all_int_data[2]
assert len(all_int_data) == num_expected
int_data = all_int_data[-1]
assert "distance_TIP383.X_TIP317.X" in int_data.metadata

0 comments on commit 2066772

Please sign in to comment.