Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

89 add tests to cover missing scorer behavior #94

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
from konnektor.network_analysis import get_is_connected
from konnektor.network_planners import HeuristicMaximalNetworkGenerator
from konnektor.utils.toy_data import build_random_dataset

from konnektor.tests.network_planners.conf import (
genScorer,
GenAtomMapper,
BadMapper,
SuperBadMapper
)

@pytest.mark.parametrize("n_process", [1, 2])
@pytest.mark.parametrize("with_progress", [True, False])
@pytest.mark.parametrize("with_scorer", [True, False])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to check - this just being removed because the test fixture just wasn't being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

def test_generate_maximal_network(with_progress, with_scorer, n_process):
def test_generate_maximal_network(with_progress, n_process):
n_compounds = 20
components, genMapper, genScorer = build_random_dataset(n_compounds=n_compounds)

Expand All @@ -30,3 +34,31 @@ def test_generate_maximal_network(with_progress, with_scorer, n_process):
assert len(network.edges) <= edge_count
assert len(network.edges) > n_compounds
assert get_is_connected(network)

@pytest.mark.parametrize("n_process", [1, 2])
@pytest.mark.parametrize("with_progress", [True, False])
def test_generate_maximal_network_missing_scorer(with_progress, n_process):
"""If no scorer is provided, the first mapping of the last mapper should be used.
Note: this test isn't great because BadMapper only returns one mapping
"""
n_compounds = 4
components, _, _ = build_random_dataset(n_compounds=n_compounds)

planner = HeuristicMaximalNetworkGenerator(
mappers= [SuperBadMapper(), GenAtomMapper(), BadMapper()],
scorer=None,
n_samples=3,
progress=with_progress,
n_processes=n_process,
)
network = planner.generate_ligand_network(components)

assert len(network.nodes) == n_compounds

edge_count = n_compounds * 3
assert len(network.edges) <= edge_count
assert len(network.edges) > n_compounds
assert get_is_connected(network)

assert [e.componentA_to_componentB for e in network.edges] == len(network.edges)*[{0:0}]

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
toluene_vs_others,
genScorer,
GenAtomMapper,
BadMapper,
SuperBadMapper
)

from gufe import LigandAtomMapping, AtomMapper, AtomMapping
from konnektor.utils.toy_data import build_random_dataset

@pytest.mark.parametrize("n_process", [1, 2])
@pytest.mark.parametrize("with_progress", [True, False])
Expand Down Expand Up @@ -41,3 +44,24 @@ def test_generate_maximal_network(
else:
for edge in network.edges:
assert "score" not in edge.annotations

@pytest.mark.parametrize("n_process", [1, 2])
@pytest.mark.parametrize("with_progress", [True, False])
def test_generate_maximal_network_missing_scorer(toluene_vs_others, n_process, with_progress):
"""If no scorer is provided, the first mapping of the last mapper should be used.
Note: this test isn't great because BadMapper only returns one mapping
"""

toluene, others = toluene_vs_others
components = others+[toluene]

planner = MaximalNetworkGenerator(
mappers= [SuperBadMapper(), GenAtomMapper(), BadMapper()],
scorer=None,
progress=with_progress,
n_processes=n_process,
)

network = planner.generate_ligand_network(components)

assert [e.componentA_to_componentB for e in network.edges] == len(network.edges)*[{0:0}]
Loading