Skip to content

Commit

Permalink
Merge pull request #68 from monarch-initiative/upheno-refactor
Browse files Browse the repository at this point in the history
Add pipeline to add uPheno relations more directly
  • Loading branch information
caufieldjh authored Apr 11, 2024
2 parents 7f809d9 + 91bb2ab commit 30bf6ba
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 50 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ src/patterns/data/**/*.txt
src/patterns/pattern_owl_seed.txt
src/patterns/all_pattern_terms.txt

src/ontology/components/*.owl
src/ontology/components/*.owl
src/ontology/debug.log
7 changes: 5 additions & 2 deletions src/ontology/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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= ff6f93caf8c93bf6c4c5c663944a984e193688503d790d719a90a5de2d147045
CONFIG_HASH= e6c8433a2061b8c344c045ae57324b457c3c5c0b221faaaec4373a8c55c52c2b


# ----------------------------------------
Expand Down Expand Up @@ -121,7 +121,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
Expand All @@ -141,6 +141,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
Expand Down
9 changes: 9 additions & 0 deletions src/ontology/phenio-odk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,12 @@ robot_report:

documentation:
documentation_system: mkdocs

workflows:
- docs

robot_plugins:
plugins:
- name: upheno
mirror_from: https://github.com/monarch-initiative/monarch-robot-plugins/releases/latest/download/monarch-robot-extensions.jar

62 changes: 17 additions & 45 deletions src/ontology/phenio.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,27 @@ $(TMPDIR)/$(ONT)-full-unreasoned.owl: $(SRC) $(OTHER_SRC)
$(EXPLAIN_OUT_PATH): $(TMPDIR)/$(ONT)-full-unreasoned.owl
$(ROBOT) explain -i $< -M unsatisfiability --unsatisfiable random:10 --explanation $@

$(TMPDIR)/$(ONT)-full.owl: $(TMPDIR)/$(ONT)-full-unreasoned.owl
#$(ROBOT) reason --input $< \
# --reasoner ELK --equivalent-classes-allowed all --exclude-tautologies structural \
# relax \
# reduce -r ELK \
# $(SHARED_ROBOT_COMMANDS) annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) --output [email protected] && mv [email protected] $@
$(ROBOT) relax --input $< \
$(SHARED_ROBOT_COMMANDS) annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) --output [email protected] && mv [email protected] $@

$(SUBQ_QUERY_RESULT_PATH): $(TMPDIR)/$(ONT)-full.owl
#echo "Finding subq patterns based on $(SUBQ_QUERY_PATH)..."
$(ROBOT) query --input $< --tdb true --format 'owl' --query $(SUBQ_QUERY_PATH) $@

$(UPDATE_QUERY_PATH): $(SUBQ_QUERY_RESULT_PATH)
#echo "Creating update query..."
awk -v RS= 'NR==1' $(SUBQ_QUERY_PATH) > $@
tail -n +3 $<| sed -e '/./!Q' -e 's/@prefix/PREFIX/g' -e 's/.$$//' >> $@
printf '\nINSERT DATA\n{' >> $@
sed -n '/rdfs:subClassOf/,$$p' $< >> $@
printf '\n}' >> $@
grep subClassOf $@ | wc -l

$(ONT)-full.owl: $(TMPDIR)/$(ONT)-full.owl $(UPDATE_QUERY_PATH)
#echo "Running update query for subq patterns..."
$(ROBOT) query --input $< --format 'owl' --update $(UPDATE_QUERY_PATH) --temporary-file 'true' annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) --output $@
#echo "Completed update with subq patterns."

### Merge Biolink Model categories
$(BLMODEL):
wget $(BLMODEL_URL) -O $@

$(ONT).owl: $(ONT)-full.owl $(BLMODEL)
$(ROBOT) merge --input $< --input $(BLMODEL) \
query --update $(BLQUERY) \
unmerge --input $(BLMODEL) \
annotate --ontology-iri $(URIBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) \
convert -o $@.tmp.owl && mv $@.tmp.owl $@
### Download ROBOT plugin for upheno
$(ROBOT_PLUGINS_DIRECTORY)/upheno.jar:
mkdir -p $(ROBOT_PLUGINS_DIRECTORY)
curl -L -o $@ https://github.com/monarch-initiative/monarch-robot-plugins/releases/download/v0.0.1/monarch-robot-extensions-0.0.1.jar

$(ONT)-full.owl: $(TMPDIR)/$(ONT)-full-unreasoned.owl | all_robot_plugins
$(ROBOT) merge --input $< \
relax \
merge --input $(BLMODEL) \
query --update $(BLQUERY) \
unmerge --input $(BLMODEL) \
upheno:extract-upheno-relations --root-phenotype UPHENO:0001001 --relation UPHENO:0000003 --relation UPHENO:0000001 \
annotate --ontology-iri $(URIBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) \
convert -o $@.tmp.owl && mv $@.tmp.owl $@

tmp/diff.txt: $(ONT).owl $(ONT)-old.owl
$(ROBOT) diff --left $< --right $(word 2,$^) --format txt -o $@

### Get full entailment with relation-graph
### First, make a minimal version
Expand Down Expand Up @@ -91,18 +75,6 @@ $(ONT)-relation-graph.tsv: $(MINIMAL_PATH)
--obo-prefixes true \
--verbose true

# base-plus. No externally imported axioms, but reasoning is performed.
$(ONT)-base-plus.owl: $(EDIT_PREPROCESSED) $(OTHER_SRC) $(IMPORT_FILES)
$(ROBOT_RELEASE_IMPORT_MODE) \
reason --reasoner ELK --equivalent-classes-allowed all --exclude-tautologies structural \
relax \
reduce -r ELK \
remove --base-iri $(URIBASE)/PHENIO --axioms external --preserve-structure false --trim false \
$(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 $@

# test artifact. A small subset of the ontology for testing purposes
# Note this does include categories.
$(ONT)-test.owl: $(ONT).owl
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/update_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cp target/$OID/src/ontology/run.sh $SRCDIR/ontology/
cp -r target/$OID/src/sparql/* $SRCDIR/sparql/
mkdir -p $ROOTDIR/.github
mkdir -p $ROOTDIR/.github/workflows
cp target/$OID/.github/workflows/qc.yml $ROOTDIR/.github/workflows/qc.yml




Expand All @@ -36,5 +36,5 @@ cp target/$OID/.github/workflows/docs.yml $ROOTDIR/.github/workflows/docs.yml
cp -n target/$OID/mkdocs.yaml $ROOTDIR/

echo "WARNING: These files should be manually migrated: mkdocs.yaml, .gitignore, src/ontology/catalog.xml (if you added a new import or component)"

echo "WARNING: Your QC workflows have not been updated automatically. Please update the ODK version number(s) in .github/workflows/qc.yml."
echo "Ontology repository update successfully completed."

0 comments on commit 30bf6ba

Please sign in to comment.