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 1354 aaronmk
.DELETE_ON_ERROR: # delete target if recipe fails
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 1452 aaronmk
DwC.cs-VegBIEN.specimens.csv: DwC1-DwC2.specimens.csv DwC2-VegBIEN.specimens.csv
55
	$(join) <$+ >$@
56
joinMaps += DwC.cs-VegBIEN.specimens.csv
57
58 1802 aaronmk
DwC-VegBIEN.specimens.csv: DwC.cs-VegBIEN.specimens.csv
59 1457 aaronmk
	$(bin)/ci_map $< >$@
60 1118 aaronmk
joinMaps += DwC-VegBIEN.specimens.csv
61
62 1802 aaronmk
DwC.self.specimens.csv: DwC-VegBIEN.specimens.csv
63 1513 aaronmk
	$(selfMap) <$<|$(bin)/sort_map >$@
64 1140 aaronmk
joinMaps += DwC.self.specimens.csv
65
66 1115 aaronmk
join_maps: $(joinMaps) ;
67
68
all += $(joinMaps)
69
70 1272 aaronmk
##### VegX
71 212 aaronmk
72 924 aaronmk
chRootMaps :=
73
74 438 aaronmk
VegX-VegBIEN.plots.csv: VegX-VegBIEN.organisms.csv
75 188 aaronmk
	env \
76 439 aaronmk
left_in_root='/*s/individualOrganismObservation/*ID->/*s/plotObservation' \
77
left_out_root='/*s/plotObservation' \
78 525 aaronmk
right_in_root='/taxonoccurrence/*_id/locationevent' \
79
right_out_root='/locationevent' \
80 439 aaronmk
$(chRoot)
81 924 aaronmk
chRootMaps += VegX-VegBIEN.plots.csv
82 439 aaronmk
83
VegX-VegBIEN.stems.csv: VegX-VegBIEN.organisms.csv
84
	env \
85 441 aaronmk
left_in_root='/*s/individualOrganismObservation->/*s/individualOrganismObservation[relatedItem[relationshipType=stemParent]/relatedItemID]' \
86 504 aaronmk
left_out_root='/*s/individualOrganismObservation[relatedItem[relationshipType=stemParent]/relatedItemID]' \
87 681 aaronmk
right_in_root='/taxonoccurrence/aggregateoccurrence/*_id/plantobservation/stemobservation' \
88 673 aaronmk
right_out_root='/stemobservation' \
89 439 aaronmk
$(chRoot)
90 924 aaronmk
chRootMaps += VegX-VegBIEN.plots.csv
91
92
ch_root_maps: $(chRootMaps) ;
93
94
all += $(chRootMaps)