def test_create_combine_tree_to_visjs(load_reaction_tree, tmpdir): collection = RouteCollection( reaction_trees=[ ReactionTree.from_dict(load_reaction_tree("routes_for_clustering.json", 0)), ReactionTree.from_dict(load_reaction_tree("routes_for_clustering.json", 1)), ReactionTree.from_dict(load_reaction_tree("routes_for_clustering.json", 2)), ] ) tar_filename = str(tmpdir / "routes.tar") combined = collection.combined_reaction_trees() combined.to_visjs_page(tar_filename) assert os.path.exists(tar_filename) with TarFile(tar_filename) as tarobj: assert "./route.html" in tarobj.getnames() assert len([name for name in tarobj.getnames() if name.endswith(".png")]) == 8
def test_create_combine_tree_dict_from_json(load_reaction_tree): collection = RouteCollection( reaction_trees=[ ReactionTree.from_dict(load_reaction_tree("routes_for_clustering.json", 0)), ReactionTree.from_dict(load_reaction_tree("routes_for_clustering.json", 1)), ReactionTree.from_dict(load_reaction_tree("routes_for_clustering.json", 2)), ] ) expected = load_reaction_tree("combined_example_tree.json") combined_dict = collection.combined_reaction_trees().to_dict() assert len(combined_dict["children"]) == 2 assert combined_dict["children"][0]["is_reaction"] assert len(combined_dict["children"][0]["children"]) == 2 assert len(combined_dict["children"][1]["children"]) == 2 assert len(combined_dict["children"][1]["children"][1]["children"]) == 2 assert combined_dict["children"][1]["children"][1]["children"][0]["is_reaction"] assert combined_dict == expected