Makefile 9.26 KB
Newer Older
1
2
D1 := data/raw
D2 := output/formatted
3
D3 := output/processed
4
5
D4 := figs/test.format.tree
D5 := figs/test.traits
Georges Kunstler's avatar
Georges Kunstler committed
6
D6 := figs/test.CWM
Georges Kunstler's avatar
Georges Kunstler committed
7
sites:= Fushan Paracou BCI Mbaiki Luquillo Japan Spain Sweden Canada France Swiss NSW NVS 
8
9
10
D3Done :=  $(addsuffix /Done.txt,$(addprefix $(D3)/, $(sites) )) 
D2traits :=  $(addsuffix /traits.csv,$(addprefix $(D2)/, $(sites) )) 
D2tree :=  $(addsuffix /tree.csv,$(addprefix $(D2)/, $(sites) )) 
Daniel Falster's avatar
Daniel Falster committed
11

12

13
all: TRY sites
14

15
sites: $(sites)
16

17

18
#-------------------------------------------------------
Daniel Falster's avatar
Daniel Falster committed
19

20
21
22
23
TRY: $(D2)/TRY/data.TRY.std.rds

$(D2)/TRY/data.TRY.std.rds:  
	Rscript R/format.data/TRY.R
24

Georges Kunstler's avatar
Georges Kunstler committed
25
26
27
#-------------------------------------------------------
GLOBAL: $(D3)/Done.txt

28
29
$(D3)/Done.txt: R/process.data/merge.all.processed.data.R sites R/process.data/process-fun.R $(D2)/traits.std.global.csv $(D5)/Done.txt
	Rscript $< 
Georges Kunstler's avatar
Georges Kunstler committed
30

31
#-------------------------------------------------------
32

33
BCI: $(D3)/BCI/Done.txt
34

Georges Kunstler's avatar
Georges Kunstler committed
35
$(D3)/BCI/Done.txt: R/process.data/process-fun.R $(D2)/BCI/traits.csv 
36
	Rscript -e "source('$<'); process_bigplot_dataset('BCI', Rlim=15,std.traits='no');  process_bigplot_dataset('BCI', Rlim=15,std.traits='global');"
37

Georges Kunstler's avatar
Georges Kunstler committed
38
$(D2)/BCI/traits.csv: R/find.trait/BCI.R R/find.trait/trait-fun.R $(D2)/BCI/tree.csv 
Georges Kunstler's avatar
Georges Kunstler committed
39
	Rscript $< ; rm -f $(D5)/Done.txt
40
41

$(D2)/BCI/tree.csv: R/format.data/BCI.R $(shell find $(D1)/BCI -type f)
Georges Kunstler's avatar
Georges Kunstler committed
42
	Rscript $< ; rm -f $(D4)/Done.txt
Georges Kunstler's avatar
Georges Kunstler committed
43
44
45
46
47

#-------------------------------------------------------

Japan: $(D3)/Japan/Done.txt

Georges Kunstler's avatar
Georges Kunstler committed
48
$(D3)/Japan/Done.txt: R/process.data/process-fun.R $(D2)/Japan/traits.csv 
49
	Rscript -e "source('$<');  process_bigplot_dataset('Japan', Rlim=15,std.traits='no');  process_bigplot_dataset('Japan', Rlim=15,std.traits='global');"
Georges Kunstler's avatar
Georges Kunstler committed
50

Georges Kunstler's avatar
Georges Kunstler committed
51
$(D2)/Japan/traits.csv: R/find.trait/Japan.R R/find.trait/trait-fun.R $(D2)/Japan/tree.csv 
Georges Kunstler's avatar
Georges Kunstler committed
52
	Rscript $< ; rm -f $(D5)/Done.txt
Georges Kunstler's avatar
Georges Kunstler committed
53
54

$(D2)/Japan/tree.csv: R/format.data/Japan.R $(shell find $(D1)/Japan -type f)
Georges Kunstler's avatar
Georges Kunstler committed
55
	Rscript $< ; rm -f $(D4)/Done.txt
56
57
58
59
#-------------------------------------------------------

Luquillo: $(D3)/Luquillo/Done.txt

Georges Kunstler's avatar
Georges Kunstler committed
60
$(D3)/Luquillo/Done.txt: R/process.data/process-fun.R $(D2)/Luquillo/traits.csv 
61
	Rscript -e "source('$<'); process_bigplot_dataset('Luquillo', Rlim=15,std.traits='no'); process_bigplot_dataset('Luquillo', Rlim=15,std.traits='global');"
62

Georges Kunstler's avatar
Georges Kunstler committed
63
$(D2)/Luquillo/traits.csv: R/find.trait/Luquillo.R R/find.trait/trait-fun.R $(D2)/Luquillo/tree.csv 
Georges Kunstler's avatar
Georges Kunstler committed
64
	Rscript $< ; rm -f $(D5)/Done.txt
65
66

$(D2)/Luquillo/tree.csv: R/format.data/Luquillo.R $(shell find $(D1)/Luquillo -type f)
Georges Kunstler's avatar
Georges Kunstler committed
67
	Rscript $< ; rm -f $(D4)/Done.txt
68
69
70
71
72

#-------------------------------------------------------

Mbaiki: $(D3)/Mbaiki/Done.txt

Georges Kunstler's avatar
Georges Kunstler committed
73
$(D3)/Mbaiki/Done.txt: R/process.data/process-fun.R $(D2)/Mbaiki/traits.csv 
Georges Kunstler's avatar
Georges Kunstler committed
74
	Rscript -e "source('$<');  process_bigplot_dataset('Mbaiki', Rlim=15,std.traits='global');"
75

Georges Kunstler's avatar
Georges Kunstler committed
76
$(D2)/Mbaiki/traits.csv: R/find.trait/Mbaiki.R R/find.trait/trait-fun.R $(D2)/Mbaiki/tree.csv 
Georges Kunstler's avatar
Georges Kunstler committed
77
	Rscript $< ; rm -f $(D5)/Done.txt 
78
79

$(D2)/Mbaiki/tree.csv: R/format.data/Mbaiki.R $(shell find $(D1)/Mbaiki -type f)
Georges Kunstler's avatar
Georges Kunstler committed
80
	Rscript $< ; rm -f $(D4)/Done.txt 
81

82
83
84
85
#-------------------------------------------------------

Canada: $(D3)/Canada/Done.txt

Georges Kunstler's avatar
Georges Kunstler committed
86
$(D3)/Canada/Done.txt: R/process.data/process-fun.R  $(D2)/Canada/traits.csv 
Georges Kunstler's avatar
Georges Kunstler committed
87
	Rscript -e "source('$<'); process_inventory_dataset('Canada',std.traits='global');"
88

Georges Kunstler's avatar
Georges Kunstler committed
89
$(D2)/Canada/traits.csv: R/find.trait/Canada.R R/find.trait/trait-fun.R $(D2)/Canada/tree.csv $(D2)/TRY/data.TRY.std.rds
Georges Kunstler's avatar
Georges Kunstler committed
90
	Rscript $< ; rm -f $(D5)/Done.txt
91
92

$(D2)/Canada/tree.csv: R/format.data/Canada.R $(shell find $(D1)/Canada -type f)
Georges Kunstler's avatar
Georges Kunstler committed
93
	Rscript $< ; rm -f $(D4)/Done.txt
94

95
96
97
#-------------------------------------------------------
France: $(D3)/France/Done.txt

Georges Kunstler's avatar
Georges Kunstler committed
98
$(D3)/France/Done.txt: R/process.data/process-fun.R $(D2)/France/traits.csv 
Georges Kunstler's avatar
Georges Kunstler committed
99
	Rscript -e "source('$<');  process_inventory_dataset('France',std.traits='global');"
100

Georges Kunstler's avatar
Georges Kunstler committed
101
$(D2)/France/traits.csv: R/find.trait/France.R R/find.trait/trait-fun.R $(D2)/France/tree.csv $(D2)/TRY/data.TRY.std.rds
Georges Kunstler's avatar
Georges Kunstler committed
102
	Rscript $< ; rm -f $(D5)/Done.txt
103
104

$(D2)/France/tree.csv: R/format.data/France.R $(shell find $(D1)/France -type f)
Georges Kunstler's avatar
Georges Kunstler committed
105
	Rscript $< ; rm -f $(D4)/Done.txt
106

107
108
#-------------------------------------------------------

109
110
Fushan: $(D3)/Fushan/Done.txt

Georges Kunstler's avatar
Georges Kunstler committed
111
$(D3)/Fushan/Done.txt: R/process.data/process-fun.R $(D2)/Fushan/traits.csv 
Georges Kunstler's avatar
Georges Kunstler committed
112
	Rscript -e "source('$<');  process_bigplot_dataset('Fushan', Rlim=15,std.traits='global');"
113

114

Georges Kunstler's avatar
Georges Kunstler committed
115
$(D2)/Fushan/traits.csv: R/find.trait/Fushan.R R/find.trait/trait-fun.R $(D2)/Fushan/tree.csv 
Georges Kunstler's avatar
Georges Kunstler committed
116
	Rscript $< ; rm -f $(D5)/Done.txt
117
118

$(D2)/Fushan/tree.csv: R/format.data/Fushan.R $(shell find $(D1)/Fushan -type f)
Georges Kunstler's avatar
Georges Kunstler committed
119
	Rscript $< ; rm -f $(D4)/Done.txt
120

121
#-------------------------------------------------------
122

123
124
NSW: $(D3)/NSW/Done.txt

Georges Kunstler's avatar
Georges Kunstler committed
125
$(D3)/NSW/Done.txt: R/process.data/process-fun.R $(D2)/NSW/traits.csv 
Georges Kunstler's avatar
Georges Kunstler committed
126
	Rscript -e "source('$<');  process_inventory_dataset('NSW',std.traits='global');"
127

Georges Kunstler's avatar
Georges Kunstler committed
128
$(D2)/NSW/traits.csv: R/find.trait/NSW.R R/find.trait/trait-fun.R $(D2)/NSW/tree.csv $(D2)/TRY/data.TRY.std.rds
Georges Kunstler's avatar
Georges Kunstler committed
129
	Rscript $< ; rm -f $(D5)/Done.txt
130
131

$(D2)/NSW/tree.csv: R/format.data/NSW.R $(shell find $(D1)/NSW -type f)
Georges Kunstler's avatar
Georges Kunstler committed
132
	Rscript $< ; rm -f $(D4)/Done.txt
133

134
135
#-------------------------------------------------------

Daniel Falster's avatar
Daniel Falster committed
136
137
NVS: $(D3)/NVS/Done.txt

Georges Kunstler's avatar
Georges Kunstler committed
138
$(D3)/NVS/Done.txt: R/process.data/process-fun.R $(D2)/NVS/traits.csv 
Georges Kunstler's avatar
Georges Kunstler committed
139
	Rscript -e "source('$<');  process_inventory_dataset('NVS',std.traits='global');"
140

Georges Kunstler's avatar
Georges Kunstler committed
141
$(D2)/NVS/traits.csv: R/find.trait/NVS.R R/find.trait/trait-fun.R $(D2)/NVS/tree.csv 
Georges Kunstler's avatar
Georges Kunstler committed
142
	Rscript $< ; rm -f $(D5)/Done.txt
143
144

$(D2)/NVS/tree.csv: R/format.data/NVS.R $(shell find $(D1)/NVS -type f)
Georges Kunstler's avatar
Georges Kunstler committed
145
	Rscript $< ; rm -f $(D4)/Done.txt
146

147
148
#-------------------------------------------------------

149
Paracou: $(D3)/Paracou/Done.txt
150

Georges Kunstler's avatar
Georges Kunstler committed
151
$(D3)/Paracou/Done.txt: R/process.data/process-fun.R $(D2)/Paracou/traits.csv 
Georges Kunstler's avatar
Georges Kunstler committed
152
	Rscript -e "source('$<');  process_bigplot_dataset('Paracou', Rlim=15,std.traits='global');"
153

Georges Kunstler's avatar
Georges Kunstler committed
154
$(D2)/Paracou/traits.csv: R/find.trait/Paracou.R R/find.trait/trait-fun.R $(D2)/Paracou/tree.csv 
Georges Kunstler's avatar
Georges Kunstler committed
155
	Rscript $< ; rm -f $(D5)/Done.txt
156
157

$(D2)/Paracou/tree.csv: R/format.data/Paracou.R $(shell find $(D1)/Paracou -type f)
Georges Kunstler's avatar
Georges Kunstler committed
158
	Rscript $< ; rm -f $(D4)/Done.txt
159

160
161
162
163
#-------------------------------------------------------

Spain: $(D3)/Spain/Done.txt

Georges Kunstler's avatar
Georges Kunstler committed
164
$(D3)/Spain/Done.txt: R/process.data/process-fun.R $(D2)/Spain/traits.csv 
Georges Kunstler's avatar
Georges Kunstler committed
165
	Rscript -e "source('$<');  process_inventory_dataset('Spain',std.traits='global');"
166

Georges Kunstler's avatar
Georges Kunstler committed
167
$(D2)/Spain/traits.csv: R/find.trait/Spain.R R/find.trait/trait-fun.R $(D2)/Spain/tree.csv $(D2)/TRY/data.TRY.std.rds
Georges Kunstler's avatar
Georges Kunstler committed
168
	Rscript $<  ; rm -f $(D5)/Done.txt
169
170

$(D2)/Spain/tree.csv: R/format.data/Spain.R $(shell find $(D1)/Spain -type f)
Georges Kunstler's avatar
Georges Kunstler committed
171
	Rscript $< ; rm -f $(D4)/Done.txt
172

173
174
175
176
#-------------------------------------------------------

Sweden: $(D3)/Sweden/Done.txt

Georges Kunstler's avatar
Georges Kunstler committed
177
$(D3)/Sweden/Done.txt: R/process.data/process-fun.R  $(D2)/Sweden/traits.csv 
Georges Kunstler's avatar
Georges Kunstler committed
178
	Rscript -e "source('$<'); process_inventory_dataset('Sweden',std.traits='global');"
179

Georges Kunstler's avatar
Georges Kunstler committed
180
$(D2)/Sweden/traits.csv: R/find.trait/Sweden.R R/find.trait/trait-fun.R $(D2)/Sweden/tree.csv $(D2)/TRY/data.TRY.std.rds
Georges Kunstler's avatar
Georges Kunstler committed
181
	Rscript $< ; rm -f $(D5)/Done.txt
182
183

$(D2)/Sweden/tree.csv: R/format.data/Sweden.R $(shell find $(D1)/Sweden -type f)
Georges Kunstler's avatar
Georges Kunstler committed
184
	Rscript $< ; rm -f $(D4)/Done.txt
185

186
187
188
#-------------------------------------------------------

Swiss: $(D3)/Swiss/Done.txt
189

Georges Kunstler's avatar
Georges Kunstler committed
190
$(D3)/Swiss/Done.txt: R/process.data/process-fun.R $(D2)/Swiss/traits.csv 
Georges Kunstler's avatar
Georges Kunstler committed
191
	Rscript -e "source('$<');  process_inventory_dataset('Swiss',std.traits='global');"
192

Georges Kunstler's avatar
Georges Kunstler committed
193
$(D2)/Swiss/traits.csv: R/find.trait/Swiss.R R/find.trait/trait-fun.R $(D2)/Swiss/tree.csv $(D2)/TRY/data.TRY.std.rds
Georges Kunstler's avatar
Georges Kunstler committed
194
	Rscript $< ; rm -f $(D5)/Done.txt
195
196

$(D2)/Swiss/tree.csv: R/format.data/Swiss.R $(shell find $(D1)/Swiss -type f)
Georges Kunstler's avatar
Georges Kunstler committed
197
	Rscript $< ; rm -f $(D4)/Done.txt
198

199
#-------------------------------------------------------
200

201
202
US: $(D3)/US/Done.txt

Georges Kunstler's avatar
Georges Kunstler committed
203
$(D3)/US/Done.txt: R/process.data/process-fun.R  $(D2)/US/traits.csv 
Georges Kunstler's avatar
Georges Kunstler committed
204
	Rscript -e "source('$<');  process_inventory_dataset('US',std.traits='global');"
205

Georges Kunstler's avatar
Georges Kunstler committed
206
207
$(D2)/US/traits.csv: R/find.trait/US.R R/find.trait/trait-fun.R $(D2)/US/tree.csv $(D2)/TRY/data.TRY.std.rds 
	Rscript $< ; rm -f $(D5)/Done.txt
208
209

$(D2)/US/tree.csv: R/format.data/US.R $(shell find $(D1)/US -type f) 
Georges Kunstler's avatar
Georges Kunstler committed
210
	Rscript $< ; rm -f $(D4)/Done.txt
211

212
#-------------------------------------------------------
213
TEST.TREE: $(D4)/Done.txt 
214

215
216
$(D4)/Done.txt:	R/format.data/test.tree.R $(D3tree) 
	Rscript $<
217
218

#-------------------------------------------------------
219
TEST.TRAITS: $(D5)/Done.txt 
220

Georges Kunstler's avatar
Georges Kunstler committed
221
$(D5)/Done.txt:	R/find.trait/test.traits.R $(D3traits)
222
	Rscript $<
223

224
#-------------------------------------------------------
225
TEST.CWM: $(D6)/Done.txt 
226

Georges Kunstler's avatar
Georges Kunstler committed
227
$(D6)/Done.txt:	R/process.data/test.tree.CWM.R  $(D3Done)
228
	Rscript $<
229

230
#-------------------------------------------------------
231

Georges Kunstler's avatar
Georges Kunstler committed
232
233
234
235
236
237
238
239
240
#-------------------------------------------------------
MERGE.ALL: output/processed/data.all.csv 

output/processed/data.all.csv:	R/process.data/merge.all.processed.data.R  
	Rscript $<

#-------------------------------------------------------


241
242
# This susbtitution rule should work as rule, but not, why not?
# docs/output/formatted/%/tree.csv: $(D1)/%/* %.R
243
# 	Rscript %.R   
244
245
246
247
248
249
250
251
252
253
254
255

# Is based on this which does work
# %-tree.csv: %/* %/*/* %.R
#         Rscript $*.R

# code to generate makefile contents
# s = dir("data/metadata/sites")
# cat((sprintf("%s: output/formatted/%s/traits.csv\n
# output/formatted/%s/traits.csv: output/formatted/%s/tree.csv R/find.trait/%s.R
# \tRscript R/find.trait/%s.R\n
# output/formatted/%s/tree.csv: $(shell find data/raw/%s -type f) %s.R
# \tRscript %s.R\n\n",s,s,s,s,s,s,s,s,s,s,s)), file="temp.txt")
Daniel Falster's avatar
Daniel Falster committed
256