def test_scoring_branch_mcts_tree_in_stock(shared_datadir, default_config, mock_stock): mock_stock( default_config, "CC(C)(C)CO", "CC(C)(C)OC(=O)N(CCCl)CCCl", "N#CCc1cccc(O)c1F", "O=[N+]([O-])c1ccccc1F", "O=C1CCC(=O)N1Br", "O=C=Nc1csc(C(F)(F)F)n1", "CCC[Sn](Cl)(CCC)CCC", "COc1ccc2ncsc2c1", ) search_tree = SearchTree.from_json( shared_datadir / "tree_with_branching.json", default_config) nodes = list(search_tree.graph()) assert pytest.approx(StateScorer(default_config)(nodes[-1]), abs=1e-3) == 0.950 assert NumberOfReactionsScorer()(nodes[-1]) == 14 assert NumberOfPrecursorsScorer(default_config)(nodes[-1]) == 8 assert NumberOfPrecursorsInStockScorer(default_config)(nodes[-1]) == 8 assert PriceSumScorer(default_config)(nodes[-1]) == 8 cost_score = RouteCostScorer(default_config)(nodes[-1]) assert pytest.approx(cost_score, abs=1e-3) == 77.4797
def test_scoring_branched_route(load_reaction_tree, default_config): tree = ReactionTree.from_dict(load_reaction_tree("branched_route.json")) assert pytest.approx(StateScorer(default_config)(tree), abs=1e-6) == 0.00012363 assert NumberOfReactionsScorer(default_config)(tree) == 14 assert NumberOfPrecursorsScorer(default_config)(tree) == 8 assert NumberOfPrecursorsInStockScorer(default_config)(tree) == 0
def test_scoring_branched_mcts_tree(shared_datadir, default_config): search_tree = SearchTree.from_json( shared_datadir / "tree_with_branching.json", default_config) nodes = list(search_tree.graph()) assert pytest.approx(StateScorer()(nodes[-1]), abs=1e-6) == 0.00012363 assert NumberOfReactionsScorer()(nodes[-1]) == 14 assert NumberOfPrecursorsScorer(default_config)(nodes[-1]) == 8 assert NumberOfPrecursorsInStockScorer(default_config)(nodes[-1]) == 0
def test_scorers_one_mcts_node(default_config): tree = SearchTree(default_config, root_smiles="CCCCOc1ccc(CC(=O)N(C)O)cc1") node = tree.root assert pytest.approx(StateScorer(default_config)(node), abs=1e-3) == 0.0497 assert NumberOfReactionsScorer(default_config)(node) == 0 assert NumberOfPrecursorsScorer(default_config)(node) == 1 assert NumberOfPrecursorsInStockScorer(default_config)(node) == 0 assert PriceSumScorer(default_config)(node) == 10 assert RouteCostScorer(default_config)(node) == 10
def test_scoring_branched_route(default_config, setup_branched_reaction_tree): tree = setup_branched_reaction_tree() assert pytest.approx(StateScorer(default_config)(tree), abs=1e-4) == 0.9866 assert NumberOfReactionsScorer()(tree) == 4 assert NumberOfPrecursorsScorer(default_config)(tree) == 5 assert NumberOfPrecursorsInStockScorer(default_config)(tree) == 5 assert PriceSumScorer(default_config)(tree) == 5 cost_score = RouteCostScorer(default_config)(tree) assert pytest.approx(cost_score, abs=1e-4) == 13.6563
def test_scorers_tree_one_node_route(default_config): tree = ReactionTree() tree.root = UniqueMolecule(smiles="CCCCOc1ccc(CC(=O)N(C)O)cc1") tree.graph.add_node(tree.root) assert pytest.approx(StateScorer(default_config)(tree), abs=1e-3) == 0.0497 assert NumberOfReactionsScorer(default_config)(tree) == 0 assert NumberOfPrecursorsScorer(default_config)(tree) == 1 assert NumberOfPrecursorsInStockScorer(default_config)(tree) == 0 assert PriceSumScorer(default_config)(tree) == 10 assert RouteCostScorer(default_config)(tree) == 10
def test_scoring_branched_route_not_in_stock(default_config, setup_branched_reaction_tree): tree = setup_branched_reaction_tree("O") assert pytest.approx(StateScorer(default_config)(tree), abs=1e-4) == 0.7966 assert NumberOfReactionsScorer()(tree) == 4 assert NumberOfPrecursorsScorer(default_config)(tree) == 5 assert NumberOfPrecursorsInStockScorer(default_config)(tree) == 4 assert PriceSumScorer(default_config)(tree) == 14 cost_score = RouteCostScorer(default_config)(tree) assert pytest.approx(cost_score, abs=1e-4) == 31.2344
def test_scoring_branched_route_in_stock(load_reaction_tree, default_config, mock_stock): mock_stock( default_config, "CC(C)(C)CO", "CC(C)(C)OC(=O)N(CCCl)CCCl", "N#CCc1cccc(O)c1F", "O=[N+]([O-])c1ccccc1F", "O=C1CCC(=O)N1Br", "O=C=Nc1csc(C(F)(F)F)n1", "CCC[Sn](Cl)(CCC)CCC", "COc1ccc2ncsc2c1", ) tree = ReactionTree.from_dict(load_reaction_tree("branched_route.json")) assert pytest.approx(StateScorer(default_config)(tree), abs=1e-3) == 0.950 assert NumberOfReactionsScorer(default_config)(tree) == 14 assert NumberOfPrecursorsScorer(default_config)(tree) == 8 assert NumberOfPrecursorsInStockScorer(default_config)(tree) == 8 assert PriceSumScorer(default_config)(tree) == 8 cost_score = RouteCostScorer(default_config)(tree) assert pytest.approx(cost_score, abs=1e-3) == 77.4797