comparison make_eml.R @ 0:d4f168043757 draft

planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/EMLassemblyline commit 5c327a780dc58fb954e7b65db6fd413ee3909c84
author ecology
date Mon, 04 Dec 2023 21:48:55 +0000
parents
children 3b0fa963ae3e
comparison
equal deleted inserted replaced
-1:000000000000 0:d4f168043757
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_other <- args[5]
13 destable <- args[6]
14 desother <- args[7]
15 quote <- args[8]
16 table_url <- args[9]
17 other_url <- args[10]
18 }
19
20
21 ###Format data###
22
23 if (data_table == ""){
24 table=NULL
25 }else{
26 table = strsplit(data_table," ")
27 for (file in table){
28 name_table = gsub("\\.[a-zA-Z]*", "", file)}
29 }
30
31
32 if (quote != ""){
33 quote = strsplit(quote,",")
34 if (length(quote[[1]]) != length(table[[1]])){
35 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")}
36 }
37
38
39 tablequote=NULL
40 for (quote_table in quote[[1]]){
41 if (quote_table=="quote"){
42 quote_table = sub("quote",'"', quote_table)}
43 else if (quote_table=="apostrophe"){
44 quote_table = gsub("apostrophe","'",quote_table)}
45 else if (quote_table=="none"){
46 quote_table = gsub("none","",quote_table)}
47 tablequote = c(tablequote, quote_table)
48 }
49
50
51 if (data_other == ""){
52 other=NULL
53 }else{
54 other = strsplit(data_other," ")
55 for (file in other){
56 name_other = gsub("\\.[a-zA-Z]*", "", file)}
57 }
58
59 if (data_table !=""){
60 if (destable == ""){
61 des_table = name_table
62 }else{
63 des_table = strsplit(destable,",")}
64 }
65
66
67 if (data_other !=""){
68 if (desother == ""){
69 des_other = name_other
70 }else{
71 des_other = strsplit(desother,",")}
72 }
73
74
75 if (data_table !=""){
76 if (table_url == ""){
77 urltable = ""
78 }else{
79 table_url = gsub("\\-" ,"", table_url)
80 urltable = strsplit(table_url,",")
81 }
82 }
83
84 if (data_other !=""){
85 if (other_url == ""){
86 urlother = ""
87 }else{
88 other_url = gsub("\\-" ,"", other_url)
89 urlother = strsplit(other_url,",")
90 }
91 }
92
93 ###Make EML###
94
95 if (!is.null(table) && !is.null(other)){
96
97 EMLassemblyline::make_eml(
98 path="output_template",
99 data.path="data_files",
100 eml.path=".",
101 dataset.title = title,
102 temporal.coverage = c(start,end),
103 data.table=table[[1]],
104 data.table.name = name_table,
105 data.table.description = des_table[[1]],
106 data.table.quote.character = tablequote,
107 data.table.url = urltable[[1]],
108 other.entity=other[[1]],
109 other.entity.name = name_other,
110 other.entity.description = des_other[[1]],
111 other.entity.url= urlother[[1]]
112 )
113
114 }else if (is.null(table) && is.null(other)){
115
116 EMLassemblyline::make_eml(
117 path="output_template",
118 data.path="data_files",
119 eml.path=".",
120 dataset.title = title,
121 temporal.coverage = c(start,end))
122
123 }else if (!is.null(table) && is.null(other)){
124
125 EMLassemblyline::make_eml(
126 path="output_template",
127 data.path="data_files",
128 eml.path=".",
129 dataset.title = title,
130 temporal.coverage = c(start,end),
131 data.table=table[[1]],
132 data.table.name = name_table,
133 data.table.description = des_table[[1]],
134 data.table.quote.character = tablequote,
135 data.table.url = urltable[[1]])
136
137
138 }else if (is.null(table) && !is.null(other)){
139
140 EMLassemblyline::make_eml(
141 path="output_template",
142 data.path="data_files",
143 eml.path=".",
144 dataset.title = title,
145 temporal.coverage = c(start,end),
146 other.entity=other[[1]],
147 other.entity.name = name_other,
148 other.entity.description = des_other[[1]],
149 other.entity.url= urlother[[1]])}
150
151
152
153 old.names <- list.files(path=".", pattern=".xml")
154 print(old.names)
155 file.rename(from=old.names, to="eml.xml")
156
157
158
159
160
161