-
Notifications
You must be signed in to change notification settings - Fork 36
/
Makefile
executable file
·114 lines (84 loc) · 5.3 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
OBO=http://purl.obolibrary.org/obo
ONT=foodon
BASE=$(OBO)/$(ONT)
SRC=$(ONT)-edit.ofn
RELEASEDIR=../..
ROBOT= robot --catalog catalog-v001.xml
OWLTOOLS= owltools
# THE "make" PROCESS VIA robot/owlapi PAYS ATTENTION TO THE catalog-v001.xml
# file residing in this directory. If you are running into the problem of
# local files not being found, e.g. with this error coming up:
#
# org.semanticweb.owlapi.model.UnloadableImportException: Could not load \
# imported ontology: <http://purl.obolibrary.org/obo/FOODON/imports/efo_import.owl> \
# Cause: https://raw.githubusercontent.com/FoodOntology/foodon/master/src/imports/efo_import.owl
# then the catalog catalog-v001.xml file likely needs to be edited, or delete it
# and load the root [ontology]-edit.owl file in Protege and ensure the
# import file connections are established correctly. This will rewrite the
# catalog-v001.xml file, and the make process should succeed.
# Temporarily foodon.owl and foodon_core.owl are the same.
all: all_imports $(ONT).owl
.PHONY: test
test: reason owl2dl
.PHONY: owl2dl
owl2dl: foodon-merged.ofn
$(ROBOT) validate-profile -i $< --profile DL -o owl2_profile_violations.txt
# Run a basic reasoner to find inconsistencies
.PHONY: reason
reason: foodon-merged.ofn
$(ROBOT) reason --input $< --reasoner ELK --equivalent-classes-allowed none
prepare_release: all
# cp $(ONT).owl $(RELEASEDIR)
# cp imports/*.ofn $(RELEASEDIR)/imports/ &&\
$(ROBOT) convert --input $(ONT)-merged.ofn --xml-entities --output $(RELEASEDIR)/$(ONT).owl &&\
cp $(ONT)-base.owl $(RELEASEDIR) &&\
cp foodon-synonyms.tsv $(RELEASEDIR)
# (test -f subsets/*.owl && cp subsets/*.owl $(RELEASEDIR)/subsets && git add $(RELEASEDIR)/subsets/* || echo "no subsets") &&\
echo "Release files are now in $(RELEASEDIR) - now you should commit, push and make a release on github"
#make
#Annotates foodon.owl ( $(ONT).owl ) file with release
$(ONT).owl: $(SRC)
# $(ROBOT) annotate --input $(SRC) --xml-entities -V $(BASE)/releases/`date +%Y-%m-%d`/$(ONT).owl --typed-annotation http://purl.org/dc/terms/date `date +%Y-%m-%d` xsd:date --output $(SRC)
# Merge ontology and imports into one file, and commment out imports tags
# production merged file shouldn't allow equivalent classes but sometimes
# import files have them.
# remove --select "owl:NamedIndividual=obo:BFO_*"
$(ROBOT) merge --input $(SRC) --xml-entities reason --reasoner ELK --equivalent-classes-allowed false relax reduce --output $(ONT)-merged.ofn
make test
python3 scripts/foodon-merged-remediation.py
# Make foodon-base.owl, stripped of food product import tags and files
# Add GAZ?
$(ROBOT) remove --input $(ONT)-edit.ofn --xml-entities --select imports --trim true annotate --ontology-iri "http://purl.obolibrary.org/obo/foodon-base.owl" merge --input imports/general_import.ofn --input imports/ncbitaxon_import.ofn --input imports/chebi_import.ofn --input imports/robot_process.ofn convert --output $(ONT)-base.owl
# Make a file that provides labels and synonyms for each term in ontology from BFO:Entity down.
# $(ROBOT) convert --input $(ONT)-merged.ofn --output $(ONT)-merged.owl
# $(ROBOT) query --format TSV --input $(ONT)-merged.owl -s foodon_synonyms.sparql foodon-synonyms.tsv
# rm $(ONT)-merged.owl
$(ROBOT) query --format TSV --input $(ONT)-merged.ofn -s sparql/foodon_synonyms.sparql foodon-synonyms.tsv
# ALL OntoFox imports: chebi efo envo eo gazetteer ncbitaxon obi ro
# ISSUE WITH BFO: Ontofox doesn't download disjointWith axioms????
IMPORTS = cob chebi gaz general ncbitaxon
IMPORTS_OWL = $(patsubst %, imports/%_import.ofn,$(IMPORTS))
IMPORTS_TXT = $(patsubst %, imports/%_ontofox.txt,$(IMPORTS))
# Make this target to regenerate ALL
all_imports: $(IMPORTS_OWL)
# Dependency between import.owl and ontofox.txt file. Only fetches .owl if it
# doesn't exist or if .txt has later timestamp.
# All annotations should only exist in the ontology-metadata.owl file and bfo.owl files.
# Because OWLAPI is erroniously parsing 1 line commented out annotations, make the "sed ..." step last.
# On Macs we need the '.bak' after -i to avoid a parsing error; while on other linux it fails
imports/%_import.ofn: imports/%_ontofox.txt
curl -s -F file=@imports/$*_ontofox.txt -o $*_import.owl https://ontofox.hegroup.org/service.php
echo "Downloaded *_import.owl"
# $(ROBOT) reduce --input $@ --reasoner ELK --output $@
# ISSUE: rdf:type sneaking in as an annotation property which is causing DL validation fail.
$(ROBOT) reduce --input $*_import.owl --xml-entities --prefix "obo: http://purl.obolibrary.org/obo/" --reasoner ELK remove --term rdf:type --select annotation-properties --select self --output imports/$*_import.ofn
rm $*_import.owl
# echo "Entity substitution."
# sed -i '.bak' 's/<owl:AnnotationProperty[^>]*\/>/<!-- & -->/; s/<\/owl:AnnotationProperty>/& -->/; s/<owl:AnnotationProperty[^>]*">/<!-- &/;' $@ || sed -i 's/<owl:AnnotationProperty[^>]*\/>/<!-- & -->/; s/<\/owl:AnnotationProperty>/& -->/; s/<owl:AnnotationProperty[^>]*">/<!-- &/;' $@
# echo "Removed annotation definitions."
.PRECIOUS: imports/%_import.ofn
## Make Targets for Robot Templates: ##
# Organismal Materials Robot template
imports/robot/plant_parts.ofn: imports/robot/plant_parts.tsv
$(ROBOT) template --template $< -i foodon-merged.ofn --ontology-iri "http://purl.obolibrary.org/foodon/imports/robot_plant_parts.ofn" -o [email protected] && mv [email protected] $@