Skip to content

Commit cacc526

Browse files
authored
Merge pull request #1 from Cellular-Semantics/homba-initial-build-pipeline
Bootstrap HOMBA ODK pipeline and generated assets
2 parents a8e791b + 6bb932a commit cacc526

25 files changed

Lines changed: 86038 additions & 16 deletions

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,12 @@ src/patterns/data/**/*.txt
6666
src/patterns/pattern_owl_seed.txt
6767
src/patterns/all_pattern_terms.txt
6868

69-
# End of ODK-managed rules
69+
# End of ODK-managed rules
70+
71+
__pycache__/
72+
*.pyc
73+
src/linkml/data/*.tsv
74+
src/ontology/components/linkouts.owl
75+
src/ontology/components/sources_merged.owl
76+
src/ontology/sources/HOMBA_v1.json
77+
src/ontology/sources/uberon-bridge-to-homba.owl

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pandas
2+
ruamel.yaml
3+
linkml-owl

src/config/db_graph_atlas.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
homba:
2+
species: mammalian
3+
prefix: https://purl.brain-bican.org/ontology/HOMBA_
4+
atlases: []
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
id: http://purl.obolibrary.org/obo/ABA_Uberon
2+
name: structure_graph
3+
prefixes:
4+
UBERON: 'http://purl.obolibrary.org/obo/UBERON_'
5+
IAO: 'http://purl.obolibrary.org/obo/IAO_'
6+
7+
default_curi_maps:
8+
- semweb_context
9+
- obo_context
10+
11+
types:
12+
string:
13+
base: str
14+
uri: xsd:string
15+
16+
classes:
17+
Class:
18+
slots:
19+
- id
20+
- name
21+
- acronym
22+
- symbol
23+
- parent_structure_id
24+
- subclass_of
25+
class_uri: owl:Class
26+
27+
slots:
28+
id:
29+
identifier: true
30+
name:
31+
slot_uri: rdfs:label
32+
annotations:
33+
owl: AnnotationAssertion
34+
acronym:
35+
slot_uri: oboInOwl:hasExactSynonym
36+
annotations:
37+
owl: AnnotationAssertion
38+
symbol:
39+
slot_uri: IAO:0000028
40+
annotations:
41+
owl: AnnotationAssertion
42+
parent_structure_id:
43+
slot_uri: BFO:0000050
44+
range: Class
45+
annotations:
46+
owl: SubClassOf, ObjectSomeValuesFrom
47+
subclass_of:
48+
slot_uri: rdfs:subclass_of
49+
range: Class
50+
annotations:
51+
owl: SubClassOf

src/ontology/components/all_templates.owl

Lines changed: 40721 additions & 14 deletions
Large diffs are not rendered by default.

src/ontology/homba-edit.owl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ Prefix(dcterms:=<http://purl.org/dc/terms/>)
1111
Ontology(<https://purl.brain-bican.org/ontology/homba.owl>
1212

1313
Import(<https://purl.brain-bican.org/ontology/homba/imports/merged_import.owl>)
14+
Import(<https://purl.brain-bican.org/ontology/homba/components/all_templates.owl>)
1415

1516

1617
Import(<https://purl.brain-bican.org/ontology/homba/patterns/definitions.owl>)
17-
Annotation(dcterms:description "None")
18+
Annotation(dcterms:description "An application ontology built by combining the HOMBA structure graph, curated Uberon mappings, generated linkouts, and standard ODK-managed releases.")
1819
Annotation(dcterms:license <https://creativecommons.org/licenses/unspecified>)
1920
Annotation(dcterms:title "Harmonized Ontology of Mammalian Brain Anatomy")
2021

src/ontology/homba-odk.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ primary_release: full
2222
import_group:
2323
use_base_merging: TRUE
2424
slme_individuals: exclude
25+
exclude_iri_patterns:
26+
- <http://www.informatics.jax.org/marker/MGI:*>
27+
- <http://purl.obolibrary.org/obo/OBA_*>
28+
- <http://purl.obolibrary.org/obo/ENVO_*>
29+
- <http://purl.obolibrary.org/obo/OBI_*>
30+
- <http://purl.obolibrary.org/obo/GOCHE_*>
31+
- <http://purl.obolibrary.org/obo/CARO_*>
32+
- <http://purl.obolibrary.org/obo/NCBITaxon_Union_*>
33+
- <http://www.genenames.org/cgi-bin/gene_symbol_report*>
2534
products:
2635
- id: uberon
2736
use_base: TRUE

src/ontology/homba.Makefile

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,141 @@
22
##
33
## If you need to customize your Makefile, make
44
## 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

Comments
 (0)