From b4f305523a365a892ceb50d15d9096275d73efdd Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Fri, 31 Jan 2025 09:48:11 +0200 Subject: [PATCH 1/5] Fix ORDO mappings query ORDO mappings were broken for a while, this commit makes the translation of ORDO xref annotations into SKOS much simpler, and hopefully a little more resilient. --- .../ordo-replace-annotation-based-mappings.ru | 335 +----------------- 1 file changed, 17 insertions(+), 318 deletions(-) diff --git a/src/sparql/ordo-replace-annotation-based-mappings.ru b/src/sparql/ordo-replace-annotation-based-mappings.ru index 4fdcdf254..87b472e8a 100644 --- a/src/sparql/ordo-replace-annotation-based-mappings.ru +++ b/src/sparql/ordo-replace-annotation-based-mappings.ru @@ -5,47 +5,7 @@ prefix oboInOwl: prefix sssom: -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - skos:broadMatch ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "- NTBT (ORPHA code's Narrower Term maps to a Broader Term).\n- Inclusion term (The ORPHA code is included under a ICD10 category and has not its own code).")) -}; - -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - skos:broadMatch ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "- NTBT (ORPHA code's Narrower Term maps to a Broader Term).\n- Attributed (The ICD10 code is attributed by Orphanet).")) -}; +## Capture broad matches DELETE { ?xref_anno a owl:Axiom ; @@ -65,50 +25,12 @@ DELETE { owl:annotatedTarget ?value ; ECO:0000218 ?mapping_precision_string . - FILTER(STRSTARTS(STR(?mapping_precision_string), "NTBT (ORPHA code's Narrower Term maps to a Broader Term)")) + FILTER( + STRSTARTS(STR(?mapping_precision_string), "- NTBT") || + STRSTARTS(STR(?mapping_precision_string), "NTBT")) }; -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - skos:broadMatch ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "- NTBT (ORPHA code's Narrower Term maps to a Broader Term).\n- Index term (The ORPHA code is listed in the ICD10 Index).")) -}; - -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - skos:broadMatch ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "- NTBT (ORPHA code's Narrower Term maps to a Broader Term).\n- Specific code (The ORPHA code has its own code in the ICD10).")) -}; +## Capture exact matches DELETE { ?xref_anno a owl:Axiom ; @@ -128,134 +50,10 @@ DELETE { owl:annotatedTarget ?value ; ECO:0000218 ?mapping_precision_string . - FILTER(STRSTARTS(STR(?mapping_precision_string), "E (Exact mapping: the two concepts are equivalent)")) -}; - -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - skos:exactMatch ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "- E (Exact mapping: the two concepts are equivalent).\n- Specific code (The ORPHA code has its own code in the ICD10).")) -}; - -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - skos:exactMatch ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "- E (Exact mapping: the two concepts are equivalent).\n- Index term (The ORPHA code is listed in the ICD10 Index).")) -}; - -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - skos:exactMatch ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "- E (Exact mapping: the two concepts are equivalent).\n- Inclusion term (The ORPHA code is included under a ICD10 category and has not its own code).")) -}; - -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - skos:narrowMatch ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "BTNT (ORPHA code's Broader Term maps to a Narrower Term)")) + FILTER(STRSTARTS(STR(?mapping_precision_string), "E (Exact ")) }; -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - skos:narrowMatch ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "- BTNT (ORPHA code's Broader Term maps to a Narrower Term).\n- Specific code (The ORPHA code has its own code in the ICD10).")) -}; - -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - skos:narrowMatch ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "- BTNT (ORPHA code's Broader Term maps to a Narrower Term).\n- Attributed (The ICD10 code is attributed by Orphanet).")) -}; +## Capture narrow matches DELETE { ?xref_anno a owl:Axiom ; @@ -275,120 +73,17 @@ DELETE { owl:annotatedTarget ?value ; ECO:0000218 ?mapping_precision_string . - FILTER(STRSTARTS(STR(?mapping_precision_string), "- BTNT (ORPHA code's Broader Term maps to a Narrower Term).\n- Inclusion term (The ORPHA code is included under a ICD10 category and has not its own code).")) + FILTER( + STRSTARTS(STR(?mapping_precision_string), "BTNT") || + STRSTARTS(STR(?mapping_precision_string), "- BTNT") + ) }; -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - skos:narrowMatch ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "- BTNT (ORPHA code's Broader Term maps to a Narrower Term).\n- Index term (The ORPHA code is listed in the ICD10 Index).")) -}; +### Remove wrong / not useful mappings DELETE { ?xref_anno a owl:Axiom ; ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - sssom:notExactMatch ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "W (Wrong mapping: the two concepts are different)")) -}; - -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - oboInOwl:hasDbXref ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "- ND (not yet decided/unable to decide).\n- Attributed (The ICD10 code is attributed by Orphanet).")) -}; - -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - oboInOwl:hasDbXref ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "ND (not yet decided/unable to decide)")) -}; - -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - oboInOwl:hasDbXref ?value . -} WHERE { - VALUES ?mapping { oboInOwl:hasDbXref } - - ?cls a owl:Class; - ?mapping ?value . - - ?xref_anno a owl:Axiom ; - owl:annotatedSource ?cls ; - owl:annotatedProperty ?mapping ; - owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . - - FILTER(STRSTARTS(STR(?mapping_precision_string), "- ND (not yet decided/unable to decide).\n- Index term (The ORPHA code is listed in the ICD10 Index).")) -}; - -DELETE { - ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . -} INSERT { - ?cls a owl:Class; - oboInOwl:hasDbXref ?value . } WHERE { VALUES ?mapping { oboInOwl:hasDbXref } @@ -401,5 +96,9 @@ DELETE { owl:annotatedTarget ?value ; ECO:0000218 ?mapping_precision_string . - FILTER(STRSTARTS(STR(?mapping_precision_string), "- ND (not yet decided/unable to decide).\n- Specific code (The ORPHA code has its own code in the ICD10).")) + FILTER( + STRSTARTS(STR(?mapping_precision_string), "W (Wrong mapping") || + STRSTARTS(STR(?mapping_precision_string), "- ND (not") || + STRSTARTS(STR(?mapping_precision_string), "ND (not") + ) }; From 71928b93c2b322abd86f9df4f2187f1fa626dfa1 Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Fri, 31 Jan 2025 09:57:34 +0200 Subject: [PATCH 2/5] Use oboInOwl source property for selecting ORDO mapping precision --- .../ordo-replace-annotation-based-mappings.ru | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sparql/ordo-replace-annotation-based-mappings.ru b/src/sparql/ordo-replace-annotation-based-mappings.ru index 87b472e8a..19877e5b4 100644 --- a/src/sparql/ordo-replace-annotation-based-mappings.ru +++ b/src/sparql/ordo-replace-annotation-based-mappings.ru @@ -9,7 +9,7 @@ prefix sssom: DELETE { ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . + oboInOwl:source ?mapping_precision_string . } INSERT { ?cls a owl:Class; skos:broadMatch ?value . @@ -23,7 +23,7 @@ DELETE { owl:annotatedSource ?cls ; owl:annotatedProperty ?mapping ; owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . + oboInOwl:source ?mapping_precision_string . FILTER( STRSTARTS(STR(?mapping_precision_string), "- NTBT") || @@ -34,7 +34,7 @@ DELETE { DELETE { ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . + oboInOwl:source ?mapping_precision_string . } INSERT { ?cls a owl:Class; skos:exactMatch ?value . @@ -48,7 +48,7 @@ DELETE { owl:annotatedSource ?cls ; owl:annotatedProperty ?mapping ; owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . + oboInOwl:source ?mapping_precision_string . FILTER(STRSTARTS(STR(?mapping_precision_string), "E (Exact ")) }; @@ -57,7 +57,7 @@ DELETE { DELETE { ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . + oboInOwl:source ?mapping_precision_string . } INSERT { ?cls a owl:Class; skos:narrowMatch ?value . @@ -71,7 +71,7 @@ DELETE { owl:annotatedSource ?cls ; owl:annotatedProperty ?mapping ; owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . + oboInOwl:source ?mapping_precision_string . FILTER( STRSTARTS(STR(?mapping_precision_string), "BTNT") || @@ -83,7 +83,7 @@ DELETE { DELETE { ?xref_anno a owl:Axiom ; - ECO:0000218 ?mapping_precision_string . + oboInOwl:source ?mapping_precision_string . } WHERE { VALUES ?mapping { oboInOwl:hasDbXref } @@ -94,7 +94,7 @@ DELETE { owl:annotatedSource ?cls ; owl:annotatedProperty ?mapping ; owl:annotatedTarget ?value ; - ECO:0000218 ?mapping_precision_string . + oboInOwl:source ?mapping_precision_string . FILTER( STRSTARTS(STR(?mapping_precision_string), "W (Wrong mapping") || From 2c5feb259d19ea8ceb33289f06e81480b56d3832 Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Sun, 2 Feb 2025 21:13:18 +0200 Subject: [PATCH 3/5] Update mondo-ingest.Makefile --- src/ontology/mondo-ingest.Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ontology/mondo-ingest.Makefile b/src/ontology/mondo-ingest.Makefile index cb68d6647..de260be9e 100644 --- a/src/ontology/mondo-ingest.Makefile +++ b/src/ontology/mondo-ingest.Makefile @@ -91,7 +91,7 @@ $(COMPONENTSDIR)/ordo.owl: $(TMPDIR)/ordo_relevant_signature.txt config/properti --update ../sparql/ordo-construct-subclass-from-part-of.ru \ --update ../sparql/ordo-construct-subsets.ru \ --update ../sparql/ordo-construct-d2g.ru \ - --update ../sparql/ordo-replace-annotation-based-mappings.ru \ + query --update ../sparql/ordo-replace-annotation-based-mappings.ru \ remove -T $(TMPDIR)/ordo_relevant_signature.txt --select complement --select "classes individuals" --trim false \ remove -T config/properties.txt --select complement --select properties --trim true \ annotate --ontology-iri $(URIBASE)/mondo/sources/ordo.owl --version-iri $(URIBASE)/mondo/sources/$(TODAY)/ordo.owl -o $@; fi From ed0f1dff218f12c090d152bde5e210a2725e084e Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Tue, 4 Feb 2025 14:49:50 +0200 Subject: [PATCH 4/5] Add leading dash to equivalence in ordo check cc @joeflack4 thanks for spotting --- src/sparql/ordo-replace-annotation-based-mappings.ru | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sparql/ordo-replace-annotation-based-mappings.ru b/src/sparql/ordo-replace-annotation-based-mappings.ru index 19877e5b4..756fdf61e 100644 --- a/src/sparql/ordo-replace-annotation-based-mappings.ru +++ b/src/sparql/ordo-replace-annotation-based-mappings.ru @@ -50,7 +50,10 @@ DELETE { owl:annotatedTarget ?value ; oboInOwl:source ?mapping_precision_string . - FILTER(STRSTARTS(STR(?mapping_precision_string), "E (Exact ")) + FILTER( + STRSTARTS(STR(?mapping_precision_string), "- E (Exact ") || + STRSTARTS(STR(?mapping_precision_string), "E (Exact ") + ) }; ## Capture narrow matches From 9c164aa3bc96aed1fff45135163ffdc44cc21b33 Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Fri, 7 Feb 2025 01:47:51 +0200 Subject: [PATCH 5/5] Remove hasDbXrefs from ordo --- src/ontology/mondo-ingest.Makefile | 1 + src/sparql/ordo-replace-annotation-based-mappings.ru | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/ontology/mondo-ingest.Makefile b/src/ontology/mondo-ingest.Makefile index de260be9e..fc22b21fa 100644 --- a/src/ontology/mondo-ingest.Makefile +++ b/src/ontology/mondo-ingest.Makefile @@ -92,6 +92,7 @@ $(COMPONENTSDIR)/ordo.owl: $(TMPDIR)/ordo_relevant_signature.txt config/properti --update ../sparql/ordo-construct-subsets.ru \ --update ../sparql/ordo-construct-d2g.ru \ query --update ../sparql/ordo-replace-annotation-based-mappings.ru \ + remove --term oboInOwl:hasDbXref --axioms "annotation" \ remove -T $(TMPDIR)/ordo_relevant_signature.txt --select complement --select "classes individuals" --trim false \ remove -T config/properties.txt --select complement --select properties --trim true \ annotate --ontology-iri $(URIBASE)/mondo/sources/ordo.owl --version-iri $(URIBASE)/mondo/sources/$(TODAY)/ordo.owl -o $@; fi diff --git a/src/sparql/ordo-replace-annotation-based-mappings.ru b/src/sparql/ordo-replace-annotation-based-mappings.ru index 756fdf61e..a18de8e6d 100644 --- a/src/sparql/ordo-replace-annotation-based-mappings.ru +++ b/src/sparql/ordo-replace-annotation-based-mappings.ru @@ -10,6 +10,7 @@ prefix sssom: DELETE { ?xref_anno a owl:Axiom ; oboInOwl:source ?mapping_precision_string . + ?cls ?mapping ?value . } INSERT { ?cls a owl:Class; skos:broadMatch ?value . @@ -35,6 +36,7 @@ DELETE { DELETE { ?xref_anno a owl:Axiom ; oboInOwl:source ?mapping_precision_string . + ?cls ?mapping ?value . } INSERT { ?cls a owl:Class; skos:exactMatch ?value . @@ -61,6 +63,7 @@ DELETE { DELETE { ?xref_anno a owl:Axiom ; oboInOwl:source ?mapping_precision_string . + ?cls ?mapping ?value . } INSERT { ?cls a owl:Class; skos:narrowMatch ?value . @@ -87,6 +90,7 @@ DELETE { DELETE { ?xref_anno a owl:Axiom ; oboInOwl:source ?mapping_precision_string . + ?cls ?mapping ?value . } WHERE { VALUES ?mapping { oboInOwl:hasDbXref }