comparison make_eml.R @ 0:330f15f2ad3f 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:40:29 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:330f15f2ad3f
1 ##07/06/2023 ##Genthon Tanguy
2 ##update 15/11/2023 ## Seguineau Pauline
3
4 ###make_eml
5
6 args = commandArgs(trailingOnly=TRUE)
7 if(length(args)>0){
8 title <- args[1]
9 start <- args[2]
10 end <-args[3]
11 data_table <- args[4]
12 data_raster <- args[5]
13 data_vector <- args[6]
14 data_other <- args[7]
15 destable <- args[8]
16 desraster<- args[9]
17 desvector<- args[10]
18 desother <- args[11]
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
31
32 ###Format data###
33 if (data_table == ""){
34 table=NULL
35 }else{
36 table = strsplit(data_table," ")
37 for (file in table){
38 name_table = gsub("\\.[a-zA-Z]*", "", file)}
39 }
40
41
42 if (quote != ""){
43 quote = strsplit(quote,",")
44 if (length(quote[[1]]) != length(table[[1]])){
45 stop("Your number of quote(s) isn't equal to your number of data table file(s). Please enter the quote parameter as many time as the number of data tables you've input")}
46 }
47
48
49 tablequote=NULL
50 for (quote_table in quote[[1]]){
51 if (quote_table=="quote"){
52 quote_table = sub("quote",'"', quote_table)}
53 else if (quote_table=="apostrophe"){
54 quote_table = gsub("apostrophe","'",quote_table)}
55 else if (quote_table=="none"){
56 quote_table = gsub("none","",quote_table)}
57 tablequote = c(tablequote, quote_table)
58 }
59
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
77 if (data_other == ""){
78 other=NULL
79 }else{
80 other = strsplit(data_other," ")
81 for (file in other){
82 name_other = gsub("\\.[a-zA-Z]*", "", file)}
83 }
84
85 if (data_table !=""){
86 if (destable == ""){
87 des_table = name_table
88 }else{
89 des_table = strsplit(destable,",")}
90 }
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 }
105
106 if (data_other !=""){
107 if (desother == ""){
108 des_other = name_other
109 }else{
110 des_other = strsplit(desother,",")}
111 }
112
113 if (data_table !=""){
114 if (table_url == ""){
115 urltable = ""
116 }else{
117 table_url = gsub("\\-" ,"", table_url)
118 urltable = strsplit(table_url,",")
119 }
120 }
121
122 if (data_other !=""){
123 if (other_url == ""){
124 urlother = ""
125 }else{
126 other_url = gsub("\\-" ,"", other_url)
127 urlother = strsplit(other_url,",")
128 }
129 }
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
151 ###Make EML###
152
153 if (!is.null(table) && !is.null(raster) && !is.null(vector) && !is.null(other)){
154
155 EMLassemblyline::make_eml(
156 path="output_template",
157 data.path="data_files",
158 eml.path=".",
159 dataset.title = title,
160 temporal.coverage = c(start,end),
161 data.table=table[[1]],
162 data.table.name = name_table,
163 data.table.description = des_table[[1]],
164 data.table.quote.character = tablequote,
165 data.table.url = urltable[[1]],
166 spatial.raster=raster[[1]],
167 spatial.raster.name = name_raster,
168 spatial.raster.description = des_raster[[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]]
201 )
202
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)){
222
223 EMLassemblyline::make_eml(
224 path="output_template",
225 data.path="data_files",
226 eml.path=".",
227 dataset.title = title,
228 temporal.coverage = c(start,end),
229 data.table=table[[1]],
230 data.table.name = name_table,
231 data.table.description = des_table[[1]],
232 data.table.quote.character = tablequote,
233 data.table.url = urltable[[1]],
234 spatial.raster=raster[[1]],
235 spatial.raster.name = name_raster,
236 spatial.raster.description = des_raster[[1]],
237 spatial.raster.url = urlraster[[1]],
238 spatial.vector=vector[[1]],
239 spatial.vector.name = name_vector,
240 spatial.vector.description = des_vector[[1]],
241 spatial.vector.url = urlvector[[1]])
242
243 }else if (is.null(table) && !is.null(raster) && is.null(vector) && is.null(other)){
244
245 EMLassemblyline::make_eml(
246 path="output_template",
247 data.path="data_files",
248 eml.path=".",
249 dataset.title = title,
250 temporal.coverage = c(start,end),
251 spatial.raster=raster[[1]],
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]],
429 other.entity=other[[1]],
430 other.entity.name = name_other,
431 other.entity.description = des_other[[1]],
432 other.entity.url= urlother[[1]])}
433
434 issues()
435 old.names <- list.files(path=".", pattern=".xml")
436 file.rename(from=old.names, to="eml.xml")
437
438
439
440
441
442