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