diff --git a/tests/test_interactions.py b/tests/test_interactions.py index 7e2a1f8..6b71dde 100644 --- a/tests/test_interactions.py +++ b/tests/test_interactions.py @@ -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}}) @@ -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