Mercurial > repos > ecology > makeeml
changeset 1:9d56f6480194 draft
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/EMLassemblyline commit 5f7298d572c63d2c43f7dc0c4d9edcaecaa5ccb7
| author | ecology |
|---|---|
| date | Fri, 17 Nov 2023 17:07:36 +0000 |
| parents | 9cbac7a9b1a3 |
| children | 8a697f446051 |
| files | make_eml.R make_eml.xml |
| diffstat | 2 files changed, 226 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/make_eml.R Wed Sep 13 19:56:16 2023 +0000 +++ b/make_eml.R Fri Nov 17 17:07:36 2023 +0000 @@ -1,13 +1,161 @@ -##07/06/2023 -##Genthon Tanguy +##07/06/2023 ##Genthon Tanguy +##update 15/11/2023 ##Seguineau Pauline + ###make_eml args = commandArgs(trailingOnly=TRUE) if(length(args)>0){ title <- args[1] + start <- args[2] + end <-args[3] + data_table <- args[4] + data_other <- args[5] + destable <- args[6] + desother <- args[7] + quote <- args[8] + table_url <- args[9] + other_url <- args[10] +} + + +###Format data### + +if (data_table == ""){ + table=NULL +}else{ + table = strsplit(data_table," ") + for (file in table){ + name_table = gsub("\\.[a-zA-Z]*", "", file)} + } + + +if (quote != ""){ + quote = strsplit(quote,",") + if (length(quote[[1]]) != length(table[[1]])){ + 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")} +} + + +tablequote=NULL +for (quote_table in quote[[1]]){ + if (quote_table=="quote"){ + quote_table = sub("quote",'"', quote_table)} + else if (quote_table=="apostrophe"){ + quote_table = gsub("apostrophe","'",quote_table)} + else if (quote_table=="none"){ + quote_table = gsub("none","",quote_table)} + tablequote = c(tablequote, quote_table) +} + + +if (data_other == ""){ + other=NULL +}else{ + other = strsplit(data_other," ") + for (file in other){ + name_other = gsub("\\.[a-zA-Z]*", "", file)} + } + +if (data_table !=""){ + if (destable == ""){ + des_table = name_table + }else{ + des_table = strsplit(destable,",")} +} + + +if (data_other !=""){ + if (desother == ""){ + des_other = name_other + }else{ + des_other = strsplit(desother,",")} } -EMLassemblyline::make_eml("output_template",eml.path=".", dataset.title = title) + +if (data_table !=""){ + if (table_url == ""){ + urltable = "" + }else{ + table_url = gsub("\\-" ,"", table_url) + urltable = strsplit(table_url,",") + } +} + +if (data_other !=""){ + if (other_url == ""){ + urlother = "" + }else{ + other_url = gsub("\\-" ,"", other_url) + urlother = strsplit(other_url,",") + } +} + +###Make EML### + +if (!is.null(table) && !is.null(other)){ + + EMLassemblyline::make_eml( + path="output_template", + data.path="data_files", + eml.path=".", + dataset.title = title, + temporal.coverage = c(start,end), + data.table=table[[1]], + data.table.name = name_table, + data.table.description = des_table[[1]], + data.table.quote.character = tablequote, + data.table.url = urltable[[1]], + other.entity=other[[1]], + other.entity.name = name_other, + other.entity.description = des_other[[1]], + other.entity.url= urlother[[1]] + ) + +}else if (is.null(table) && is.null(other)){ + + EMLassemblyline::make_eml( + path="output_template", + data.path="data_files", + eml.path=".", + dataset.title = title, + temporal.coverage = c(start,end)) + +}else if (!is.null(table) && is.null(other)){ + + EMLassemblyline::make_eml( + path="output_template", + data.path="data_files", + eml.path=".", + dataset.title = title, + temporal.coverage = c(start,end), + data.table=table[[1]], + data.table.name = name_table, + data.table.description = des_table[[1]], + data.table.quote.character = tablequote, + data.table.url = urltable[[1]]) + + +}else if (is.null(table) && !is.null(other)){ + + EMLassemblyline::make_eml( + path="output_template", + data.path="data_files", + eml.path=".", + dataset.title = title, + temporal.coverage = c(start,end), + other.entity=other[[1]], + other.entity.name = name_other, + other.entity.description = des_other[[1]], + other.entity.url= urlother[[1]])} + + + old.names <- list.files(path=".", pattern=".xml") print(old.names) file.rename(from=old.names, to="eml.xml") + + + + + +
--- a/make_eml.xml Wed Sep 13 19:56:16 2023 +0000 +++ b/make_eml.xml Fri Nov 17 17:07:36 2023 +0000 @@ -5,17 +5,68 @@ <requirement type="package" version="3.5.5">r-emlassemblyline</requirement> </requirements> <command detect_errors="exit_code"><![CDATA[ + mkdir output_template && #for $input in $templates - ln -s '$input' 'output_template/${input.element_identifier}.txt'; + ln -s '$input' 'output_template/${input.element_identifier}'; + #end for + + #set $table = "" + mkdir data_files && + #for $indata in $inputdata + ln -s '$indata' 'data_files/${indata.element_identifier}'; + #set $table += $indata.element_identifier + " "; #end for + + #set $other = "" + #for $data_other in $dataother + ln -s '$data_other' 'data_files/${data_other.element_identifier}'; + #set $other += $data_other.element_identifier + " "; + #end for + + #set $quotetable ="" + #for $q in $table_quote + #set $quotetable += $q.quote + ","; + #end for + Rscript - '$__tool_directory__/make_eml.R' 2> err.txt - 'title' + '$__tool_directory__/make_eml.R' 2> err.txt + '$title' + '$temporal_coverage.start' + '$temporal_coverage.end' + '$table' + '$other' + '$destable' + '$desother' + '$quotetable' + '$table_url' + '$other_url' + ]]></command> <inputs> - <param name="templates" type="data_collection" collection_type="list" format="tabular" label="Upload all EAL templates" help= "Input a data collection." /> - <param name="title" type="text" label="Title for your dataset." /> + <param name="templates" type="data_collection" collection_type="list" format="tabular" label="Upload all EAL templates" help= "Input a data collection with only tabular files." /> + <section name="data_table" title="Do you have data table ? " > + <param name="inputdata" type="data_collection" collection_type="list" label="Upload all data files wich are data table" help= "Input a data collection." optional = "true"/> + <param name="destable" type="text" label="Give a short description of your data file. If there is multiple data files please separate your descriptions with a comma (,) in the same order of your data input" optional = "true"/> + <repeat name="table_quote" title="What's the quotes of your data table ? Repeat this parameter as many time as the number of data tables you've input and in the same order" > + <param name="quote" type="select" label="What's the quotes of your data table ?" optional="true"> + <option value="quote">Quote</option> + <option value="apostrophe">Apostrophe</option> + <option value="none">None</option> + </param> + </repeat> + <param name="table_url" type="text" label="Give the publicly accessible URL from which your data table can be downloaded. If more than one, data files please separate your URLs with a comma (,) in the same order of your data input. If wanting to include URLs for some but not all then use a - for those that don't have a URL." optional = "true"/> + </section> + <section name="data_other" title="Do you have other data entity ? " > + <param name="dataother" type="data_collection" collection_type="list" label="Upload all data files wich are other entity" help= "Input a data collection." optional = "true"/> + <param name="desother" type="text" label="Give a short description of your data file. If there are multiple data files please separate your descriptions with a comma (,) in the same order of your data input" optional = "true"/> + <param name="other_url" type="text" label="Give the publicly accessible URL from which your other data entity can be downloaded. If more than one, data files please separate your URLs with a comma (,) in the same order of your data input. If wanting to include URLs for some but not all then use a - for those that don't have a URL." optional = "true"/> + </section> + <param name="title" type="text" label="Title for your dataset." /> + <section name="temporal_coverage" title="Temporal coverage" > + <param name="start" type="text" label="Beginning date of the dataset in the format YYYY-MM-DD" /> + <param name="end" type="text" label="Ending date of the dataset in the format YYYY-MM-DD" /> + </section> </inputs> <outputs> <data name="metadataout" from_work_dir="eml.xml" format="xml" label="EML"/> @@ -25,12 +76,12 @@ <test expect_num_outputs="2"> <param name="templates"> <collection type="list"> - <element name="annotations" value="annotations.txt"/> - <element name="keywords" value="keywords.txt" /> - <element name="attributes_data_blary_al" value="attributes_data_blary_al.txt"/> - <element name="catvars_data_blary_al" value="catvars_data_blary_al.txt"/> - <element name="geographic_coverage" value="geographic_coverage.txt" /> - <element name="personnel" value="personnel.txt" /> + <element name="annotations.txt" value="annotations.txt"/> + <element name="keywords.txt" value="keywords.txt" /> + <element name="attributes_data_blary_al.txt" value="attributes_data_blary_al.txt"/> + <element name="catvars_data_blary_al.txt" value="catvars_data_blary_al.txt"/> + <element name="geographic_coverage.txt" value="geographic_coverage.txt" /> + <element name="personnel.txt" value="personnel.txt" /> </collection> </param> <output name="metadataout" > @@ -44,7 +95,7 @@ <help><