Skip to content

Commit

Permalink
Enforce taxon constraints
Browse files Browse the repository at this point in the history
We add a new test to the test suite to check that taxon constraints are
not violated.

The check is done by: (1) merging the edit file with an ontology
containing disjointness axioms over sibling taxa
(obo:ncbitaxon/subsets/taxslim-disjoint-over-in-taxon.owl), (2)
expanding any macro in the merged ontology (needed for taxon constraints
depending on RO:0002161 and RO:0002175), and (3) reasoning over the
result.

This necessitates two updates to CL's ODK configuration: adding a mirror
for the taxslim-disjoint-over-in-taxon.owl module, and making sure that
the OMO:0002000 annotation property (which defines the expansion of
RO:0002161 and RO:0002175)  is not stripped away by the imports
pipeline.

Because the TC check in Uberon had been broken between March and August
2024, a TC violation has crept in that can now be found in the Uberon
import module. That violation has already been fixed upstream in Uberon,
so it will automatically disappear the next time we refresh the imports
after the next Uberon release.

In the meantime, we hack the merged_imports module to forcefully remove
the offending axiom.
  • Loading branch information
gouttegd authored Sep 6, 2024
1 parent d51de67 commit 73e6126
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 7 deletions.
32 changes: 31 additions & 1 deletion .github/workflows/qc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,45 @@ jobs:
ontology_qc:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.5
container: obolibrary/odkfull:v1.5.2

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Run ontology QC checks
id: check
continue-on-error: true
env:
DEFAULT_BRANCH: master
run: cd src/ontology && make ROBOT_ENV='ROBOT_JAVA_ARGS=-Xmx6G' test IMP=false PAT=false MIR=false

- name: Reason over taxon constraints
id: explaintc
continue-on-error: true
if: steps.check.outcome == 'failure'
run: |
if [ -s src/ontology/reports/taxon-constraint-check.txt ]; then
robot explain -i src/ontology/tmp/cl-plus-taxon-disjoints.ofn -M unsatisfiability -u all -r ELK -e taxon-unsats.md
echo "<details>\n<summary>This PR violates some taxon constraints. Here is what the reasoner has to say:</summary>\n" > comments.md
cat taxon-unsats.md >> comment.md
echo "</details>" >> comment.md
exit 1
fi
- name: Post explanation for taxon constraint violations
if: steps.explaintc.outcome == 'failure'
uses: NejcZdovc/comment-pr@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
file: "../../comment.md"
identifier: "TAXON_CONSTRAINTS_REASONING"

# If the check failed, then the entire job should fail, even if we
# allowed it to continue so that we could post the message with
# the explanations.
- name: Fail on error
if: steps.check.outcome == 'failure'
run: exit 1

17 changes: 12 additions & 5 deletions src/ontology/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ----------------------------------------
# Makefile for cl
# Generated using ontology-development-kit
# ODK Version: v1.5
# ODK Version: v1.5.2
# ----------------------------------------
# IMPORTANT: DO NOT EDIT THIS FILE. To override default make goals, use cl.Makefile instead

Expand All @@ -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= b786b0d7cbd09184896d55b42fe68a40981419e0c9d848963a74348b7bb955b7
CONFIG_HASH= b30da9471aba970de63ae9153976cf8ce20f44a23d2dda7923dc04560cd0ae11


# ----------------------------------------
Expand Down Expand Up @@ -46,7 +46,7 @@ REPORT_PROFILE_OPTS =
OBO_FORMAT_OPTIONS =
SPARQL_VALIDATION_CHECKS = equivalent-classes owldef-self-reference nolabels pmid-not-dbxref obsolete-replaced_by obsolete-alt-id orcid-contributor illegal-annotation-property label-synonym-polysemy illegal-date
SPARQL_EXPORTS = cl_terms cl-edges cl-synonyms cl-xrefs cl-def-xrefs
ODK_VERSION_MAKEFILE = v1.5
ODK_VERSION_MAKEFILE = v1.5.2

TODAY ?= $(shell date +%Y-%m-%d)
OBODATE ?= $(shell date +'%d:%m:%Y %H:%M')
Expand Down Expand Up @@ -173,7 +173,7 @@ all_main: $(MAIN_FILES)
# ----------------------------------------


IMPORTS = pr go uberon ro pato ncbitaxon omo
IMPORTS = pr go uberon ro pato ncbitaxon ncbitaxondisjoints omo

IMPORT_ROOTS = $(IMPORTDIR)/merged_import
IMPORT_OWL_FILES = $(foreach n,$(IMPORT_ROOTS), $(n).owl)
Expand Down Expand Up @@ -365,7 +365,7 @@ ALLSEED = $(PRESEED) $(TMPDIR)/all_pattern_terms.txt \
$(IMPORTSEED): $(ALLSEED) | $(TMPDIR)
if [ $(IMP) = true ]; then cat $(ALLSEED) | sort | uniq > $@; fi

ANNOTATION_PROPERTIES=rdfs:label IAO:0000115 oboInOwl:is_metadata_tag
ANNOTATION_PROPERTIES=rdfs:label IAO:0000115 oboInOwl:is_metadata_tag OMO:0002000

# ----------------------------------------
# Import modules
Expand Down Expand Up @@ -572,6 +572,13 @@ mirror-ncbitaxon: | $(TMPDIR)
$(ROBOT) convert -I http://purl.obolibrary.org/obo/ncbitaxon/subsets/taxslim.owl -o $(TMPDIR)/$@.owl


## ONTOLOGY: ncbitaxondisjoints
.PHONY: mirror-ncbitaxondisjoints
.PRECIOUS: $(MIRRORDIR)/ncbitaxondisjoints.owl
mirror-ncbitaxondisjoints: | $(TMPDIR)
$(ROBOT) convert -I http://purl.obolibrary.org/obo/ncbitaxon/subsets/taxslim-disjoint-over-in-taxon.owl -o $(TMPDIR)/$@.owl


## ONTOLOGY: omo
.PHONY: mirror-omo
.PRECIOUS: $(MIRRORDIR)/omo.owl
Expand Down
3 changes: 3 additions & 0 deletions src/ontology/cl-odk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import_group:
- rdfs:label
- IAO:0000115
- oboInOwl:is_metadata_tag
- OMO:0002000
exclude_iri_patterns:
- <http://www.informatics.jax.org/marker/MGI:*>
- <http://purl.obolibrary.org/obo/OBA_*>
Expand Down Expand Up @@ -87,6 +88,8 @@ import_group:
use_base: TRUE
- id: ncbitaxon
mirror_from: http://purl.obolibrary.org/obo/ncbitaxon/subsets/taxslim.owl
- id: ncbitaxondisjoints
mirror_from: http://purl.obolibrary.org/obo/ncbitaxon/subsets/taxslim-disjoint-over-in-taxon.owl
- id: omo
module_type: mirror
pattern_pipelines_group:
Expand Down
38 changes: 38 additions & 0 deletions src/ontology/cl.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,37 @@ $(COMPONENTSDIR)/mappings.owl: $(SRC) $(EXTERNAL_SSSOM_SETS) | all_robot_plugins
--bridge-iri http://purl.obolibrary.org/obo/cl/components/mappings.owl


# ----------------------------------------
# TAXON CONSTRAINTS CHECK
# ----------------------------------------

# The TC check requires te taxslim-disjoint-over-in-taxon.owl ontology,
# which is declared as an ODK mirror (under the name ncbitaxondisjoints)
# and as such should already have been downloaded into the mirror
# directory by the standard ODK-generated rule. But the QC checks are
# typically run under MIR=false, so while the standard rule would be
# invoked by Make it would not result in the mirror being downloaded.
# So instead, we make the TC check depend on another file, and here we
# 1. force the download of the mirror if it is not already there;
# 2. create a link to that mirror.
$(TMPDIR)/taxslim-disjoint-over-in-taxon.owl:
if [ ! -f $(MIRRORDIR)/ncbitaxondisjoints.owl ]; then \
$(MAKE) $(MIRRORDIR)/ncbitaxondisjoints.owl MIR=true IMP=true ; \
fi && \
ln -f -s ../$(MIRRORDIR)/ncbitaxondisjoints.owl $@

# Actual TC check: we add the taxon disjointness axioms into the
# ontology, make sure to expand all macros, then try to reason over the
# resulting product.
$(REPORTDIR)/taxon-constraint-check.txt: $(EDIT_PREPROCESSED) $(TMPDIR)/taxslim-disjoint-over-in-taxon.owl
$(ROBOT) merge $(foreach src,$^,-i $(src)) \
expand -o $(TMPDIR)/cl-plus-taxon-disjoints.ofn \
reason -r ELK > $@

# Include the TC check in the routine tests
test: $(REPORTDIR)/taxon-constraint-check.txt


##############################################
##### CL Template pipeline ###################
##############################################
Expand Down Expand Up @@ -321,9 +352,16 @@ $(TEMPLATEDIR)/cellxgene_subset.tsv:
wget $(CELLXGENE_SUBSET_URL) -O $@

# Make CL-plus (CL + PCL product)
# HACK: We have to remove the disjointness axioms between taxa, because
# PCL does not enforce taxon constraints and may contain TC violations
# that would be revealed here due to the presence of those axioms
# (thereby causing that step to fail). The proper fix would be for PCL
# to enforce TC.
# See <https://github.com/obophenotype/provisional_cell_ontology/issues/59>

cl-plus.owl: $(ONT)-full.owl
$(ROBOT) merge --input-iri http://purl.obolibrary.org/obo/pcl/pcl-base.owl --input $(ONT)-full.owl \
unmerge --input-iri http://purl.obolibrary.org/obo/ncbitaxon/subsets/taxslim-disjoint-over-in-taxon.owl \
reason --reasoner ELK --equivalent-classes-allowed asserted-only --exclude-tautologies structural \
relax \
reduce -r ELK \
Expand Down
1 change: 0 additions & 1 deletion src/ontology/imports/merged_import.owl
Original file line number Diff line number Diff line change
Expand Up @@ -198565,7 +198565,6 @@ SubClassOf(<http://purl.obolibrary.org/obo/UBERON_0006293> <http://purl.obolibra
SubClassOf(<http://purl.obolibrary.org/obo/UBERON_0006293> <http://purl.obolibrary.org/obo/UBERON_0003104>)
SubClassOf(<http://purl.obolibrary.org/obo/UBERON_0006293> <http://purl.obolibrary.org/obo/UBERON_0004120>)
SubClassOf(<http://purl.obolibrary.org/obo/UBERON_0006293> <http://purl.obolibrary.org/obo/UBERON_0005291>)
SubClassOf(Annotation(<http://www.geneontology.org/formats/oboInOwl#source> "EHDAA2-modified") <http://purl.obolibrary.org/obo/UBERON_0006293> ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/BFO_0000050> <http://purl.obolibrary.org/obo/UBERON_0005602>))
SubClassOf(Annotation(<http://www.geneontology.org/formats/oboInOwl#source> "XAO") <http://purl.obolibrary.org/obo/UBERON_0006293> ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/RO_0002202> <http://purl.obolibrary.org/obo/UBERON_0004872>))

# Class: <http://purl.obolibrary.org/obo/UBERON_0006304> (future trigeminal ganglion)
Expand Down
1 change: 1 addition & 0 deletions src/ontology/imports/ncbitaxondisjoints_terms.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 73e6126

Please sign in to comment.