# ========================================
# Regulation XP test
# ========================================
# Anyone with oboedit2.29 or higher can generate these files
# Just change to this directory and type
#
#    make

GO=../../ontology/gene_ontology_edit.obo
SOURCES= go_regtest_withPosNeg_withPF  go_regtest_withPosNeg_noPF go_regtest_noPosNeg_withPF  go_regtest_noPosNeg_noPF 
TARGETS= $(patsubst %,%.obo,$(SOURCES))

all: $(TARGETS)

update:
	cd ../../ontology && cvs update gene_ontology_edit.obo

all_latest: update all

test: all $(patsubst %,%-test,$(TARGETS))
all_owl: all $(patsubst %,%.owl,$(SOURCES))
all_owlx: all $(patsubst %,%.owl-xml,$(SOURCES))

# ALL intersection_of tags present
# withPosNeg: Includes relationship: tags for regulates, positively_regulates and negatively_regulates
# withPF: Regulation of MF terms (in MP) have links to the corresponding terms (in MF)
go_regtest_withPosNeg_withPF.obo: $(GO)
	obo2obo -semanticparse -o -saveimpliedlinks $@ $<
.PRECIOUS: go_regtest_all.obo

# ALL intersection_of tags present
# withPosNeg: Includes relationship: tags for regulates, positively_regulates and negatively_regulates
# noPF: Regulation of MF terms (in MP) DO NOT HAVE relationship tags to the corresponding terms (in MF)
#    (but the intersection_of tags do reference the MF term)
# *** this is the combination we will probably go with ***
go_regtest_withPosNeg_noPF.obo: go_regtest_withPosNeg_withPF.obo
	./obol-remove-inter-ontology-link.pl $< >  $@.tmp && mv $@.tmp $@
.PRECIOUS: go_regtest_withPosNeg_noPF.obo

# ALL intersection_of tags present
# noPosNeg: Includes relationship: tags for regulates, BUT NOT positively_regulates and negatively_regulates
# withPF: Regulation of MF terms (in MP) have links to the corresponding terms (in MF)
go_regtest_noPosNeg_withPF.obo: go_regtest_withPosNeg_withPF.obo
	egrep -v '^relationship: .*_regulates' $< > $@.tmp && mv $@.tmp $@
.PRECIOUS: go_regtest_noPosNeg_withPF.obo

# ALL intersection_of tags present
# noPosNeg: Includes relationship: tags for regulates, BUT NOT positively_regulates and negatively_regulates
# noPF: Regulation of MF terms (in MP) DO NOT HAVE relationship tags to the corresponding terms (in MF)
#    (but the intersection_of tags do reference the MF term)
go_regtest_noPosNeg_noPF.obo: go_regtest_noPosNeg_withPF.obo
	./obol-remove-inter-ontology-link.pl $< >  $@.tmp && mv $@.tmp $@
.PRECIOUS: go_regtest_noPosNeg_noPF.obo

%.owl: %.obo
	obo2owl -o file://`pwd`/$@ $<

%.owl-xml: %.obo
	obo2owl -owlformat owlxml -o file://`pwd`/$@ $<

# this is just an extra-paranoid test to see if the generated files can be parsed
%-test: %
	obo2obo -o $@.tmp $< && diff $@.tmp $< > $@ ; echo done