diff --git a/src/ontology/uberon.Makefile b/src/ontology/uberon.Makefile index 0f9082f234..6a30fc8b6c 100644 --- a/src/ontology/uberon.Makefile +++ b/src/ontology/uberon.Makefile @@ -113,7 +113,7 @@ core.owl: $(OWLSRC) # FIXED apparently our base does not contain phenoscape-ext!! (It does, through unreasoned) #$(TMPDIR)/phenoscape-ext-src.owl: $(SRC) # wget --no-check-certificate https://raw.githubusercontent.com/obophenotype/uberon-phenoscape-ext/master/phenoscape-ext.owl -O $@ && touch $@ - + # including the imports would lead to circularity, so we remove these here #$(COMPONENTSDIR)/phenoscape-ext.owl: $(TMPDIR)/phenoscape-ext-src.owl core.owl # owltools $(UCAT) $< --remove-imports-declarations -o -f functional $@ @@ -1713,8 +1713,8 @@ reports/robot_release_diff.md: $(TMPDIR)/$(ONT)-obo.obo $(TMPDIR)/$(ONT)-obo-mai .PHONY: feature_diff feature_diff: reports/robot_main_diff.md - - + + ######################## #### Utility commands ## @@ -1745,7 +1745,6 @@ clean: rm -rf ./uberon-base.* rm -f uberon.owl uberon.obo core.owl BUILDLOGUBERON.txt unsat_all_explanation.md rm -f ext.owl - explain: $(ROBOT) explain --input $(TMPDIR)/unreasoned-composite-metazoan.owl --reasoner ELK \ @@ -1756,13 +1755,13 @@ explain: # echo "skipping $@" unsat: $(TMPDIR)/bundled-metazoan.owl_unsat.ofn $(TMPDIR)/cl_mondo_merged.owl_unsat.ofn - + $(TMPDIR)/%_unsat.ofn: % $(ROBOT) merge --input $< explain --reasoner ELK \ -M unsatisfiability --unsatisfiable random:3 --explanation $@.md \ annotate --ontology-iri "$(ONTBASE)/$@" \ --output $@ - + cl_mondo_merged.owl: $(ROBOT) merge -i uberon.owl -I $(URIBASE)/cl.owl -o $@ @@ -1873,6 +1872,24 @@ docs/releases.md: uberon-odk.yaml # if http://purl.obolibrary.org/obo/mondo/releases/2021-01-01/mondo.owl exists, include it in overview. # Use Github or obo purls (include switch that we can conficgue with ODK) +# ---------------------------------------- +# TAXON CONSTRAINTS VIA RELATION GRAPH +# ---------------------------------------- +# see https://github.com/obophenotype/uberon/issues/2137#issuecomment-963594082 + +# make a relationgraph ttl file (assumes RG 2.0 - may not be in ODK yet) +tmp/%.relationgraph.ttl: %.obo + relation-graph --ontology-file $< --equivalence-as-subclass true --output-subclasses true --reflexive-subclasses true --output-file $@ +.PRECIOUS: tmp/%.relationgraph.ttl + +tmp/%.rgmerged.ttl: tmp/%.relationgraph.ttl %.obo + robot merge -i $< -i $*.obo -o $@ +.PRECIOUS: tmp/%.rgmerged.ttl + +# This is currently hardcoded to a subset of species +tmp/class-taxon-exclusions.tsv: tmp/uberon-edit.rgmerged.ttl + robot query -i $< --tdb true --query ../sparql/taxon-violation-relation-graph.sparql $@ + ### Removing uberon_2 contraints ### refer to https://github.com/obophenotype/uberon/discussions/2158 remove_uberon_two_constraints: @@ -1886,3 +1903,4 @@ explain_humans: explain_humans_all: $(ROBOT) merge -i ../../ext.owl -i contexts/context-human.owl explain --reasoner ELK -M unsatisfiability --unsatisfiable random:10 --explanation $@.md + diff --git a/src/sparql/taxon-violation-relation-graph.sparql b/src/sparql/taxon-violation-relation-graph.sparql new file mode 100644 index 0000000000..ee5d8905d9 --- /dev/null +++ b/src/sparql/taxon-violation-relation-graph.sparql @@ -0,0 +1,47 @@ +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: + +PREFIX human: +PREFIX mammal: +PREFIX never_in_taxon: +PREFIX in_taxon: + +SELECT ?c ?cLabel ?p ?pLabel ?clsWithConstraint ?clsWithConstraintLabel ?taxonWithConstraint ?taxonWithConstraintLabel ?queryTaxon +WHERE { + + ?c ?p ?clsWithConstraint . + + # NEVER IN + { + ?clsWithConstraint never_in_taxon: ?taxonWithConstraint . + ?queryTaxon + rdfs:subClassOf ?taxonWithConstraint + } + UNION + # ONLY IN + { + ?clsWithConstraint in_taxon: ?taxonWithConstraint + FILTER NOT EXISTS { ?queryTaxon + rdfs:subClassOf ?taxonWithConstraint + } + } + + # add to this as required + VALUES ?queryTaxon { + human: mammal: + } + OPTIONAL + { ?c rdfs:label ?cLabel } + OPTIONAL + { ?p rdfs:label ?pLabel } + OPTIONAL + { ?clsWithConstraint rdfs:label ?clsWithConstraintLabel } + OPTIONAL + { ?taxonWithConstraint rdfs:label ?taxonWithConstraintLabel } + + + FILTER isIRI(?c) + + + }