Skip to content

Commit

Permalink
Merge pull request #26180 from geneontology/automate-precomputed-taxo…
Browse files Browse the repository at this point in the history
…n-constraints

Build computed taxon constraints as part of go-plus.
  • Loading branch information
balhoff authored Oct 28, 2023
2 parents aff1656 + df83372 commit 42fd58f
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/ontology/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ REPORTDIR = $(RELEASEDIR)/reports
# TOP LEVEL TARGETS
# ----------------------------------------

stage_release: imports/reactome_xrefs_import.owl test $(ONT).owl $(ONT).obo $(ONT).json.gz $(GO_PLUS).owl $(GO_PLUS).json.gz go-base.owl $(GO_GAF).owl $(GO_AMIGO).owl $(GO_LEGO).owl $(GO_LEGO_REACTO).owl go-basic.obo go-basic.json.gz extensions/rhea-reactions.ttl subset-owls subset-reports generate-mappings
stage_release: imports/reactome_xrefs_import.owl test $(ONT).owl $(ONT).obo $(ONT).json.gz $(GO_PLUS).owl $(GO_PLUS).json.gz go-base.owl $(GO_GAF).owl $(GO_AMIGO).owl $(GO_LEGO).owl $(GO_LEGO_REACTO).owl go-basic.obo go-basic.json.gz extensions/rhea-reactions.ttl imports/go-computed-taxon-constraints.obo subset-owls subset-reports generate-mappings

test: $(SRC)-check sparql_test change-report.txt reasoned.owl unsatisfiable present_in_taxon_check.ofn chebi_pH_7_3_check

Expand Down Expand Up @@ -206,8 +206,9 @@ present_in_taxon_check.ofn: enhanced.owl ../taxon_constraints/present_in_taxon.o

# equivalent to reasoned, but we rename
# TODO cleanup redundancies with merge here and with go-base
$(GO_PLUS).owl: reasoned.owl
$(ROBOT) merge -i $< --collapse-import-closure true --include-annotations false annotate -O $(BASE)/$@ -V $(RELEASE_URIBASE)/$@ -o $@
# note: do not run 'reason' after go-computed-taxon-constraints.owl is merged; some desired logical redundancy may be lost
$(GO_PLUS).owl: reasoned.owl imports/go-computed-taxon-constraints.owl
$(ROBOT) merge -i $< --collapse-import-closure true --include-annotations false merge -i imports/go-computed-taxon-constraints.owl annotate -O $(BASE)/$@ -V $(RELEASE_URIBASE)/$@ -o $@
.PRECIOUS: $(GO_PLUS).owl

# Create release file containing GO-asserted axioms, no external axioms, and no inferences.
Expand Down Expand Up @@ -361,6 +362,13 @@ imports/ncbitaxon_import.owl: imports/ncbitaxon_import_pre.owl
imports/go_taxon_constraints.owl: ../taxon_constraints/only_in_taxon.ofn ../taxon_constraints/never_in_taxon.ofn
$(ROBOT) merge $(addprefix -i , $^) annotate -O $(BASE)/$@ -o $@

imports/go-computed-taxon-constraints.owl: $(SRC) $(SPARQLDIR)/taxon-constraints-materialization.ru $(SPARQLDIR)/taxon-constraints-in-taxon-annotation.rq $(SPARQLDIR)/taxon-constraints-never-in-taxon-annotation.rq
$(ROBOT) merge -i $< query --update $(SPARQLDIR)/taxon-constraints-materialization.ru materialize --term RO:0002162 query --query $(SPARQLDIR)/taxon-constraints-in-taxon-annotation.rq taxon-constraints-in-taxon-annotation.ttl --query $(SPARQLDIR)/taxon-constraints-never-in-taxon-annotation.rq taxon-constraints-never-in-taxon-annotation.ttl &&\
$(ROBOT) merge -i taxon-constraints-in-taxon-annotation.ttl -i taxon-constraints-never-in-taxon-annotation.ttl annotate -O $(BASE)/$@ -o $@

imports/go-computed-taxon-constraints.obo: imports/go-computed-taxon-constraints.owl
$(ROBOT) convert -i $< -o imports/go-computed-taxon-constraints.tmp.obo && grep -v '^owl-axioms' imports/go-computed-taxon-constraints.tmp.obo >$@

imports/%_import.owl: imports/%_import_pre.owl
cp $< $@

Expand Down
5 changes: 3 additions & 2 deletions src/ontology/catalog-v001.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/imports/opl_import.owl" uri="imports/opl_import.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/imports/so_import.owl" uri="imports/so_import.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/imports/ro_import.owl" uri="imports/ro_import.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/ro.owl" uri="mirror/ro-download.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/ro.owl" uri="mirror/ro-download.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/imports/annotation_properties.owl" uri="imports/annotation_properties.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/imports/pato_import.owl" uri="imports/pato_import.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/pato.owl" uri="mirror/pato.owl"/>
Expand All @@ -39,9 +39,10 @@
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/extensions/go-plus.owl" uri="extensions/go-plus.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/extensions/go-gaf.owl" uri="extensions/go-gaf.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/extensions/go-lego-edit-unsafe.ofn" uri="extensions/go-lego-edit-unsafe.ofn"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/chebi.owl" uri="mirror/chebi.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/chebi.owl" uri="mirror/chebi.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/uberon/reasoner_axioms.owl" uri="go_inferences_null.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/imports/go-pattern-conformance.ttl" uri="imports/go-pattern-conformance.ttl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/imports/go-computed-taxon-constraints.owl" uri="imports/go-computed-taxon-constraints.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/imports/go-taxon-groupings.owl" uri="imports/go-taxon-groupings.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/imports/go_taxon_constraints.owl" uri="imports/go_taxon_constraints.owl"/>
<uri id="User Entered Import Resolution" name="http://purl.obolibrary.org/obo/go/extensions/go-taxon-subsets.owl" uri="extensions/go-taxon-subsets.owl"/>
Expand Down
30 changes: 30 additions & 0 deletions src/sparql/taxon-constraints-in-taxon-annotation.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX oio: <http://www.geneontology.org/formats/oboInOwl#>
PREFIX in_taxon: <http://purl.obolibrary.org/obo/RO_0002162>
CONSTRUCT {
<http://purl.obolibrary.org/obo/go/imports/go-computed-taxon-constraints.owl#INTAXON> a owl:Ontology .
in_taxon: a owl:ObjectProperty .
?term rdfs:subClassOf _:taxon_restriction .
_:taxon_restriction a owl:Restriction ;
owl:onProperty in_taxon: ;
owl:someValuesFrom ?taxon .
[
a owl:Axiom ;
owl:annotatedSource ?term ;
owl:annotatedProperty rdfs:subClassOf ;
owl:annotatedTarget _:taxon_restriction ;
oio:source "computed"
]
}
WHERE {
?term rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty in_taxon: ;
owl:someValuesFrom ?taxon
]
FILTER(STRSTARTS(STR(?term), "http://purl.obolibrary.org/obo/GO_"))
FILTER(isIRI(?taxon))
FILTER(STRSTARTS(STR(?taxon), "http://purl.obolibrary.org/obo/NCBITaxon"))
FILTER(!STRENDS(STR(?taxon), "#NOT"))
}
18 changes: 18 additions & 0 deletions src/sparql/taxon-constraints-materialization.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX in_taxon: <http://purl.obolibrary.org/obo/RO_0002162>
INSERT {
?complement_supertaxon rdfs:subClassOf ?complement_subtaxon .
?complement_subtaxon owl:equivalentClass [
a owl:Class ;
owl:complementOf ?subtaxon
] .
}
WHERE {
?subtaxon rdfs:subClassOf ?supertaxon .
FILTER(isIRI(?subtaxon))
FILTER(STRSTARTS(STR(?subtaxon), "http://purl.obolibrary.org/obo/NCBITaxon"))
FILTER(STRSTARTS(STR(?supertaxon), "http://purl.obolibrary.org/obo/NCBITaxon"))
BIND(IRI(CONCAT(STR(?subtaxon), "#NOT")) AS ?complement_subtaxon)
BIND(IRI(CONCAT(STR(?supertaxon), "#NOT")) AS ?complement_supertaxon)
}
65 changes: 65 additions & 0 deletions src/sparql/taxon-constraints-never-in-taxon-annotation.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX oio: <http://www.geneontology.org/formats/oboInOwl#>
PREFIX in_taxon: <http://purl.obolibrary.org/obo/RO_0002162>
PREFIX never_in_taxon: <http://purl.obolibrary.org/obo/RO_0002161>
CONSTRUCT {
<http://purl.obolibrary.org/obo/go/imports/go-computed-taxon-constraints.owl#NEVERINTAXON> a owl:Ontology .
in_taxon: a owl:ObjectProperty .
never_in_taxon: a owl:AnnotationProperty .
?term rdfs:subClassOf _:complement .
_:complement a owl:Class ;
owl:complementOf [
a owl:Restriction ;
owl:onProperty in_taxon: ;
owl:someValuesFrom ?taxon
] .
[
a owl:Axiom ;
owl:annotatedSource ?term ;
owl:annotatedProperty rdfs:subClassOf ;
owl:annotatedTarget _:complement ;
oio:source "computed"
] .
?term never_in_taxon: ?taxon .
[
a owl:Axiom ;
owl:annotatedSource ?term ;
owl:annotatedProperty never_in_taxon: ;
owl:annotatedTarget ?taxon ;
oio:source "computed"
] .
}
WHERE {
?term rdfs:subClassOf [
a owl:Restriction ;
owl:onProperty in_taxon: ;
owl:someValuesFrom ?taxon_complement
]
FILTER(STRSTARTS(STR(?term), "http://purl.obolibrary.org/obo/GO_"))
FILTER(isIRI(?taxon_complement))
FILTER(STRSTARTS(STR(?taxon_complement), "http://purl.obolibrary.org/obo/NCBITaxon"))
FILTER(STRENDS(STR(?taxon_complement), "#NOT"))
BIND(IRI(STRBEFORE(STR(?taxon_complement), "#NOT")) AS ?taxon)
FILTER (
EXISTS {
?term rdfs:subClassOf+ [
a owl:Restriction ;
owl:onProperty in_taxon: ;
owl:someValuesFrom ?super_taxon
] .
FILTER(!STRENDS(STR(?super_taxon), "#NOT"))
?taxon rdfs:subClassOf+ ?super_taxon .
}
||
NOT EXISTS {
?term rdfs:subClassOf+ [
a owl:Restriction ;
owl:onProperty in_taxon: ;
owl:someValuesFrom ?super_taxon
] .
FILTER(STRSTARTS(STR(?super_taxon), "http://purl.obolibrary.org/obo/NCBITaxon"))
FILTER(!STRENDS(STR(?super_taxon), "#NOT"))
}
)
}

0 comments on commit 42fd58f

Please sign in to comment.