Mercurial > repos > ecology > eal_templates
comparison make_eml.R @ 1:3b0fa963ae3e draft
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/EMLassemblyline commit f00c48e2a16ba6154e6c1aa50330586eefb13a32
author | ecology |
---|---|
date | Sat, 23 Dec 2023 20:41:26 +0000 |
parents | d4f168043757 |
children |
comparison
equal
deleted
inserted
replaced
0:d4f168043757 | 1:3b0fa963ae3e |
---|---|
1 ##07/06/2023 ##Genthon Tanguy | 1 ##07/06/2023 ##Genthon Tanguy |
2 ##update 15/11/2023 ##Seguineau Pauline | 2 ##update 15/11/2023 ## Seguineau Pauline |
3 | 3 |
4 ###make_eml | 4 ###make_eml |
5 | 5 |
6 args = commandArgs(trailingOnly=TRUE) | 6 args = commandArgs(trailingOnly=TRUE) |
7 if(length(args)>0){ | 7 if(length(args)>0){ |
8 title <- args[1] | 8 title <- args[1] |
9 start <- args[2] | 9 start <- args[2] |
10 end <-args[3] | 10 end <-args[3] |
11 data_table <- args[4] | 11 data_table <- args[4] |
12 data_other <- args[5] | 12 data_raster <- args[5] |
13 destable <- args[6] | 13 data_vector <- args[6] |
14 desother <- args[7] | 14 data_other <- args[7] |
15 quote <- args[8] | 15 destable <- args[8] |
16 table_url <- args[9] | 16 desraster<- args[9] |
17 other_url <- args[10] | 17 desvector<- args[10] |
18 } | 18 desother <- args[11] |
19 | 19 quote <- args[12] |
20 table_url <- args[13] | |
21 other_url <- args[14] | |
22 raster_url <- args[15] | |
23 vector_url <- args[16] | |
24 } | |
25 | |
26 #Load package | |
27 | |
28 library(EMLassemblyline) | |
29 sessionInfo() | |
30 | |
20 | 31 |
21 ###Format data### | 32 ###Format data### |
22 | |
23 if (data_table == ""){ | 33 if (data_table == ""){ |
24 table=NULL | 34 table=NULL |
25 }else{ | 35 }else{ |
26 table = strsplit(data_table," ") | 36 table = strsplit(data_table," ") |
27 for (file in table){ | 37 for (file in table){ |
46 quote_table = gsub("none","",quote_table)} | 56 quote_table = gsub("none","",quote_table)} |
47 tablequote = c(tablequote, quote_table) | 57 tablequote = c(tablequote, quote_table) |
48 } | 58 } |
49 | 59 |
50 | 60 |
61 if (data_raster == ""){ | |
62 raster=NULL | |
63 }else{ | |
64 raster = strsplit(data_raster," ") | |
65 for (file in raster){ | |
66 name_raster = gsub("\\.[a-zA-Z]*", "", file)} | |
67 } | |
68 | |
69 if (data_vector == ""){ | |
70 vector=NULL | |
71 }else{ | |
72 vector = strsplit(data_vector," ") | |
73 for (file in vector){ | |
74 name_vector = gsub("\\.[a-zA-Z]*", "", file)} | |
75 } | |
76 | |
51 if (data_other == ""){ | 77 if (data_other == ""){ |
52 other=NULL | 78 other=NULL |
53 }else{ | 79 }else{ |
54 other = strsplit(data_other," ") | 80 other = strsplit(data_other," ") |
55 for (file in other){ | 81 for (file in other){ |
61 des_table = name_table | 87 des_table = name_table |
62 }else{ | 88 }else{ |
63 des_table = strsplit(destable,",")} | 89 des_table = strsplit(destable,",")} |
64 } | 90 } |
65 | 91 |
92 if (data_raster !=""){ | |
93 if (desraster == ""){ | |
94 des_raster = name_raster | |
95 }else{ | |
96 des_raster = strsplit(desraster,",")} | |
97 } | |
98 | |
99 if (data_vector !=""){ | |
100 if (desvector == ""){ | |
101 des_vector = name_vector | |
102 }else{ | |
103 des_vector = strsplit(desvector,",")} | |
104 } | |
66 | 105 |
67 if (data_other !=""){ | 106 if (data_other !=""){ |
68 if (desother == ""){ | 107 if (desother == ""){ |
69 des_other = name_other | 108 des_other = name_other |
70 }else{ | 109 }else{ |
71 des_other = strsplit(desother,",")} | 110 des_other = strsplit(desother,",")} |
72 } | 111 } |
73 | 112 |
74 | |
75 if (data_table !=""){ | 113 if (data_table !=""){ |
76 if (table_url == ""){ | 114 if (table_url == ""){ |
77 urltable = "" | 115 urltable = "" |
78 }else{ | 116 }else{ |
79 table_url = gsub("\\-" ,"", table_url) | 117 table_url = gsub("\\-" ,"", table_url) |
88 other_url = gsub("\\-" ,"", other_url) | 126 other_url = gsub("\\-" ,"", other_url) |
89 urlother = strsplit(other_url,",") | 127 urlother = strsplit(other_url,",") |
90 } | 128 } |
91 } | 129 } |
92 | 130 |
131 if (data_raster !=""){ | |
132 if (raster_url == ""){ | |
133 urlraster = "" | |
134 }else{ | |
135 raster_url = gsub("\\-" ,"", raster_url) | |
136 urlraster = strsplit(raster_url,",") | |
137 } | |
138 } | |
139 | |
140 if (data_vector !=""){ | |
141 if (vector_url == ""){ | |
142 urlvector = "" | |
143 }else{ | |
144 vector_url = gsub("\\-" ,"", vector_url) | |
145 urlvector = strsplit(vector_url,",") | |
146 } | |
147 } | |
148 | |
149 | |
150 | |
93 ###Make EML### | 151 ###Make EML### |
94 | 152 |
95 if (!is.null(table) && !is.null(other)){ | 153 if (!is.null(table) && !is.null(raster) && !is.null(vector) && !is.null(other)){ |
96 | 154 |
97 EMLassemblyline::make_eml( | 155 EMLassemblyline::make_eml( |
98 path="output_template", | 156 path="output_template", |
99 data.path="data_files", | 157 data.path="data_files", |
100 eml.path=".", | 158 eml.path=".", |
101 dataset.title = title, | 159 dataset.title = title, |
102 temporal.coverage = c(start,end), | 160 temporal.coverage = c(start,end), |
103 data.table=table[[1]], | 161 data.table=table[[1]], |
104 data.table.name = name_table, | 162 data.table.name = name_table, |
105 data.table.description = des_table[[1]], | 163 data.table.description = des_table[[1]], |
106 data.table.quote.character = tablequote, | 164 data.table.quote.character = tablequote, |
107 data.table.url = urltable[[1]], | 165 data.table.url = urltable[[1]], |
108 other.entity=other[[1]], | 166 spatial.raster=raster[[1]], |
109 other.entity.name = name_other, | 167 spatial.raster.name = name_raster, |
110 other.entity.description = des_other[[1]], | 168 spatial.raster.description = des_raster[[1]], |
111 other.entity.url= urlother[[1]] | 169 spatial.raster.url = urlraster[[1]], |
170 spatial.vector=vector[[1]], | |
171 spatial.vector.name = name_vector, | |
172 spatial.vector.description = des_vector[[1]], | |
173 spatial.vector.url = urlvector[[1]], | |
174 other.entity=other[[1]], | |
175 other.entity.name = name_other, | |
176 other.entity.description = des_other[[1]], | |
177 other.entity.url= urlother[[1]]) | |
178 | |
179 }else if (is.null(table) && is.null(raster) && is.null(vector) && is.null(other)){ | |
180 | |
181 EMLassemblyline::make_eml( | |
182 path="output_template", | |
183 data.path="data_files", | |
184 eml.path=".", | |
185 dataset.title = title, | |
186 temporal.coverage = c(start,end)) | |
187 | |
188 }else if (!is.null(table) && is.null(raster) && is.null(vector) && is.null(other)){ | |
189 | |
190 EMLassemblyline::make_eml( | |
191 path="output_template", | |
192 data.path="data_files", | |
193 eml.path=".", | |
194 dataset.title = title, | |
195 temporal.coverage = c(start,end), | |
196 data.table=table[[1]], | |
197 data.table.name = name_table, | |
198 data.table.description = des_table[[1]], | |
199 data.table.quote.character = tablequote, | |
200 data.table.url = urltable[[1]] | |
112 ) | 201 ) |
113 | 202 |
114 }else if (is.null(table) && is.null(other)){ | 203 }else if (!is.null(table) && !is.null(raster) && is.null(vector) && is.null(other)){ |
204 | |
205 EMLassemblyline::make_eml( | |
206 path="output_template", | |
207 data.path="data_files", | |
208 eml.path=".", | |
209 dataset.title = title, | |
210 temporal.coverage = c(start,end), | |
211 data.table=table[[1]], | |
212 data.table.name = name_table, | |
213 data.table.description = des_table[[1]], | |
214 data.table.quote.character = tablequote, | |
215 data.table.url = urltable[[1]], | |
216 spatial.raster=raster[[1]], | |
217 spatial.raster.name = name_raster, | |
218 spatial.raster.description = des_raster[[1]], | |
219 spatial.raster.url = urlraster[[1]]) | |
220 | |
221 }else if (!is.null(table) && !is.null(raster) && !is.null(vector) && is.null(other)){ | |
115 | 222 |
116 EMLassemblyline::make_eml( | 223 EMLassemblyline::make_eml( |
117 path="output_template", | 224 path="output_template", |
118 data.path="data_files", | 225 data.path="data_files", |
119 eml.path=".", | 226 eml.path=".", |
120 dataset.title = title, | 227 dataset.title = title, |
121 temporal.coverage = c(start,end)) | 228 temporal.coverage = c(start,end), |
122 | 229 data.table=table[[1]], |
123 }else if (!is.null(table) && is.null(other)){ | 230 data.table.name = name_table, |
124 | 231 data.table.description = des_table[[1]], |
125 EMLassemblyline::make_eml( | 232 data.table.quote.character = tablequote, |
126 path="output_template", | 233 data.table.url = urltable[[1]], |
127 data.path="data_files", | 234 spatial.raster=raster[[1]], |
128 eml.path=".", | 235 spatial.raster.name = name_raster, |
129 dataset.title = title, | 236 spatial.raster.description = des_raster[[1]], |
130 temporal.coverage = c(start,end), | 237 spatial.raster.url = urlraster[[1]], |
131 data.table=table[[1]], | 238 spatial.vector=vector[[1]], |
132 data.table.name = name_table, | 239 spatial.vector.name = name_vector, |
133 data.table.description = des_table[[1]], | 240 spatial.vector.description = des_vector[[1]], |
134 data.table.quote.character = tablequote, | 241 spatial.vector.url = urlvector[[1]]) |
135 data.table.url = urltable[[1]]) | 242 |
136 | 243 }else if (is.null(table) && !is.null(raster) && is.null(vector) && is.null(other)){ |
137 | 244 |
138 }else if (is.null(table) && !is.null(other)){ | 245 EMLassemblyline::make_eml( |
139 | 246 path="output_template", |
140 EMLassemblyline::make_eml( | 247 data.path="data_files", |
141 path="output_template", | 248 eml.path=".", |
142 data.path="data_files", | 249 dataset.title = title, |
143 eml.path=".", | 250 temporal.coverage = c(start,end), |
144 dataset.title = title, | 251 spatial.raster=raster[[1]], |
145 temporal.coverage = c(start,end), | 252 spatial.raster.name = name_raster, |
253 spatial.raster.description = des_raster[[1]], | |
254 spatial.raster.url = urlraster[[1]]) | |
255 | |
256 }else if (is.null(table) && !is.null(raster) && !is.null(vector) && is.null(other)){ | |
257 | |
258 EMLassemblyline::make_eml( | |
259 path="output_template", | |
260 data.path="data_files", | |
261 eml.path=".", | |
262 dataset.title = title, | |
263 temporal.coverage = c(start,end), | |
264 spatial.raster=raster[[1]], | |
265 spatial.raster.name = name_raster, | |
266 spatial.raster.description = des_raster[[1]], | |
267 spatial.raster.url = urlraster[[1]], | |
268 spatial.vector=vector[[1]], | |
269 spatial.vector.name = name_vector, | |
270 spatial.vector.description = des_vector[[1]], | |
271 spatial.vector.url = urlvector[[1]]) | |
272 | |
273 }else if (is.null(table) && !is.null(raster) && !is.null(vector) && !is.null(other)){ | |
274 | |
275 EMLassemblyline::make_eml( | |
276 path="output_template", | |
277 data.path="data_files", | |
278 eml.path=".", | |
279 dataset.title = title, | |
280 temporal.coverage = c(start,end), | |
281 spatial.raster=raster[[1]], | |
282 spatial.raster.name = name_raster, | |
283 spatial.raster.description = des_raster[[1]], | |
284 spatial.raster.url = urlraster[[1]], | |
285 spatial.vector=vector[[1]], | |
286 spatial.vector.name = name_vector, | |
287 spatial.vector.description = des_vector[[1]], | |
288 spatial.vector.url = urlvector[[1]], | |
289 other.entity=other[[1]], | |
290 other.entity.name = name_other, | |
291 other.entity.description = des_other[[1]], | |
292 other.entity.url= urlother[[1]]) | |
293 | |
294 }else if (is.null(table) && is.null(raster) && !is.null(vector) && is.null(other)){ | |
295 | |
296 EMLassemblyline::make_eml( | |
297 path="output_template", | |
298 data.path="data_files", | |
299 eml.path=".", | |
300 dataset.title = title, | |
301 temporal.coverage = c(start,end), | |
302 spatial.vector=vector[[1]], | |
303 spatial.vector.name = name_vector, | |
304 spatial.vector.description = des_vector[[1]], | |
305 spatial.vector.url = urlvector[[1]]) | |
306 | |
307 }else if (is.null(table) && is.null(raster) && !is.null(vector) && !is.null(other)){ | |
308 | |
309 EMLassemblyline::make_eml( | |
310 path="output_template", | |
311 data.path="data_files", | |
312 eml.path=".", | |
313 dataset.title = title, | |
314 temporal.coverage = c(start,end), | |
315 spatial.vector=vector[[1]], | |
316 spatial.vector.name = name_vector, | |
317 spatial.vector.description = des_vector[[1]], | |
318 spatial.vector.url = urlvector[[1]], | |
319 other.entity=other[[1]], | |
320 other.entity.name = name_other, | |
321 other.entity.description = des_other[[1]], | |
322 other.entity.url= urlother[[1]]) | |
323 | |
324 }else if (is.null(table) && is.null(raster) && is.null(vector) && !is.null(other)){ | |
325 | |
326 EMLassemblyline::make_eml( | |
327 path="output_template", | |
328 data.path="data_files", | |
329 eml.path=".", | |
330 dataset.title = title, | |
331 temporal.coverage = c(start,end), | |
332 other.entity=other[[1]], | |
333 other.entity.name = name_other, | |
334 other.entity.description = des_other[[1]], | |
335 other.entity.url= urlother[[1]]) | |
336 | |
337 }else if (!is.null(table) && is.null(raster) && !is.null(vector) && is.null(other)){ | |
338 | |
339 EMLassemblyline::make_eml( | |
340 path="output_template", | |
341 data.path="data_files", | |
342 eml.path=".", | |
343 dataset.title = title, | |
344 temporal.coverage = c(start,end), | |
345 data.table=table[[1]], | |
346 data.table.name = name_table, | |
347 data.table.description = des_table[[1]], | |
348 data.table.quote.character = tablequote, | |
349 data.table.url = urltable[[1]], | |
350 spatial.vector=vector[[1]], | |
351 spatial.vector.name = name_vector, | |
352 spatial.vector.description = des_vector[[1]], | |
353 spatial.vector.url = urlvector[[1]]) | |
354 | |
355 }else if (!is.null(table) && is.null(raster) && is.null(vector) && !is.null(other)){ | |
356 | |
357 EMLassemblyline::make_eml( | |
358 path="output_template", | |
359 data.path="data_files", | |
360 eml.path=".", | |
361 dataset.title = title, | |
362 temporal.coverage = c(start,end), | |
363 data.table=table[[1]], | |
364 data.table.name = name_table, | |
365 data.table.description = des_table[[1]], | |
366 data.table.quote.character = tablequote, | |
367 data.table.url = urltable[[1]], | |
368 other.entity=other[[1]], | |
369 other.entity.name = name_other, | |
370 other.entity.description = des_other[[1]], | |
371 other.entity.url= urlother[[1]]) | |
372 | |
373 }else if (is.null(table) && !is.null(raster) && is.null(vector) && !is.null(other)){ | |
374 | |
375 EMLassemblyline::make_eml( | |
376 path="output_template", | |
377 data.path="data_files", | |
378 eml.path=".", | |
379 dataset.title = title, | |
380 temporal.coverage = c(start,end), | |
381 spatial.raster=raster[[1]], | |
382 spatial.raster.name = name_raster, | |
383 spatial.raster.description = des_raster[[1]], | |
384 spatial.raster.url = urlraster[[1]], | |
385 other.entity=other[[1]], | |
386 other.entity.name = name_other, | |
387 other.entity.description = des_other[[1]], | |
388 other.entity.url= urlother[[1]]) | |
389 | |
390 }else if (!is.null(table) && is.null(raster) && !is.null(vector) && !is.null(other)){ | |
391 | |
392 EMLassemblyline::make_eml( | |
393 path="output_template", | |
394 data.path="data_files", | |
395 eml.path=".", | |
396 dataset.title = title, | |
397 temporal.coverage = c(start,end), | |
398 data.table=table[[1]], | |
399 data.table.name = name_table, | |
400 data.table.description = des_table[[1]], | |
401 data.table.quote.character = tablequote, | |
402 data.table.url = urltable[[1]], | |
403 spatial.vector=vector[[1]], | |
404 spatial.vector.name = name_vector, | |
405 spatial.vector.description = des_vector[[1]], | |
406 spatial.vector.url = urlvector[[1]], | |
407 other.entity=other[[1]], | |
408 other.entity.name = name_other, | |
409 other.entity.description = des_other[[1]], | |
410 other.entity.url= urlother[[1]]) | |
411 | |
412 }else if (!is.null(table) && !is.null(raster) && is.null(vector) && !is.null(other)){ | |
413 | |
414 EMLassemblyline::make_eml( | |
415 path="output_template", | |
416 data.path="data_files", | |
417 eml.path=".", | |
418 dataset.title = title, | |
419 temporal.coverage = c(start,end), | |
420 data.table=table[[1]], | |
421 data.table.name = name_table, | |
422 data.table.description = des_table[[1]], | |
423 data.table.quote.character = tablequote, | |
424 data.table.url = urltable[[1]], | |
425 spatial.raster=raster[[1]], | |
426 spatial.raster.name = name_raster, | |
427 spatial.raster.description = des_raster[[1]], | |
428 spatial.raster.url = urlraster[[1]], | |
146 other.entity=other[[1]], | 429 other.entity=other[[1]], |
147 other.entity.name = name_other, | 430 other.entity.name = name_other, |
148 other.entity.description = des_other[[1]], | 431 other.entity.description = des_other[[1]], |
149 other.entity.url= urlother[[1]])} | 432 other.entity.url= urlother[[1]])} |
150 | 433 |
151 | 434 issues() |
152 | |
153 old.names <- list.files(path=".", pattern=".xml") | 435 old.names <- list.files(path=".", pattern=".xml") |
154 print(old.names) | |
155 file.rename(from=old.names, to="eml.xml") | 436 file.rename(from=old.names, to="eml.xml") |
156 | 437 |
157 | 438 |
158 | 439 |
159 | 440 |