Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ catalog-v001.xml
graphviz-images/
junk/
lib/
mro-import.owl
mro.xlsx
mro.owl.gz
iedb.zip
reference/
src/.cache/
src/__pycache__/
Expand Down
73 changes: 50 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,29 @@ build/mhc.fasta: | build
update-seqs: src/update_seqs.py ontology/chain-sequence.tsv build/hla.fasta build/mhc.fasta
python3 $^

build/hla_prot.fasta: | build
curl -o $@ -L https://raw.githubusercontent.com/ANHIG/IMGTHLA/Latest/hla_prot.fasta

build/AlleleList.txt: | build
curl -o $@ -L https://raw.githubusercontent.com/ANHIG/IMGTHLA/Latest/Allelelist.txt

.PHONY: update-alleles
update-alleles: src/check_missing_alleles.py ontology/chain-sequence.tsv ontology/chain.tsv ontology/molecule.tsv ontology/genetic-locus.tsv index.tsv build/hla_prot.fasta build/AlleleList.txt
python3 $^

### OWL Files

mro.owl: mro-import.owl index.tsv $(build_files) ontology/metadata.ttl | build/robot.jar
build/mro.owl: build/mro-import.owl index.tsv $(build_files) ontology/metadata.ttl | build/robot.jar
$(ROBOT) merge \
--input mro-import.owl \
--input $< \
template \
--prefix "MRO: $(OBO)/MRO_" \
--prefix "REO: $(OBO)/REO_" \
--template index.tsv \
$(templates) \
--merge-before \
reason --reasoner HermiT \
reason \
--reasoner ELK \
--remove-redundant-subclass-axioms false \
annotate \
--ontology-iri "$(OBO)/mro.owl" \
Expand All @@ -123,7 +133,7 @@ mro.owl: mro-import.owl index.tsv $(build_files) ontology/metadata.ttl | build/r
--annotation-file ontology/metadata.ttl \
--output $@

mro-import.owl: ontology/import.txt $(LIB)/ro.owl $(LIB)/obi.owl $(LIB)/eco.owl | build/robot.jar
build/mro-import.owl: ontology/import.txt $(LIB)/ro.owl $(LIB)/obi.owl $(LIB)/eco.owl | build/robot.jar
$(ROBOT) merge \
--input $(LIB)/eco.owl \
--input $(LIB)/obi.owl \
Expand All @@ -140,6 +150,7 @@ mro-import.owl: ontology/import.txt $(LIB)/ro.owl $(LIB)/obi.owl $(LIB)/eco.owl
--lower-terms $< \
--output $@


# fetch ontology dependencies
$(LIB)/%:
mkdir -p $(LIB)
Expand All @@ -151,11 +162,14 @@ $(LIB)/%:
# This includes an extended OWL file
# and tables for the IEDB database and Finders.

iedb:
mkdir -p $@
IEDB_TARGETS := build/mro-iedb.owl \
build/mhc_allele_restriction.tsv \
build/ALLELE_FINDER_NAMES.csv \
build/ALLELE_FINDER_SEARCH.csv \
build/ALLELE_FINDER_TREE.csv

# extended version for IEDB use
iedb/mro-iedb.owl: mro.owl iedb/iedb.tsv iedb/iedb-manual.tsv | build/robot.jar iedb
build/mro-iedb.owl: build/mro.owl iedb/iedb.tsv iedb/iedb-manual.tsv | build/robot.jar iedb
$(ROBOT) template \
--prefix "MRO: $(OBO)/MRO_" \
--input $< \
Expand All @@ -164,26 +178,26 @@ iedb/mro-iedb.owl: mro.owl iedb/iedb.tsv iedb/iedb-manual.tsv | build/robot.jar
--merge-before \
--output $@

build/mhc_allele_restriction.csv: iedb/mro-iedb.owl src/mhc_allele_restriction.rq | build/robot.jar
build/mhc_allele_restriction.csv: build/mro-iedb.owl src/mhc_allele_restriction.rq | build/robot.jar
$(ROBOT) query --input $(word 1,$^) --select $(word 2,$^) $@

iedb/mhc_allele_restriction.tsv: src/clean.py build/mhc_allele_restriction.csv | iedb
build/mhc_allele_restriction.tsv: src/clean.py build/mhc_allele_restriction.csv | iedb
python3 $^ > $@

iedb/ALLELE_FINDER_NAMES.csv: iedb/mro-iedb.owl src/names.rq | build/robot.jar iedb
build/ALLELE_FINDER_NAMES.csv: build/mro-iedb.owl src/names.rq | build/robot.jar iedb
$(ROBOT) query --input $(word 1,$^) --select $(word 2,$^) $@.tmp --format csv
tail -n+2 $@.tmp | dos2unix > $@
rm $@.tmp

iedb/ALLELE_FINDER_SEARCH.csv: iedb/mro-iedb.owl src/search.rq | build/robot.jar iedb
build/ALLELE_FINDER_SEARCH.csv: build/mro-iedb.owl src/search.rq | build/robot.jar iedb
$(ROBOT) query --input $(word 1,$^) --select $(word 2,$^) $@.tmp --format csv
tail -n+2 $@.tmp | dos2unix > $@
rm $@.tmp

build/parents.csv: iedb/mro-iedb.owl src/parents.rq | build/robot.jar
build/parents.csv: build/mro-iedb.owl src/parents.rq | build/robot.jar
$(ROBOT) query --input $(word 1,$^) --select $(word 2,$^) $@

iedb/ALLELE_FINDER_TREE.csv: src/tree.py build/parents.csv | iedb
build/ALLELE_FINDER_TREE.csv: src/tree.py build/parents.csv | iedb
python3 $^ --mode CSV > $@

build/tree.json: src/tree.py build/parents.csv | build
Expand All @@ -192,16 +206,15 @@ build/tree.json: src/tree.py build/parents.csv | build
build/full_tree.json: src/tree.py build/full_tree.csv | build
python3 $^ --mode JSON > $@

IEDB_TARGETS := iedb/mro-iedb.owl iedb/mhc_allele_restriction.tsv iedb/ALLELE_FINDER_NAMES.csv iedb/ALLELE_FINDER_SEARCH.csv iedb/ALLELE_FINDER_TREE.csv
.PHONY: update-iedb
update-iedb: $(IEDB_TARGETS)


### General
### Testing & verification

VERIFY_QUERIES = $(wildcard src/verify/*.rq)

build/mro-base.owl: mro.owl | build/robot.jar
build/mro-base.owl: build/mro.owl | build/robot.jar
$(ROBOT) remove --input $< \
--base-iri $(OBO)/MRO_ \
--axioms external \
Expand All @@ -212,14 +225,14 @@ build/report.csv: build/mro-base.owl | build/robot.jar
$(ROBOT) report --input $< --print 10 --output $@

.PHONY: verify
verify: iedb/mro-iedb.owl $(VERIFY_QUERIES) | build/robot.jar
verify: build/mro-iedb.owl $(VERIFY_QUERIES) | build/robot.jar
$(ROBOT) verify --input $< \
--queries $(VERIFY_QUERIES) \
--output-dir build

# Validate a relaxed/reduced version of MRO
.PHONY: validate
validate: mro.owl $(source_files) | build/robot.jar build/validate
validate: build/mro.owl $(source_files) | build/robot.jar build/validate
$(ROBOT) relax --input $< \
reduce remove --axioms equivalent \
validate $(foreach i,$(source_files),--table $(i)) \
Expand All @@ -228,15 +241,29 @@ validate: mro.owl $(source_files) | build/robot.jar build/validate
--output-dir build/validate

.PRECIOUS: build/mhc_allele_restriction_errors.tsv
build/mhc_allele_restriction_errors.tsv: src/validate_mhc_allele_restriction.py iedb/mhc_allele_restriction.tsv | build
build/mhc_allele_restriction_errors.tsv: src/validate_mhc_allele_restriction.py build/mhc_allele_restriction.tsv | build
python3 $^ $@

.PRECIOUS: build/whitespace.tsv
build/whitespace.tsv: src/detect_whitespace.py index.tsv iedb/iedb.tsv iedb/iedb-manual.tsv $(source_files)
python3 $^ $@


### Release files

iedb.zip: $(IEDB_TARGETS)
zip $@ $^

mro.owl.gz: build/mro.owl
gzip -f $<

release: iedb.zip mro.owl.gz


### General

.PHONY: test
test: build/report.csv verify validate build/mhc_allele_restriction_errors.tsv
test: build/report.csv verify build/mhc_allele_restriction_errors.tsv

.PHONY: pytest
pytest:
Expand All @@ -246,8 +273,8 @@ pytest:
.PHONY: clean
clean:
rm -rf build
rm -f mro.owl mro-import.owl
rm -f $(IEDB_TARGETS)
rm -f iedb.zip
rm -f mro.owl.gz

.PHONY: all
all: update-iedb
all: clean release
Loading