diff --git a/src/ontology/Makefile b/src/ontology/Makefile index 6477c0f..e8d1e13 100644 --- a/src/ontology/Makefile +++ b/src/ontology/Makefile @@ -10,7 +10,7 @@ # More information: https://github.com/INCATools/ontology-development-kit/ # Fingerprint of the configuration file when this Makefile was last generated -CONFIG_HASH= 99af76b7f2328471bf0bb6570a80b7c7424e15a85ba9754da8106283b744a2b2 +CONFIG_HASH= 95caacb33d47877b4b17c9330f52ac6d80d553c7c3d33b0175b8d1be6c800bbc # ---------------------------------------- @@ -154,7 +154,7 @@ custom_robot_plugins: .PHONY: extra_robot_plugins -extra_robot_plugins: +extra_robot_plugins: $(ROBOT_PLUGINS_DIRECTORY)/upheno.jar # Install all ROBOT plugins to the runtime plugins directory @@ -174,6 +174,9 @@ $(ROBOT_PLUGINS_DIRECTORY)/%.jar: # Specific rules for supplementary plugins defined in configuration +$(ROBOT_PLUGINS_DIRECTORY)/upheno.jar: + curl -L -o $@ https://github.com/monarch-initiative/monarch-robot-plugins/releases/latest/download/monarch-robot-extensions.jar + # ---------------------------------------- # Release assets @@ -1105,4 +1108,4 @@ Updating the repository: endef export data -include zp.Makefile \ No newline at end of file +include zp.Makefile diff --git a/src/ontology/zapp/zp-zapp-manual.tsv b/src/ontology/zapp/zp-zapp-manual.tsv index 8402b88..9098db0 100644 --- a/src/ontology/zapp/zp-zapp-manual.tsv +++ b/src/ontology/zapp/zp-zapp-manual.tsv @@ -1,2 +1,6 @@ -ID LABEL -ID LABEL +ID Preferred label Label submitter Exact synonym Synonym submitter +ID A skos:preferredLabel >AI dc:contributor A oboInOwl:exactSynonym >AI dc:contributor +ZP:0000711 microencephaly orcid:0000-0002-4142-7153 +ZP:0000711 undersized brain orcid:0000-0002-4142-7153 +ZP:0003410 macroencephaly orcid:0000-0002-4142-7153 +ZP:0003410 oversized brain orcid:0000-0002-4142-7153 diff --git a/src/ontology/zp-odk.yaml b/src/ontology/zp-odk.yaml index 93f6934..20f3e33 100644 --- a/src/ontology/zp-odk.yaml +++ b/src/ontology/zp-odk.yaml @@ -89,6 +89,10 @@ pattern_pipelines_group: dosdp_tools_options: "--obo-prefixes=true --restrict-axioms-to=logical" ontology: tmp/zp-edit-merged-reasoned.owl robot_java_args: '-Xmx8G' +robot_plugins: + plugins: + - name: upheno + mirror_from: https://github.com/monarch-initiative/monarch-robot-plugins/releases/latest/download/monarch-robot-extensions.jar allow_equivalents: asserted-only documentation: documentation_system: mkdocs \ No newline at end of file diff --git a/src/ontology/zp.Makefile b/src/ontology/zp.Makefile index 9b3ebe1..da66a48 100644 --- a/src/ontology/zp.Makefile +++ b/src/ontology/zp.Makefile @@ -257,24 +257,43 @@ qc: ### ZP ZAPP ################# ############################################# +.PHONY: qc-zapp +qc-zapp: zp-zapp.owl tmp/zp-zapp.csv + @echo + @echo "Checking count of entities in ZAPP subset..." + ../scripts/zapp_check_subset_count.sh + @echo + mkdir -p $(REPORTDIR)/zapp + $(ROBOT) verify -i $< --queries ../sparql/multiple-labels-violation.sparql -O $(REPORTDIR)/zapp + + tmp/zp-zapp-manual.owl: zapp/zp-zapp-manual.tsv - $(ROBOT) template --template $< --output $@ + $(ROBOT) template \ + --prefix 'orcid: https://orcid.org/' \ + --template $< \ + --output $@ tmp/zp-zapp.csv: zp.owl ../sparql/zp_zapp_terms.sparql $(ROBOT) query -f csv -i $< --use-graphs true --query ../sparql/zp_zapp_terms.sparql $@ -ANNOTATION_PROPERTIES_ZAPP = rdfs:label IAO:0000115 OMO:0002000 oboInOwl:hasDbXref oboInOwl:hasExactSynonym oboInOwl:hasRelatedSynonym oboInOwl:hasBroadSynonym oboInOwl:hasNarrowSynonym - -zp-zapp.owl: zp.owl tmp/zp-zapp.csv tmp/zp-zapp-manual.owl tmp/definitions-matches.owl - $(ROBOT) merge -i zp.owl \ - remove -T tmp/zp-zapp.csv --select complement \ - remove $(foreach p, $(ANNOTATION_PROPERTIES_ZAPP), --term $(p)) \ - --term-file tmp/zp-zapp.csv \ - --select complement \ - remove --term rdfs:label --select "ZP:*" \ - merge -i tmp/zp-zapp-manual.owl \ +zp-zapp.owl: zp.owl tmp/zp-zapp.csv tmp/zp-zapp-manual.owl tmp/definitions-matches.owl ../sparql/drop-zfin-labels.ru + $(ROBOT) merge -i $< \ + upheno:extract-upheno-relations \ + --term-file=tmp/zp-zapp.csv \ + --relation UPHENO:0000003 \ merge -i tmp/definitions-matches.owl \ + filter \ + --term UPHENO:0000003 \ + --term-file=tmp/zp-zapp.csv \ + --select annotations \ + merge -i tmp/zp-zapp-manual.owl \ + query \ + --update ../sparql/drop-zfin-labels.ru \ + --update ../sparql/promote-manual-zapp-labels.ru \ $(SHARED_ROBOT_COMMANDS) \ - annotate --link-annotation http://purl.org/dc/elements/1.1/type http://purl.obolibrary.org/obo/IAO_8000001 \ - --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) \ - --output $@.tmp.owl && mv $@.tmp.owl $@ + annotate \ + --annotation dc:description 'A subset of the Zebrafish Phenotype Ontology for use in the ZAPP project.' \ + --link-annotation http://purl.org/dc/elements/1.1/type http://purl.obolibrary.org/obo/IAO_8000001 \ + --link-annotation http://purl.obolibrary.org/obo/IAO_0000700 http://purl.obolibrary.org/obo/ZP_0000000 \ + --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) \ + --output $@ diff --git a/src/scripts/zapp_check_subset_count.sh b/src/scripts/zapp_check_subset_count.sh new file mode 100755 index 0000000..37c7ae5 --- /dev/null +++ b/src/scripts/zapp_check_subset_count.sh @@ -0,0 +1,13 @@ +ZAPP_GRAPH_TERMS=$(grep 'owl:Class rdf:about="http://purl.obolibrary.org/obo/ZP_' zp-zapp.owl | sort | uniq) +ZAPP_GRAPH_COUNT=$(echo "$ZAPP_GRAPH_TERMS" | wc -l) + +ZAPP_CSV_TERMS=$(grep 'ZP_' ../ontology/tmp/zp-zapp.csv | sort | uniq) +ZAPP_CSV_COUNT=$(echo "$ZAPP_CSV_TERMS" | wc -l) + +echo "Expected number of ZAPP terms from CSV: $ZAPP_CSV_COUNT" +echo "Actual number of ZAPP terms in graph: $ZAPP_GRAPH_COUNT" + +if [ $ZAPP_GRAPH_COUNT -ne $ZAPP_CSV_COUNT ] +then + exit 1 +fi diff --git a/src/sparql/drop-zfin-labels.ru b/src/sparql/drop-zfin-labels.ru new file mode 100644 index 0000000..9f76864 --- /dev/null +++ b/src/sparql/drop-zfin-labels.ru @@ -0,0 +1,30 @@ +PREFIX iao: +PREFIX infores: +PREFIX obo: +PREFIX oboInOwl: +PREFIX owl: +PREFIX rdfs: + +DELETE { + ?entity rdfs:label ?zfinLabel . + ?entity obo:IAO_0000115 ?zfinDefinition . +} + +INSERT { + [ + a owl:Axiom ; + owl:annotatedSource ?entity ; + owl:annotatedProperty oboInOwl:hasExactSynonym ; + owl:annotatedTarget ?zfinLabel ; + oboInOwl:source infores:zfin + ] +} + +WHERE { + ?entity a owl:Class . + ?entity rdfs:label ?zfinLabel . + ?entity obo:IAO_0000115 ?zfinDefinition . + FILTER(isIRI(?entity) && regex(str(?entity), "ZP_")) + FILTER(STRENDS(?zfinLabel, ", abnormal")) + FILTER(STRSTARTS(?zfinDefinition, "Abnormal(ly)")) +} diff --git a/src/sparql/multiple-labels-violation.sparql b/src/sparql/multiple-labels-violation.sparql new file mode 100644 index 0000000..f87a426 --- /dev/null +++ b/src/sparql/multiple-labels-violation.sparql @@ -0,0 +1,25 @@ +PREFIX oboInOwl: +PREFIX owl: +PREFIX rdfs: + +SELECT ?entity ?label ?source WHERE { + { + SELECT ?entity WHERE { + ?entity a owl:Class . + ?entity rdfs:label ?_label . + } + GROUP BY ?entity + HAVING(COUNT(?_label) > 1) + } + ?entity rdfs:label ?label . + OPTIONAL { + [ + a owl:Axiom ; + owl:annotatedSource ?entity ; + owl:annotatedProperty rdfs:label ; + owl:annotatedTarget ?label ; + oboInOwl:source ?source + ] + } +} +ORDER BY ?cls diff --git a/src/sparql/promote-manual-zapp-labels.ru b/src/sparql/promote-manual-zapp-labels.ru new file mode 100644 index 0000000..ee6d28e --- /dev/null +++ b/src/sparql/promote-manual-zapp-labels.ru @@ -0,0 +1,40 @@ +PREFIX oboInOwl: +PREFIX owl: +PREFIX rdfs: +PREFIX skos: + +DELETE { + ?entity rdfs:label ?originalLabel . + ?originalLabelAxiom owl:annotatedProperty rdfs:label . + + ?entity skos:preferredLabel ?zappLabel . + ?zappLabelAxiom owl:annotatedProperty skos:preferredLabel . +} + +INSERT { + ?entity oboInOwl:exactSynonym ?originalLabel . + ?originalLabelAxiom owl:annotatedProperty oboInOwl:exactSynonym . + + ?entity rdfs:label ?zappLabel . + ?zappLabelAxiom owl:annotatedProperty rdfs:label . +} + +WHERE { + ?entity a owl:Class . + ?entity skos:preferredLabel ?zappLabel . + ?entity rdfs:label ?originalLabel . + + ?zappLabelAxiom + a owl:Axiom ; + owl:annotatedSource ?entity ; + owl:annotatedProperty skos:preferredLabel ; + owl:annotatedTarget ?zappLabel . + + ?originalLabelAxiom + a owl:Axiom ; + owl:annotatedSource ?entity ; + owl:annotatedProperty rdfs:label ; + owl:annotatedTarget ?originalLabel . + + FILTER(isIRI(?entity) && regex(str(?entity), "ZP_")) +} diff --git a/src/sparql/zp_zapp_terms.sparql b/src/sparql/zp_zapp_terms.sparql index 0858244..cdcd788 100644 --- a/src/sparql/zp_zapp_terms.sparql +++ b/src/sparql/zp_zapp_terms.sparql @@ -3,8 +3,6 @@ PREFIX owl: PREFIX oio: SELECT DISTINCT ?class WHERE { - ?class a owl:Class . - VALUES ?source { @@ -174,8 +172,23 @@ SELECT DISTINCT ?class WHERE { } - # Reified label axiom - ?axiom a owl:Axiom ; - owl:annotatedSource ?class ; - oio:source ?source . + { + ?class a owl:Class . + + # Reified label axiom + ?axiom a owl:Axiom ; + owl:annotatedSource ?class ; + oio:source ?source . + } + UNION + { + ?class a owl:Class . + + FILTER( + isIRI(?class) && + (?class = ) || + (STRSTARTS(str(?class), "http://purl.obolibrary.org/obo/ZFA_")) || + (STRSTARTS(str(?class), "http://purl.obolibrary.org/obo/GO_")) + ) + } }