Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Steps to get taxon exclusions from relation graph #2160

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions src/ontology/uberon.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
Expand Down Expand Up @@ -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 ##

Expand Down Expand Up @@ -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 \
Expand All @@ -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 [email protected] \
annotate --ontology-iri "$(ONTBASE)/$@" \
--output $@

cl_mondo_merged.owl:
$(ROBOT) merge -i uberon.owl -I $(URIBASE)/cl.owl -o $@

Expand Down Expand Up @@ -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:
Expand All @@ -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 [email protected]

47 changes: 47 additions & 0 deletions src/sparql/taxon-violation-relation-graph.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

PREFIX human: <http://purl.obolibrary.org/obo/NCBITaxon_9606>
PREFIX mammal: <http://purl.obolibrary.org/obo/NCBITaxon_40674>
PREFIX never_in_taxon: <http://purl.obolibrary.org/obo/RO_0002161>
PREFIX in_taxon: <http://purl.obolibrary.org/obo/RO_0002162>

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)


}