Project

General

Profile

1 235 aaronmk
os = $(shell uname)
2 224 aaronmk
3 235 aaronmk
SED = sed -$(if $(filter Darwin,$(os)),E,r)
4
5 240 aaronmk
#####
6 224 aaronmk
7 240 aaronmk
all: _not_file misc
8 197 aaronmk
	$(MAKE) plots
9 198 aaronmk
	./join VegX VegBank
10
	./join VegX VegBIEN
11 199 aaronmk
	./review
12 150 aaronmk
13 223 aaronmk
.SUFFIXES:
14
15 235 aaronmk
_not_file:
16
.PHONY: _not_file
17 188 aaronmk
18 240 aaronmk
misc = schemas/vegbien.sql schemas/vegbien_empty.sql VegX-VegBIEN.organisms.csv
19
20 199 aaronmk
all =\
21
$(wildcard for_review/*.csv) \
22
$(filter-out VegX-% VegBank-%,$(wildcard *-VegBank.*.csv)) \
23 223 aaronmk
VegX-*.plots.csv $(misc)
24 196 aaronmk
25 235 aaronmk
clean: _not_file
26 196 aaronmk
	$(RM) $(all)
27 188 aaronmk
28 240 aaronmk
#####
29 198 aaronmk
30 240 aaronmk
misc: $(misc)
31
.PRECIOUS: $(misc)
32
33 350 aaronmk
bin = ../bin
34
in_place = $(bin)/in_place
35 356 aaronmk
cat_csv = $(bin)/cat_csv
36 350 aaronmk
repl = $(bin)/repl
37
sort = $(bin)/sort 1 0
38
chRoot = $(bin)/ch_root <$< >$@
39 240 aaronmk
empty = $(SED) -n \
40
's/^CREATE TABLE ([0-9A-Za-z_]+) \($$/TRUNCATE \1 CASCADE;/p' <$< >$@
41
42 356 aaronmk
VegBank-VegBIEN.%.csv: VegBank-VegBIEN.csv VegBank-VegBIEN.%_only.csv
43
	$(bin)/cat_csv <$+ >$@
44
.PRECIOUS: VegBank-VegBIEN.%.csv
45
46 212 aaronmk
schemas/vegbien.sql: schemas/vegbank.sql
47 356 aaronmk
	$(repl) <$< VegBank-VegBIEN.schema.csv >$@
48 212 aaronmk
49 223 aaronmk
schemas/vegbien_empty.sql: schemas/vegbien.sql
50
	$(empty)
51
52 350 aaronmk
VegX-VegBank.organisms.csv: _not_file
53
	$(in_place) $@ $(sort)
54
55 212 aaronmk
VegX-VegBIEN.organisms.csv: VegX-VegBank.organisms.csv
56 221 aaronmk
	$(repl) <$< VegBank-VegBIEN.csv 1|$(sort) >$@
57 212 aaronmk
58 240 aaronmk
#####
59 212 aaronmk
60 235 aaronmk
plots: _not_file $(subst .organisms.,.plots.,$(wildcard VegX-*.organisms.csv))
61 197 aaronmk
62 188 aaronmk
chRoot2PlotsLeftVegx =\
63
	env \
64
	left_in_root='/*s/individualOrganismObservation/*ID->/*s/plotObservation' \
65
	left_out_root='/*s/plotObservation' \
66
	$(chRoot)
67
68
VegX-VegBank.plots.csv: VegX-VegBank.organisms.csv
69
	$(chRoot2PlotsVegxVegbank)
70
chRoot2PlotsVegxVegbank =\
71
	env \
72
	right_in_root='/taxonObservation/*_ID/observation' \
73
	right_out_root='/observation' \
74
	$(chRoot2PlotsLeftVegx)
75
76
VegX-VegBIEN.plots.csv: VegX-VegBIEN.organisms.csv
77
	$(chRoot2PlotsVegxVegbien)
78
chRoot2PlotsVegxVegbien =\
79
	env \
80 200 aaronmk
	right_in_root='/taxonoccurrence/*_ID/plotevent' \
81 188 aaronmk
	right_out_root='/plotevent' \
82
	$(chRoot2PlotsLeftVegx)