diff --git a/poetry.lock b/poetry.lock index 64670debc..408535ddf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1754,13 +1754,13 @@ testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs [[package]] name = "importlib-resources" -version = "6.1.1" +version = "6.1.2" description = "Read resources from Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "importlib_resources-6.1.1-py3-none-any.whl", hash = "sha256:e8bf90d8213b486f428c9c39714b920041cb02c184686a3dee24905aaa8105d6"}, - {file = "importlib_resources-6.1.1.tar.gz", hash = "sha256:3893a00122eafde6894c59914446a512f728a0c1a45f9bb9b63721b6bacf0b4a"}, + {file = "importlib_resources-6.1.2-py3-none-any.whl", hash = "sha256:9a0a862501dc38b68adebc82970140c9e4209fc99601782925178f8386339938"}, + {file = "importlib_resources-6.1.2.tar.gz", hash = "sha256:308abf8474e2dba5f867d279237cd4076482c3de7104a40b41426370e891549b"}, ] [package.dependencies] @@ -1768,7 +1768,7 @@ zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} [package.extras] docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-ruff", "zipp (>=3.17)"] +testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-ruff (>=0.2.1)", "zipp (>=3.17)"] [[package]] name = "iniconfig" @@ -5808,19 +5808,20 @@ tui = ["trogon"] [[package]] name = "sssom" -version = "0.4.0" +version = "0.4.4" description = "Operations on SSSOM mapping tables" optional = false python-versions = ">=3.8,<4.0" files = [ - {file = "sssom-0.4.0-py3-none-any.whl", hash = "sha256:5510f58b8a82528afe7d66df9f2bded1415bb95e491cb93f92925badbec62774"}, - {file = "sssom-0.4.0.tar.gz", hash = "sha256:263fa80456b74068dbd64126395875f6535c6b6f2311e4811c5dbac786d77ce1"}, + {file = "sssom-0.4.4-py3-none-any.whl", hash = "sha256:bc2a01865ea2cf1805420d82a1cbd7d0e180fc86af77f4e3eedd4fed5a569fc7"}, + {file = "sssom-0.4.4.tar.gz", hash = "sha256:9395c5614f2d1ff321450100d5448388642dccca6060dd8c03a5664d227da7b0"}, ] [package.dependencies] click = ">=8.1.6" curies = ">=0.7.3" deprecation = ">=2.1.0,<3.0.0" +importlib-resources = ">=6.1.1,<7.0.0" linkml-runtime = ">=1.5.5" networkx = {version = ">=3.1", extras = ["networkx"]} pandas = ">1.0.3" @@ -6503,4 +6504,4 @@ seaborn = [] [metadata] lock-version = "2.0" python-versions = ">=3.9,<4.0.0" -content-hash = "fb57c83e4ed702ced737faed65e39c18ce4cc7d84b44ca61df90bc9d8c6f1812" +content-hash = "17a886d77e5854e646118c3356fcee11c1577915d767782e93808aa5c183055b" diff --git a/pyproject.toml b/pyproject.toml index 7038362de..2d5cdff38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ SQLAlchemy = ">=1.4.32" linkml-runtime = ">=1.5.3" linkml-renderer = ">=0.3.0" networkx = ">=2.7.1" -sssom = "^0.4.0" +sssom = "^0.4.4" ratelimit = ">=2.2.1" appdirs = ">=1.4.4" semsql = ">=0.3.1" @@ -38,6 +38,7 @@ click = "*" semsimian = "^0.2.1" urllib3 = {version = "< 2", optional = true} pydantic = "*" +importlib-resources = ">=6.1.2" [tool.poetry.dev-dependencies] pytest = "^7.1.3" diff --git a/tests/test_cli.py b/tests/test_cli.py index 500a4c9c9..d81964fb3 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -134,7 +134,8 @@ def test_languages(self): def test_info(self): for input_arg in [TEST_ONT, f"sqlite:{TEST_DB}", TEST_OWL_RDF]: result = self.runner.invoke( - main, ["-i", str(input_arg), "info", NUCLEUS, "-o", TEST_OUT, "-D", "x,d"] + main, + ["-i", str(input_arg), "info", NUCLEUS, "-o", TEST_OUT, "-D", "x,d"], ) result.stdout result.stderr @@ -162,12 +163,14 @@ def test_labels(self): assert "cytoplasm" in result.stdout assert "IAO:0000078" in result.stdout result = self.runner.invoke( - main, ["-i", str(input_arg), "labels", ".all", "--if-absent", "present-only"] + main, + ["-i", str(input_arg), "labels", ".all", "--if-absent", "present-only"], ) assert "cytoplasm" in result.stdout assert "IAO:0000078" not in result.stdout result = self.runner.invoke( - main, ["-i", str(input_arg), "labels", ".all", "--if-absent", "absent-only"] + main, + ["-i", str(input_arg), "labels", ".all", "--if-absent", "absent-only"], ) assert "cytoplasm" not in result.stdout assert "IAO:0000078" in result.stdout @@ -178,21 +181,48 @@ def test_definitions(self): self.assertIn("cytoplasm", result.stdout, "cytoplasm should be defined in .all") self.assertIn("IAO:0000078", result.stdout, "IAO:0000078 should be included in .all") result = self.runner.invoke( - main, ["-i", str(input_arg), "definitions", ".all", "--if-absent", "present-only"] + main, + [ + "-i", + str(input_arg), + "definitions", + ".all", + "--if-absent", + "present-only", + ], ) self.assertIn( - "cytoplasm", result.stdout, "cytoplasm should be included with present-only query" + "cytoplasm", + result.stdout, + "cytoplasm should be included with present-only query", ) self.assertNotIn("IAO:0000078", result.stdout) result = self.runner.invoke( - main, ["-i", str(input_arg), "definitions", ".all", "--if-absent", "absent-only"] + main, + [ + "-i", + str(input_arg), + "definitions", + ".all", + "--if-absent", + "absent-only", + ], ) self.assertNotIn( - "cytoplasm", result.stdout, "cytoplasm should be excluded with absent-only query" + "cytoplasm", + result.stdout, + "cytoplasm should be excluded with absent-only query", ) self.assertIn("IAO:0000078", result.stdout) result = self.runner.invoke( - main, ["-i", str(input_arg), "definitions", "--additional-metadata", "cytoplasm"] + main, + [ + "-i", + str(input_arg), + "definitions", + "--additional-metadata", + "cytoplasm", + ], ) self.assertIn( "ISBN:0198547684", @@ -212,13 +242,33 @@ def test_obograph_local(self): out = self._out(outpath) assert "GO:0043226" in out self.runner.invoke( - main, ["-i", input_arg, "ancestors", "-p", "i", "plasma membrane", "-o", outpath] + main, + [ + "-i", + input_arg, + "ancestors", + "-p", + "i", + "plasma membrane", + "-o", + outpath, + ], ) out = self._out(outpath) assert "GO:0016020" in out assert "GO:0043226" not in out self.runner.invoke( - main, ["-i", input_arg, "descendants", "-p", "i", "GO:0016020", "-o", outpath] + main, + [ + "-i", + input_arg, + "descendants", + "-p", + "i", + "GO:0016020", + "-o", + outpath, + ], ) out = self._out(outpath) # TODO: @@ -397,7 +447,11 @@ def test_tree(self): [NUCLEUS, IMBO], [CELLULAR_COMPONENT, CELL], ), - (["-p", "i,p", CYTOPLASM, "--down"], [CYTOPLASM, VACUOLE, "GO:0110165"], []), + ( + ["-p", "i,p", CYTOPLASM, "--down"], + [CYTOPLASM, VACUOLE, "GO:0110165"], + [], + ), ] for args, expected_in, expected_not_in in cases: result = self.runner.invoke(main, ["-i", input_arg, "tree", *args]) @@ -427,7 +481,14 @@ def test_obsoletes(self): for input_arg in input_args: result = self.runner.invoke( main, - ["-i", input_arg, "obsoletes", "-o", TEST_OUT, "--show-migration-relationships"], + [ + "-i", + input_arg, + "obsoletes", + "-o", + TEST_OUT, + "--show-migration-relationships", + ], ) self.assertEqual(0, result.exit_code) with open(TEST_OUT) as file: @@ -440,7 +501,17 @@ def test_obsoletes(self): def test_mappings_local(self): result = self.runner.invoke( - main, ["-i", str(TEST_ONT), "mappings", "GO:0016740", "-o", TEST_OUT, "-O", "csv"] + main, + [ + "-i", + str(TEST_ONT), + "mappings", + "GO:0016740", + "-o", + TEST_OUT, + "-O", + "csv", + ], ) self.assertEqual(0, result.exit_code) out = self._out() @@ -588,7 +659,15 @@ def test_extract(self): for dangling in [True, False]: logging.info(f"input={input}, output_format={output_format}") query = [".desc//p=i", IMBO, ".anc//p=i", IMBO] - cmd = ["-i", str(input), "extract", "-o", TEST_OUT, "-O", output_format] + query + cmd = [ + "-i", + str(input), + "extract", + "-o", + TEST_OUT, + "-O", + output_format, + ] + query # print(cmd) if dangling: cmd += ["--dangling"] @@ -634,7 +713,16 @@ def test_taxon_constraints_local(self): for fmt in ["yaml", "csv", "html"]: result = self.runner.invoke( main, - ["-i", str(input_arg), "taxon-constraints", NUCLEUS, "-o", TEST_OUT, "-O", fmt], + [ + "-i", + str(input_arg), + "taxon-constraints", + NUCLEUS, + "-o", + TEST_OUT, + "-O", + fmt, + ], ) self.assertEqual(0, result.exit_code) contents = self._out() @@ -944,7 +1032,13 @@ def test_lexmatch(self): nucleus_match = "XX:1" intracellular_match = "XX:2" OTHER_ONTOLOGY = f"{INPUT_DIR}/alignment-test.obo" - for input_arg in [TEST_SIMPLE_OBO, TEST_OBOJSON, TEST_OWL_RDF, TEST_ONT, TEST_DB]: + for input_arg in [ + TEST_SIMPLE_OBO, + TEST_OBOJSON, + TEST_OWL_RDF, + TEST_ONT, + TEST_DB, + ]: for reversed in [False, True]: if reversed: args = [ @@ -963,7 +1057,14 @@ def test_lexmatch(self): result = self.runner.invoke( main, args - + ["lexmatch", "-R", RULES_FILE, "-o", outfile, "--no-ensure-strict-prefixes"], + + [ + "lexmatch", + "-R", + RULES_FILE, + "-o", + outfile, + "--no-ensure-strict-prefixes", + ], ) err = result.stderr self.assertEqual(0, result.exit_code) @@ -1096,6 +1197,7 @@ def test_diffs(self): catalytic_activity_changed = any( c.about_node == CATALYTIC_ACTIVITY for c in changes if isinstance(c, NodeChange) ) + if simple: self.assertFalse(catalytic_activity_changed) else: diff --git a/tests/test_implementations/__init__.py b/tests/test_implementations/__init__.py index 0bb7d7f8c..d84d4ca50 100644 --- a/tests/test_implementations/__init__.py +++ b/tests/test_implementations/__init__.py @@ -208,7 +208,9 @@ def test_owl_types(self, oi: BasicOntologyInterface, skip_oio=False): for e2, expected2 in cases: if expected2 != expected: test.assertNotIn( - e2, entities, f"{e2} unexpectedly found in query for {expected}" + e2, + entities, + f"{e2} unexpectedly found in query for {expected}", ) def test_labels(self, oi: BasicOntologyInterface): @@ -299,7 +301,8 @@ def test_metadata(self, oi: MetadataInterface): m = oi.entity_metadata_map(INTRACELLULAR) test.assertIn(TERM_TRACKER_ITEM, m.keys()) # TODO: check this generalizes test.assertIn( - "https://github.com/geneontology/go-ontology/issues/17776", m[TERM_TRACKER_ITEM] + "https://github.com/geneontology/go-ontology/issues/17776", + m[TERM_TRACKER_ITEM], ) def test_obsolete_entities(self, oi: SearchInterface): @@ -314,7 +317,8 @@ def test_obsolete_entities(self, oi: SearchInterface): obsoletes = list(oi.obsoletes()) test.assertCountEqual(["CL:2", "CL:3", "CL:5", "CL:6"], obsoletes_excluding_merged) test.assertCountEqual( - ["CL:1a1", "CL:1a2", "CL:4a1", "CL:1a3", "CL:2", "CL:3", "CL:5", "CL:6"], obsoletes + ["CL:1a1", "CL:1a2", "CL:4a1", "CL:1a3", "CL:2", "CL:3", "CL:5", "CL:6"], + obsoletes, ) all_entities = set(list(oi.entities(filter_obsoletes=False))) all_non_obsolete_entities = set(list(oi.entities(filter_obsoletes=True))) @@ -326,7 +330,7 @@ def test_obsolete_entities(self, oi: SearchInterface): # test.assertCountEqual(obsoletes, all_entities.difference(all_non_obsolete_entities)) for x in obsoletes: mm = oi.entity_metadata_map(x) - test.assertEquals([True], mm[DEPRECATED_PREDICATE]) + test.assertEqual([True], mm[DEPRECATED_PREDICATE]) cases = [ ("CL:1", [], []), ("CL:1a1", ["CL:1"], []), @@ -350,7 +354,9 @@ def test_obsolete_entities(self, oi: SearchInterface): if r[1] == CONSIDER_REPLACEMENT ] test.assertCountEqual( - replaced_by, actual_replaced_by, f"replaced_by did not match for {curie}" + replaced_by, + actual_replaced_by, + f"replaced_by did not match for {curie}", ) test.assertCountEqual(consider, actual_consider) for r in replaced_by: @@ -438,7 +444,9 @@ def test_multilingual(self, oi: BasicOntologyInterface): else: test.assertEqual(1, len(defns), f"Expected one definition for {lang} for {curie}") test.assertEqual( - expected_definition, defns[0][1], f"Definition for {lang} did not match" + expected_definition, + defns[0][1], + f"Definition for {lang} did not match", ) def test_sssom_mappings(self, oi: MappingProviderInterface): @@ -507,7 +515,9 @@ def test_sssom_mappings(self, oi: MappingProviderInterface): test.assertEqual( m_upper, oi.normalize( - curie.lower(), target_prefixes=[prefix.upper()], source_prefixes=["GO"] + curie.lower(), + target_prefixes=[prefix.upper()], + source_prefixes=["GO"], ), ) mappings = list(oi.sssom_mappings(curie)) @@ -549,11 +559,22 @@ def test_relationships(self, oi: BasicOntologyInterface, ignore_annotation_edges all_relations = list(oi.relationships()) test.assertGreater(len(all_relations), 0) cases = [ - (NUCLEUS, False, [(NUCLEUS, IS_A, IMBO), (NUCLEUS, ONLY_IN_TAXON, EUKARYOTA)]), + ( + NUCLEUS, + False, + [(NUCLEUS, IS_A, IMBO), (NUCLEUS, ONLY_IN_TAXON, EUKARYOTA)], + ), (VACUOLE, True, [(VACUOLE, IS_A, IMBO), (VACUOLE, PART_OF, CYTOPLASM)]), (SUBATOMIC_PARTICLE, True, []), (HUMAN, True, [(HUMAN, IS_A, MAMMALIA)]), - (CELL, True, [(CELL, IS_A, "CARO:0000003"), (CELL, ONLY_IN_TAXON, CELLULAR_ORGANISMS)]), + ( + CELL, + True, + [ + (CELL, IS_A, "CARO:0000003"), + (CELL, ONLY_IN_TAXON, CELLULAR_ORGANISMS), + ], + ), (CELLULAR_COMPONENT, True, [(CELLULAR_COMPONENT, IS_A, "BFO:0000040")]), ] for curie, complete, expected_rels in cases: @@ -609,11 +630,15 @@ def test_rbox_relationships(self, oi: BasicOntologyInterface): ]: parents = [r[2] for r in oi.relationships([curie], predicates=[p])] test.assertCountEqual( - expected, parents, f"expected {p}({curie}) = {expected} got {parents}" + expected, + parents, + f"expected {p}({curie}) = {expected} got {parents}", ) parents = [r[2] for r in oi.relationships([curie]) if r[1] == p] test.assertCountEqual( - expected, parents, f"expected {p}({curie}) = {expected} got {parents}" + expected, + parents, + f"expected {p}({curie}) = {expected} got {parents}", ) def test_equiv_relationships(self, oi: BasicOntologyInterface): @@ -661,10 +686,14 @@ def test_obograph_node(self, oi: OboGraphInterface): meta = node.meta test.assertTrue(meta.definition.val.startswith("A membrane-")) test.assertCountEqual( - ["NIF_Subcellular:sao1702920020", "Wikipedia:Cell_nucleus"], [s.val for s in meta.xrefs] + ["NIF_Subcellular:sao1702920020", "Wikipedia:Cell_nucleus"], + [s.val for s in meta.xrefs], ) test.assertCountEqual( - [("hasExactSynonym", "cell nucleus"), ("hasNarrowSynonym", "horsetail nucleus")], + [ + ("hasExactSynonym", "cell nucleus"), + ("hasNarrowSynonym", "horsetail nucleus"), + ], [(s.pred, s.val) for s in meta.synonyms], ) test.assertIn("obo:go#goslim_yeast", meta.subsets) @@ -793,11 +822,13 @@ def test_disjoint_with(self, oi: OwlInterface): ] for pair in pairs: test.assertTrue( - pair in expected or pair[::-1] in expected, f"Unexpected disjoint pair: {pair}" + pair in expected or pair[::-1] in expected, + f"Unexpected disjoint pair: {pair}", ) for case in expected: test.assertTrue( - case in pairs or case[::-1] in pairs, f"Expected disjoint pair not found: {case}" + case in pairs or case[::-1] in pairs, + f"Expected disjoint pair not found: {case}", ) for case in expected: for c in case: @@ -1090,8 +1121,26 @@ def test_subgraph_from_traversal(self, oi: OboGraphInterface): [IMBO], [(NUCLEUS, IS_A, IMBO)], ), - ([], [IS_A, PART_OF], Distance.TRANSITIVE, Distance.TRANSITIVE, 0, 0, [], []), - ([NUCLEUS, VACUOLE], [IS_A, PART_OF], Distance.ZERO, Distance.ZERO, 0, 0, [], []), + ( + [], + [IS_A, PART_OF], + Distance.TRANSITIVE, + Distance.TRANSITIVE, + 0, + 0, + [], + [], + ), + ( + [NUCLEUS, VACUOLE], + [IS_A, PART_OF], + Distance.ZERO, + Distance.ZERO, + 0, + 0, + [], + [], + ), ] for case in cases: ( @@ -1134,7 +1183,9 @@ def test_extract_graph(self, oi: OboGraphInterface, test_metadata=False): f"failed for case: {case}, got nodes: {retrieved_class_nodes}", ) test.assertEqual( - num_edges, len(g.edges), f"failed for case: {case}, got edges: {g.edges}" + num_edges, + len(g.edges), + f"failed for case: {case}, got edges: {g.edges}", ) node_ids = [n.id for n in g.nodes] for node_id in nodes: @@ -1378,7 +1429,11 @@ def test_patcher_obsoletion_chains(self, get_adapter_function: Callable): None, [(NUCLEAR_ENVELOPE, PART_OF, CELLULAR_ANATOMICAL_ENTITY)], ), - ([NUCLEAR_ENVELOPE], None, [(NUCLEAR_MEMBRANE, PART_OF, ENDOMEMBRANE_SYSTEM)]), + ( + [NUCLEAR_ENVELOPE], + None, + [(NUCLEAR_MEMBRANE, PART_OF, ENDOMEMBRANE_SYSTEM)], + ), ( [NUCLEAR_ENVELOPE, ENDOMEMBRANE_SYSTEM], None, @@ -1392,10 +1447,17 @@ def test_patcher_obsoletion_chains(self, get_adapter_function: Callable): ( [CYTOPLASMIC_REGION], None, - [(CELL_CORTEX_REGION, IS_A, CYTOPLASM), (CELL_CORTEX_REGION, PART_OF, CYTOPLASM)], + [ + (CELL_CORTEX_REGION, IS_A, CYTOPLASM), + (CELL_CORTEX_REGION, PART_OF, CYTOPLASM), + ], ), ([CELL_CORTEX_REGION, CELL_CORTEX], None, []), - ([CELL_CORTEX_REGION, CELL_CORTEX, CYTOPLASMIC_REGION, CYTOPLASM], None, []), + ( + [CELL_CORTEX_REGION, CELL_CORTEX, CYTOPLASMIC_REGION, CYTOPLASM], + None, + [], + ), ( [CYTOPLASM, CELL_CORTEX_REGION, CELL_CORTEX, CYTOPLASMIC_REGION], "order of obsoletion is wrong", @@ -1426,7 +1488,8 @@ def test_patcher_obsoletion_chains(self, get_adapter_function: Callable): for o in obsoletions: test.assertIn(o, refreshed_obsolete_entities) test.assertCountEqual( - obsoletions, set(refreshed_obsolete_entities) - set(current_obsolete_entities) + obsoletions, + set(refreshed_obsolete_entities) - set(current_obsolete_entities), ) refreshed_relationships = list(oi.relationships()) for e in expected_edges: @@ -1475,7 +1538,8 @@ def test_summary_statistics(self, oi: SummaryStatisticsInterface): test.assertEqual(255, stats.distinct_synonym_count) test.assertEqual(264, stats.synonym_statement_count) test.assertEqual( - 136, stats.synonym_statement_count_by_predicate[HAS_EXACT_SYNONYM].filtered_count + 136, + stats.synonym_statement_count_by_predicate[HAS_EXACT_SYNONYM].filtered_count, ) test.assertEqual(152, stats.mapping_statement_count_by_predicate[HAS_DBXREF].filtered_count) stats_cc = oi.branch_summary_statistics("cc", branch_roots=[CELLULAR_COMPONENT]) @@ -1486,13 +1550,15 @@ def test_summary_statistics(self, oi: SummaryStatisticsInterface): test.assertEqual(29, stats_cc.distinct_synonym_count) test.assertEqual(29, stats_cc.synonym_statement_count) test.assertEqual( - 14, stats_cc.synonym_statement_count_by_predicate[HAS_EXACT_SYNONYM].filtered_count + 14, + stats_cc.synonym_statement_count_by_predicate[HAS_EXACT_SYNONYM].filtered_count, ) test.assertEqual( 17, stats_cc.mapping_statement_count_by_predicate[HAS_DBXREF].filtered_count ) stats_ns = oi.branch_summary_statistics( - "cc_namespace", property_values={"oio:hasOBONamespace": "cellular_component"} + "cc_namespace", + property_values={"oio:hasOBONamespace": "cellular_component"}, ) test.assertEqual(23, stats_ns.class_count) test.assertEqual(23, stats_ns.class_count_with_text_definitions) @@ -1501,7 +1567,8 @@ def test_summary_statistics(self, oi: SummaryStatisticsInterface): test.assertEqual(29, stats_ns.distinct_synonym_count) test.assertEqual(29, stats_ns.synonym_statement_count) test.assertEqual( - 14, stats_ns.synonym_statement_count_by_predicate[HAS_EXACT_SYNONYM].filtered_count + 14, + stats_ns.synonym_statement_count_by_predicate[HAS_EXACT_SYNONYM].filtered_count, ) test.assertEqual( 17, stats_ns.mapping_statement_count_by_predicate[HAS_DBXREF].filtered_count @@ -1606,10 +1673,12 @@ def test_store_associations(self, oi: AssociationProviderInterface): [PROTEIN1], list(associations_subjects(oi.associations(objects=[VACUOLE]))) ) test.assertEqual( - [PROTEIN1], list(associations_subjects(oi.associations(objects=[NUCLEUS, VACUOLE]))) + [PROTEIN1], + list(associations_subjects(oi.associations(objects=[NUCLEUS, VACUOLE]))), ) test.assertEqual( - [PROTEIN2], list(associations_subjects(oi.associations(objects=[NUCLEAR_MEMBRANE]))) + [PROTEIN2], + list(associations_subjects(oi.associations(objects=[NUCLEAR_MEMBRANE]))), ) # closures test.assertEqual( @@ -1681,11 +1750,32 @@ def test_class_enrichment(self, oi: ClassEnrichmentCalculationInterface): ([GENE1, GENE6, GENE7], 0.5, None, None, None, [NUCLEUS]), ([GENE1, GENE6, GENE7], 0.5, [], None, None, [NUCLEAR_ENVELOPE]), # exact overlap - ([GENE3, GENE6, GENE7], 0.5, None, None, [NUCLEAR_ENVELOPE], [NUCLEAR_ENVELOPE]), + ( + [GENE3, GENE6, GENE7], + 0.5, + None, + None, + [NUCLEAR_ENVELOPE], + [NUCLEAR_ENVELOPE], + ), # nuclear membrane is before nucleus as less common overall - ([GENE1, GENE2, GENE3], 1.0, None, None, [NUCLEAR_MEMBRANE], [NUCLEAR_MEMBRANE]), + ( + [GENE1, GENE2, GENE3], + 1.0, + None, + None, + [NUCLEAR_MEMBRANE], + [NUCLEAR_MEMBRANE], + ), ([GENE1, GENE2, GENE3], 0.05, None, None, [], []), - ([GENE1, GENE2, GENE4, GENE5, GENE6], 0.5, None, None, [VACUOLE, CYTOPLASM], [VACUOLE]), + ( + [GENE1, GENE2, GENE4, GENE5, GENE6], + 0.5, + None, + None, + [VACUOLE, CYTOPLASM], + [VACUOLE], + ), ([GENE8, GENE9], 1.0, None, None, [IMBO], None), ] for case in cases: @@ -1755,7 +1845,9 @@ def test_common_ancestors(self, oi: SemanticSimilarityInterface): if expected_ancs is not None: test.assertCountEqual(expected_ancs, ancs) test.assertCountEqual( - expected_mrcas, mrcas, f"different MRCA results for {x} v {y} with {preds}" + expected_mrcas, + mrcas, + f"different MRCA results for {x} v {y} with {preds}", ) for a in mrcas: test.assertIn(a, ancs) @@ -1807,7 +1899,9 @@ def test_information_content_scores( ) m = {} for curie, score in oi.information_content_scores( - terms, object_closure_predicates=[IS_A, PART_OF], use_associations=use_associations + terms, + object_closure_predicates=[IS_A, PART_OF], + use_associations=use_associations, ): m[curie] = score test.assertGreater(len(m), 0) @@ -1877,7 +1971,9 @@ def test_pairwise_similarity(self, oi: SemanticSimilarityInterface): test.assertIsNone(pair.phenodigm_score) else: test.assertGreater( - pair.phenodigm_score, 0.5, f"expected phenodigm match for {pair}" + pair.phenodigm_score, + 0.5, + f"expected phenodigm match for {pair}", ) distances[(pair.subject_id, pair.object_id)] = 1 - pair.jaccard_similarity # test triangle inequality @@ -1916,7 +2012,9 @@ def test_pairwise_similarity(self, oi: SemanticSimilarityInterface): ts1, ts2, ps, expected_avg, expected_max = ts sim = oi.termset_pairwise_similarity(ts1, ts2, predicates=ps, labels=True) test.assertLess( - abs(sim.average_score - expected_avg), error_range, f"TermSet: {ts} Sim: {sim}" + abs(sim.average_score - expected_avg), + error_range, + f"TermSet: {ts} Sim: {sim}", ) test.assertLess(abs(sim.best_score - expected_max), error_range) @@ -1927,7 +2025,11 @@ def test_annotate_text(self, oi: TextAnnotatorInterface): ( "The nucleus is the part of the cell that contains the DNA.", 3, - [(NUCLEUS, "nucleus", 5, 11), (PART_OF, "part of", 20, 26), (CELL, "cell", 32, 35)], + [ + (NUCLEUS, "nucleus", 5, 11), + (PART_OF, "part of", 20, 26), + (CELL, "cell", 32, 35), + ], ), ] for text, n, expected in cases: @@ -1949,7 +2051,15 @@ def test_entities_metadata_statements(self, oi: BasicOntologyInterface): ( [MEMBRANE], [OIO_CREATION_DATE], - [("GO:0016020", "oio:creation_date", "2014-03-06T11:37:54Z", "xsd:string", {})], + [ + ( + "GO:0016020", + "oio:creation_date", + "2014-03-06T11:37:54Z", + "xsd:string", + {}, + ) + ], ), ( [MEMBRANE], @@ -1962,9 +2072,27 @@ def test_entities_metadata_statements(self, oi: BasicOntologyInterface): "xsd:string", {}, ), - ("GO:0016020", "oio:creation_date", "2014-03-06T11:37:54Z", "xsd:string", {}), - ("GO:0016020", "oio:hasAlternativeId", "GO:0098589", "xsd:string", {}), - ("GO:0016020", "oio:hasAlternativeId", "GO:0098805", "xsd:string", {}), + ( + "GO:0016020", + "oio:creation_date", + "2014-03-06T11:37:54Z", + "xsd:string", + {}, + ), + ( + "GO:0016020", + "oio:hasAlternativeId", + "GO:0098589", + "xsd:string", + {}, + ), + ( + "GO:0016020", + "oio:hasAlternativeId", + "GO:0098805", + "xsd:string", + {}, + ), ( "GO:0016020", "oio:hasDbXref", @@ -1972,19 +2100,61 @@ def test_entities_metadata_statements(self, oi: BasicOntologyInterface): "xsd:string", {}, ), - ("GO:0016020", "oio:hasNarrowSynonym", "membrane region", "xsd:string", {}), - ("GO:0016020", "oio:hasNarrowSynonym", "region of membrane", "xsd:string", {}), - ("GO:0016020", "oio:hasNarrowSynonym", "whole membrane", "xsd:string", {}), - ("GO:0016020", "oio:hasOBONamespace", "cellular_component", "xsd:string", {}), + ( + "GO:0016020", + "oio:hasNarrowSynonym", + "membrane region", + "xsd:string", + {}, + ), + ( + "GO:0016020", + "oio:hasNarrowSynonym", + "region of membrane", + "xsd:string", + {}, + ), + ( + "GO:0016020", + "oio:hasNarrowSynonym", + "whole membrane", + "xsd:string", + {}, + ), + ( + "GO:0016020", + "oio:hasOBONamespace", + "cellular_component", + "xsd:string", + {}, + ), ("GO:0016020", "oio:id", "GO:0016020", "xsd:string", {}), ("GO:0016020", "oio:inSubset", "obo:go#goslim_yeast", None, {}), ("GO:0016020", "oio:inSubset", "obo:go#goslim_plant", None, {}), ("GO:0016020", "oio:inSubset", "obo:go#goslim_pir", None, {}), - ("GO:0016020", "oio:inSubset", "obo:go#goslim_metagenomics", None, {}), - ("GO:0016020", "oio:inSubset", "obo:go#goslim_flybase_ribbon", None, {}), + ( + "GO:0016020", + "oio:inSubset", + "obo:go#goslim_metagenomics", + None, + {}, + ), + ( + "GO:0016020", + "oio:inSubset", + "obo:go#goslim_flybase_ribbon", + None, + {}, + ), ("GO:0016020", "oio:inSubset", "obo:go#goslim_chembl", None, {}), ("GO:0016020", "oio:inSubset", "obo:go#goslim_candida", None, {}), - ("GO:0016020", "oio:inSubset", "obo:go#goslim_aspergillus", None, {}), + ( + "GO:0016020", + "oio:inSubset", + "obo:go#goslim_aspergillus", + None, + {}, + ), ("GO:0016020", "rdfs:label", "membrane", "xsd:string", {}), ], ), @@ -1995,11 +2165,29 @@ def test_entities_metadata_statements(self, oi: BasicOntologyInterface): ("GO:0016020", "oio:inSubset", "obo:go#goslim_yeast", None, {}), ("GO:0016020", "oio:inSubset", "obo:go#goslim_plant", None, {}), ("GO:0016020", "oio:inSubset", "obo:go#goslim_pir", None, {}), - ("GO:0016020", "oio:inSubset", "obo:go#goslim_metagenomics", None, {}), - ("GO:0016020", "oio:inSubset", "obo:go#goslim_flybase_ribbon", None, {}), + ( + "GO:0016020", + "oio:inSubset", + "obo:go#goslim_metagenomics", + None, + {}, + ), + ( + "GO:0016020", + "oio:inSubset", + "obo:go#goslim_flybase_ribbon", + None, + {}, + ), ("GO:0016020", "oio:inSubset", "obo:go#goslim_chembl", None, {}), ("GO:0016020", "oio:inSubset", "obo:go#goslim_candida", None, {}), - ("GO:0016020", "oio:inSubset", "obo:go#goslim_aspergillus", None, {}), + ( + "GO:0016020", + "oio:inSubset", + "obo:go#goslim_aspergillus", + None, + {}, + ), ], ), ( @@ -2020,22 +2208,70 @@ def test_entities_metadata_statements(self, oi: BasicOntologyInterface): "xsd:string", {}, ), - ("GO:0005634", "oio:hasDbXref", "Wikipedia:Cell_nucleus", "xsd:string", {}), - ("GO:0005634", "oio:hasExactSynonym", "cell nucleus", "xsd:string", {}), - ("GO:0005634", "oio:hasNarrowSynonym", "horsetail nucleus", "xsd:string", {}), - ("GO:0005634", "oio:hasOBONamespace", "cellular_component", "xsd:string", {}), + ( + "GO:0005634", + "oio:hasDbXref", + "Wikipedia:Cell_nucleus", + "xsd:string", + {}, + ), + ( + "GO:0005634", + "oio:hasExactSynonym", + "cell nucleus", + "xsd:string", + {}, + ), + ( + "GO:0005634", + "oio:hasNarrowSynonym", + "horsetail nucleus", + "xsd:string", + {}, + ), + ( + "GO:0005634", + "oio:hasOBONamespace", + "cellular_component", + "xsd:string", + {}, + ), ("GO:0005634", "oio:id", "GO:0005634", "xsd:string", {}), ("GO:0005634", "oio:inSubset", "obo:go#goslim_yeast", None, {}), ("GO:0005634", "oio:inSubset", "obo:go#goslim_plant", None, {}), ("GO:0005634", "oio:inSubset", "obo:go#goslim_pir", None, {}), ("GO:0005634", "oio:inSubset", "obo:go#goslim_mouse", None, {}), - ("GO:0005634", "oio:inSubset", "obo:go#goslim_metagenomics", None, {}), + ( + "GO:0005634", + "oio:inSubset", + "obo:go#goslim_metagenomics", + None, + {}, + ), ("GO:0005634", "oio:inSubset", "obo:go#goslim_generic", None, {}), - ("GO:0005634", "oio:inSubset", "obo:go#goslim_flybase_ribbon", None, {}), - ("GO:0005634", "oio:inSubset", "obo:go#goslim_drosophila", None, {}), + ( + "GO:0005634", + "oio:inSubset", + "obo:go#goslim_flybase_ribbon", + None, + {}, + ), + ( + "GO:0005634", + "oio:inSubset", + "obo:go#goslim_drosophila", + None, + {}, + ), ("GO:0005634", "oio:inSubset", "obo:go#goslim_chembl", None, {}), ("GO:0005634", "oio:inSubset", "obo:go#goslim_candida", None, {}), - ("GO:0005634", "oio:inSubset", "obo:go#goslim_aspergillus", None, {}), + ( + "GO:0005634", + "oio:inSubset", + "obo:go#goslim_aspergillus", + None, + {}, + ), ("GO:0005634", "oio:inSubset", "obo:go#goslim_agr", None, {}), ("GO:0005634", "rdfs:label", "nucleus", "xsd:string", {}), ], @@ -2048,13 +2284,37 @@ def test_entities_metadata_statements(self, oi: BasicOntologyInterface): ("GO:0005634", "oio:inSubset", "obo:go#goslim_plant", None, {}), ("GO:0005634", "oio:inSubset", "obo:go#goslim_pir", None, {}), ("GO:0005634", "oio:inSubset", "obo:go#goslim_mouse", None, {}), - ("GO:0005634", "oio:inSubset", "obo:go#goslim_metagenomics", None, {}), + ( + "GO:0005634", + "oio:inSubset", + "obo:go#goslim_metagenomics", + None, + {}, + ), ("GO:0005634", "oio:inSubset", "obo:go#goslim_generic", None, {}), - ("GO:0005634", "oio:inSubset", "obo:go#goslim_flybase_ribbon", None, {}), - ("GO:0005634", "oio:inSubset", "obo:go#goslim_drosophila", None, {}), + ( + "GO:0005634", + "oio:inSubset", + "obo:go#goslim_flybase_ribbon", + None, + {}, + ), + ( + "GO:0005634", + "oio:inSubset", + "obo:go#goslim_drosophila", + None, + {}, + ), ("GO:0005634", "oio:inSubset", "obo:go#goslim_chembl", None, {}), ("GO:0005634", "oio:inSubset", "obo:go#goslim_candida", None, {}), - ("GO:0005634", "oio:inSubset", "obo:go#goslim_aspergillus", None, {}), + ( + "GO:0005634", + "oio:inSubset", + "obo:go#goslim_aspergillus", + None, + {}, + ), ("GO:0005634", "oio:inSubset", "obo:go#goslim_agr", None, {}), ], ),