Project

General

Profile

1 785 aaronmk
##### Vars/functions
2
3 1272 aaronmk
# Paths
4 895 aaronmk
bin := ../bin
5 1272 aaronmk
coreMaps := DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv\
6
VegX-VegBIEN.organisms.csv
7 895 aaronmk
8 1272 aaronmk
# Commands
9
10 1115 aaronmk
review_ = $(bin)/review <$(1) >for_review/$(1)
11
review = $(call review_,$@)
12 924 aaronmk
13 1272 aaronmk
join = env header_num=1 $(bin)/join_union_sort
14
selfMap = $(bin)/cols 0 0
15 744 aaronmk
16 1272 aaronmk
define chRoot
17
$(bin)/ch_root <$< >$@
18
$(review)
19
endef
20
21 785 aaronmk
##### General targets
22
23 1115 aaronmk
all: _always $(coreMaps) join_maps ch_root_maps ;
24 150 aaronmk
25 1260 aaronmk
.SUFFIXES: # turn off built-in suffix rules
26
.SECONDARY: # don't automatically delete intermediate files
27 223 aaronmk
28 383 aaronmk
_always:
29
.PHONY: _always
30 188 aaronmk
31 383 aaronmk
clean: _always
32 196 aaronmk
	$(RM) $(all)
33 188 aaronmk
34 924 aaronmk
all :=
35
36 785 aaronmk
##### Core maps cleanup
37 198 aaronmk
38 895 aaronmk
ifneq ($(filter .%.last_cleanup,$(MAKECMDGOALS)),)
39
.%.last_cleanup: %
40
	$(bin)/in_place $< $(bin)/simplify_xpath
41 1132 aaronmk
	$(bin)/in_place $< $(bin)/sort_map
42 895 aaronmk
	touch $@
43 1115 aaronmk
	$(call review_,$<)
44 895 aaronmk
else
45
$(coreMaps): _always
46
	$(MAKE) $(@:%=.%.last_cleanup)
47
endif
48 350 aaronmk
49 1272 aaronmk
##### DwC
50 1115 aaronmk
51
joinMaps :=
52
53 1270 aaronmk
DwC2.ci-VegBIEN.specimens.csv: DwC2-VegBIEN.specimens.csv
54
	$(selfMap) <$<|$(bin)/ucase_first 0|$(join) $< >$@
55
joinMaps += DwC2.ci-VegBIEN.specimens.csv
56
57
DwC-VegBIEN.specimens.csv: DwC1-DwC2.specimens.csv DwC2.ci-VegBIEN.specimens.csv
58
	$(join) <$+ >$@
59 1118 aaronmk
joinMaps += DwC-VegBIEN.specimens.csv
60
61 1140 aaronmk
DwC.self.specimens.csv: DwC-VegBIEN.specimens.csv
62 1270 aaronmk
	$(selfMap) <$< >$@
63 1140 aaronmk
joinMaps += DwC.self.specimens.csv
64
65 1115 aaronmk
join_maps: $(joinMaps) ;
66
67
all += $(joinMaps)
68
69 1272 aaronmk
##### VegX
70 212 aaronmk
71 924 aaronmk
chRootMaps :=
72
73 438 aaronmk
VegX-VegBIEN.plots.csv: VegX-VegBIEN.organisms.csv
74 188 aaronmk
	env \
75 439 aaronmk
left_in_root='/*s/individualOrganismObservation/*ID->/*s/plotObservation' \
76
left_out_root='/*s/plotObservation' \
77 525 aaronmk
right_in_root='/taxonoccurrence/*_id/locationevent' \
78
right_out_root='/locationevent' \
79 439 aaronmk
$(chRoot)
80 924 aaronmk
chRootMaps += VegX-VegBIEN.plots.csv
81 439 aaronmk
82
VegX-VegBIEN.stems.csv: VegX-VegBIEN.organisms.csv
83
	env \
84 441 aaronmk
left_in_root='/*s/individualOrganismObservation->/*s/individualOrganismObservation[relatedItem[relationshipType=stemParent]/relatedItemID]' \
85 504 aaronmk
left_out_root='/*s/individualOrganismObservation[relatedItem[relationshipType=stemParent]/relatedItemID]' \
86 681 aaronmk
right_in_root='/taxonoccurrence/aggregateoccurrence/*_id/plantobservation/stemobservation' \
87 673 aaronmk
right_out_root='/stemobservation' \
88 439 aaronmk
$(chRoot)
89 924 aaronmk
chRootMaps += VegX-VegBIEN.plots.csv
90
91
ch_root_maps: $(chRootMaps) ;
92
93
all += $(chRootMaps)