|
2 | 2 | ## |
3 | 3 | ## If you need to customize your Makefile, make |
4 | 4 | ## changes here rather than in the main Makefile |
| 5 | + |
| 6 | +URIBASE = https://purl.brain-bican.org/ontology |
| 7 | + |
| 8 | +JOBS = HOMBA_v1 |
| 9 | +BRIDGES = homba |
| 10 | +TARGETS = homba |
| 11 | + |
| 12 | +LINKML = linkml-data2owl |
| 13 | + |
| 14 | +STRUCTURE_GRAPHS = $(patsubst %, sources/%.json, $(JOBS)) |
| 15 | +ALL_GRAPH_ONTOLOGIES = $(patsubst sources/%.json,sources/%.ofn,$(STRUCTURE_GRAPHS)) |
| 16 | +ALL_BRIDGES = $(patsubst %, sources/uberon-bridge-to-%.owl, $(BRIDGES)) |
| 17 | +# Keep the template-regenerated bridge workflow disabled until HOMBA has a |
| 18 | +# manually curated mapping table to compare against the legacy bridge. |
| 19 | +# SOURCE_TEMPLATES = $(patsubst %, ../templates/%_CCF_to_UBERON_source.tsv, $(TARGETS)) |
| 20 | +# NEW_BRIDGES = $(patsubst %, new-bridges/new-uberon-bridge-to-%.owl, $(TARGETS)) |
| 21 | + |
| 22 | + |
| 23 | +.PHONY: $(COMPONENTSDIR)/all_templates.owl |
| 24 | +$(COMPONENTSDIR)/all_templates.owl: clean_files dependencies $(COMPONENTSDIR)/linkouts.owl $(COMPONENTSDIR)/sources_merged.owl |
| 25 | + $(ROBOT) merge -i $(COMPONENTSDIR)/linkouts.owl -i $(COMPONENTSDIR)/sources_merged.owl annotate --ontology-iri $(URIBASE)/$@ convert -f ofn -o $@ |
| 26 | +.PRECIOUS: $(COMPONENTSDIR)/all_templates.owl |
| 27 | + |
| 28 | +.PHONY: dependencies |
| 29 | +dependencies: |
| 30 | + python3 -m pip install --break-system-packages -r ../../requirements.txt |
| 31 | + |
| 32 | + |
| 33 | +LOCAL_CLEAN_FILES = $(ALL_GRAPH_ONTOLOGIES) $(ALL_BRIDGES) $(TMPDIR)/tmp.json $(TMPDIR)/tmp.owl $(COMPONENTSDIR)/sources_merged.owl $(COMPONENTSDIR)/linkouts.owl $(TEMPLATEDIR)/linkouts.tsv |
| 34 | +# Template-regenerated bridge artifacts to restore later if HOMBA gets a curated mapping workflow: |
| 35 | +# LOCAL_CLEAN_FILES += $(SOURCE_TEMPLATES) $(NEW_BRIDGES) |
| 36 | + |
| 37 | +.PHONY: clean_files |
| 38 | +clean_files: |
| 39 | + rm -f $(LOCAL_CLEAN_FILES) |
| 40 | + |
| 41 | +sources/HOMBA_v1.json: |
| 42 | + mkdir -p $(dir $@) |
| 43 | + curl -L -o $@ "https://allen-hmba-releases.s3.us-west-2.amazonaws.com/terminology/HOMBA_v1.json" |
| 44 | + |
| 45 | +../linkml/data/template_%.tsv: sources/%.json |
| 46 | + mkdir -p $(dir $@) |
| 47 | + python3 $(SCRIPTSDIR)/structure_graph_template.py -i $< -o $@ |
| 48 | +.PRECIOUS: ../linkml/data/template_%.tsv |
| 49 | + |
| 50 | +sources/%.ofn: ../linkml/data/template_%.tsv |
| 51 | + $(LINKML) -C Class -s ../linkml/structure_graph_schema.yaml $< -o $@ |
| 52 | +.PRECIOUS: sources/%.ofn |
| 53 | + |
| 54 | +sources/uberon-bridge-to-homba.owl: |
| 55 | + mkdir -p $(dir $@) |
| 56 | + curl -L -o $(TMPDIR)/uberon-bridge-to-homba.download.owl "https://raw.githubusercontent.com/obophenotype/uberon/refs/heads/add-homba-bridge/src/ontology/bridge/uberon-bridge-to-homba.owl" |
| 57 | + python3 $(SCRIPTSDIR)/normalize_homba_bridge_xml.py $(TMPDIR)/uberon-bridge-to-homba.download.owl $@ |
| 58 | + |
| 59 | +# Disabled for now: provenance/template regeneration workflow that compares the legacy bridge |
| 60 | +# against a manually curated HOMBA mapping table and rebuilds a fresh bridge. |
| 61 | +# $(TMPDIR)/%_old_mapping.tsv: sources/uberon-bridge-to-%.owl |
| 62 | +# $(ROBOT) query --input $< --query ../sparql/bridge_mappings.sparql $@ |
| 63 | +# |
| 64 | +# ../templates/%_CCF_to_UBERON_source.tsv: $(TMPDIR)/%_old_mapping.tsv ../templates/%_CCF_to_UBERON.tsv |
| 65 | +# python3 ../scripts/mapping_source_template_generator.py -i1 $< -i2 $(word 2, $^) -o $@ |
| 66 | +# .PRECIOUS: ../templates/%_CCF_to_UBERON_source.tsv |
| 67 | +# |
| 68 | +# new-bridges/new-uberon-bridge-to-%.owl: ../templates/%_CCF_to_UBERON.tsv ../templates/%_CCF_to_UBERON_source.tsv $(MIRRORDIR)/uberon.owl |
| 69 | +# mkdir -p $(dir $@) |
| 70 | +# $(ROBOT) template --input $(MIRRORDIR)/uberon.owl --template $< --output $(TMPDIR)/sourceless-new-uberon-bridge.owl |
| 71 | +# $(ROBOT) template --input $(MIRRORDIR)/uberon.owl --template $(word 2, $^) --output $(TMPDIR)/CCF_to_UBERON_source.owl |
| 72 | +# $(ROBOT) merge --input $(TMPDIR)/sourceless-new-uberon-bridge.owl --output $(TMPDIR)/CCF_to_UBERON_source.owl --output $@ |
| 73 | + |
| 74 | +$(COMPONENTSDIR)/sources_merged.owl: $(ALL_GRAPH_ONTOLOGIES) $(ALL_BRIDGES) |
| 75 | + $(ROBOT) merge $(patsubst %, -i %, $^) relax annotate --ontology-iri $(URIBASE)/$@ -o $@ |
| 76 | + |
| 77 | +$(TMPDIR)/tmp.owl: $(SRC) $(COMPONENTSDIR)/sources_merged.owl |
| 78 | + $(ROBOT) merge $(patsubst %, -i %, $^) relax annotate --ontology-iri $(URIBASE)/$@ -o $@ |
| 79 | + |
| 80 | +$(TMPDIR)/tmp.json: $(TMPDIR)/tmp.owl |
| 81 | + $(ROBOT) convert --input $< -f json -o $@ |
| 82 | + |
| 83 | +$(TEMPLATEDIR)/linkouts.tsv: $(TMPDIR)/tmp.json |
| 84 | + python3 $(SCRIPTSDIR)/gen_linkout_template.py $< |
| 85 | + |
| 86 | +$(COMPONENTSDIR)/linkouts.owl: $(TMPDIR)/tmp.owl $(TEMPLATEDIR)/linkouts.tsv |
| 87 | + $(ROBOT) template --template $(word 2, $^) --input $< --add-prefixes template_prefixes.json -o $@ |
| 88 | + |
| 89 | + |
| 90 | +## ONTOLOGY: uberon (remove disjoint classes and properties to keep merged bridge reasoning tractable) |
| 91 | +.PHONY: mirror-uberon |
| 92 | +.PRECIOUS: $(MIRRORDIR)/uberon.owl |
| 93 | +mirror-uberon: | $(TMPDIR) |
| 94 | + if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(ROBOT) convert -I http://purl.obolibrary.org/obo/uberon/uberon-base.owl -o $(TMPDIR)/uberon-download.owl && \ |
| 95 | + $(ROBOT) remove -i $(TMPDIR)/uberon-download.owl --axioms disjoint -o $(TMPDIR)/$@.owl; fi |
| 96 | + |
| 97 | + |
| 98 | +## Disable '--equivalent-classes-allowed asserted-only' due to bridge-level equivalence patterns |
| 99 | +.PHONY: reason_test |
| 100 | +reason_test: $(EDIT_PREPROCESSED) |
| 101 | + $(ROBOT) reason --input $< --reasoner ELK \ |
| 102 | + --exclude-tautologies structural --output test.owl && rm test.owl |
| 103 | + |
| 104 | +## Disable '--equivalent-classes-allowed asserted-only' for the base release |
| 105 | +## because HOMBA currently contains inferred equivalent classes. |
| 106 | +$(ONT)-base.owl: $(EDIT_PREPROCESSED) $(OTHER_SRC) $(IMPORT_FILES) |
| 107 | + $(ROBOT_RELEASE_IMPORT_MODE) \ |
| 108 | + reason --reasoner $(REASONER) --exclude-tautologies structural --annotate-inferred-axioms false \ |
| 109 | + relax $(RELAX_OPTIONS) \ |
| 110 | + reduce -r $(REASONER) $(REDUCE_OPTIONS) \ |
| 111 | + remove --base-iri $(URIBASE)/HOMBA --axioms external --preserve-structure false --trim false \ |
| 112 | + $(SHARED_ROBOT_COMMANDS) \ |
| 113 | + annotate --link-annotation http://purl.org/dc/elements/1.1/type http://purl.obolibrary.org/obo/IAO_8000001 \ |
| 114 | + --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) \ |
| 115 | + --output $@.tmp.owl && mv $@.tmp.owl $@ |
| 116 | + |
| 117 | +$(ONT)-full.owl: $(EDIT_PREPROCESSED) $(OTHER_SRC) $(IMPORT_FILES) |
| 118 | + $(ROBOT_RELEASE_IMPORT_MODE) \ |
| 119 | + reason --reasoner ELK --exclude-tautologies structural \ |
| 120 | + relax \ |
| 121 | + reduce -r ELK \ |
| 122 | + $(SHARED_ROBOT_COMMANDS) annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) --output $@.tmp.owl && mv $@.tmp.owl $@ |
| 123 | + |
| 124 | +$(ONT)-simple.owl: $(EDIT_PREPROCESSED) $(OTHER_SRC) $(SIMPLESEED) $(IMPORT_FILES) |
| 125 | + $(ROBOT_RELEASE_IMPORT_MODE) \ |
| 126 | + reason --reasoner ELK --exclude-tautologies structural \ |
| 127 | + relax \ |
| 128 | + remove --axioms equivalent \ |
| 129 | + relax \ |
| 130 | + filter --term-file $(SIMPLESEED) --select "annotations ontology anonymous self" --trim true --signature true \ |
| 131 | + reduce -r ELK \ |
| 132 | + query --update ../sparql/inject-subset-declaration.ru --update ../sparql/inject-synonymtype-declaration.ru \ |
| 133 | + $(SHARED_ROBOT_COMMANDS) annotate --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) --output $@.tmp.owl && mv $@.tmp.owl $@ |
| 134 | + |
| 135 | +$(ONT).owl: $(ONT)-full.owl |
| 136 | + $(ROBOT) annotate --input $< --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) \ |
| 137 | + convert -o $@.tmp.owl && mv $@.tmp.owl $@ |
| 138 | + |
| 139 | +$(ONT).json: $(ONT).owl |
| 140 | + $(ROBOT) annotate --input $< --ontology-iri $(ONTBASE)/$@ $(ANNOTATE_ONTOLOGY_VERSION) \ |
| 141 | + convert --check false -f json -o $@.tmp.json && \ |
| 142 | + mv $@.tmp.json $@ |
0 commit comments