Skip to content

Commit

Permalink
Merge pull request #325 from biocypher/duplicate_tail_ontologies
Browse files Browse the repository at this point in the history
#273: add unit test for duplicated tail ontologies
  • Loading branch information
slobentanzer committed Apr 19, 2024
2 parents ce78126 + 97d4370 commit 53c7e90
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
7 changes: 6 additions & 1 deletion biocypher/_misc.py
Expand Up @@ -115,7 +115,12 @@ def _get_inheritance_tree(inheritance_graph: Union[dict, nx.Graph]) -> dict:
)
if multiple_parents_present:
logger.warning(
"The ontology contains multiple inheritance (one child node has multiple parent nodes). This is not visualized in the following hierarchy tree (the child node is only added once). If you want to browse all relationships of the parsed ontology write a graphml file to disk and view this file."
"The ontology contains multiple inheritance (one child node "
"has multiple parent nodes). This is not visualized in the "
"following hierarchy tree (the child node is only added once). "
"If you wish to browse all relationships of the parsed "
"ontologies, write a graphml file to disk using "
"`to_disk = <directory>` and view this file."
)

# unlist values
Expand Down
5 changes: 3 additions & 2 deletions biocypher/_ontology.py
Expand Up @@ -695,8 +695,9 @@ def show_ontology_structure(self, to_disk: str = None, full: bool = False):
Args:
to_disk (str): If specified, the ontology structure will be saved
to disk as a GRAPHML file, to be opened in your favourite
graph visualisation tool.
to disk as a GRAPHML file at the location (directory) specified
by the `to_disk` string, to be opened in your favourite graph
visualisation tool.
full (bool): If True, the full ontology structure will be shown,
including all nodes and edges. If False, only the nodes and
Expand Down
1 change: 0 additions & 1 deletion test/test_misc.py
@@ -1,7 +1,6 @@
import logging

import pytest
import treelib
import networkx as nx

from biocypher._misc import create_tree_visualisation
Expand Down
36 changes: 36 additions & 0 deletions test/test_ontology.py
@@ -1,4 +1,5 @@
import os
import logging

import pytest
import networkx as nx
Expand Down Expand Up @@ -217,3 +218,38 @@ def test_simple_ontology(simple_ontology):
"entity",
"Thing",
]


def test_duplicated_tail_ontologies(caplog, extended_ontology_mapping):
ontology = Ontology(
head_ontology={
"url": "https://github.com/biolink/biolink-model/raw/v3.2.1/biolink-model.owl.ttl",
"root_node": "entity",
},
ontology_mapping=extended_ontology_mapping,
tail_ontologies={
"so": {
"url": "test/ontologies/so.owl",
"head_join_node": "sequence variant",
"tail_join_node": "sequence_variant",
},
"so_2": {
"url": "test/ontologies/so.owl",
"head_join_node": "device",
"tail_join_node": "sequence_variant",
},
"mondo": {
"url": "test/ontologies/mondo.owl",
"head_join_node": "disease",
"tail_join_node": "human disease",
},
},
)
assert ontology
with caplog.at_level(logging.INFO):
tree = ontology.show_ontology_structure()
assert tree
assert any(
"The ontology contains multiple inheritance" in record.message
for record in caplog.records
)

0 comments on commit 53c7e90

Please sign in to comment.