changeset 2:391394c022b8 draft

planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
author mingchen0919
date Sat, 31 Mar 2018 21:32:17 -0400
parents 16e0f4b7a286
children 5838300fc1aa
files elastic_expose_to_list_collection.xml elastic_expose_to_list_paired_collection.xml elastic_expose_to_paired_collection.xml elastic_tool_wrappers_macros.xml list.Rmd list_paired.Rmd list_paired_render.R list_render.R paired.Rmd paired_render.R
diffstat 10 files changed, 283 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/elastic_expose_to_list_collection.xml	Mon Mar 26 18:40:39 2018 -0400
+++ b/elastic_expose_to_list_collection.xml	Sat Mar 31 21:32:17 2018 -0400
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<tool id="elastic_expose_to_list_collection" name="expose to a list" version="1.0.0">
+<tool id="elastic_expose_to_list_collection" name="expose data (list)" version="1.0.0">
   <macros>
     <import>elastic_tool_wrappers_macros.xml</import>
   </macros>
@@ -8,9 +8,57 @@
     <expand macro="rmarkdown_requirements"/>
   </requirements>
   <expand macro="stdio"/>
-  <expand macro="shell_command"/>
+  <command><![CDATA[
+
+        ############ first, create a directory to store all files
+        mkdir -p $report.files_path &&
+
+
+        ############ save the tool installation directory to an environment variable
+        export TOOL_INSTALL_DIR='${__tool_directory__}' &&
+
+
+        #########################
+        ##
+        ## save user input option/argument pairs into a file
+        ##
+        #########################
+
+        ## first line will be the header
+        echo 'tool_output_dir|relative_path' > '$report.files_path/options_and_arguments.txt' &&
+
+
+
+        ####################################################
+        ## loop through repeats to get option/argument pairs
+        ####################################################
+
+
+        ############ option_argument_path_relative_to_a_tool
+        #for i in $option_argument_path_relative_to_a_tool_repeat:
+             #set $item = str($i.a_tool_output_dir) + "|" + str($i.value)
+             echo '$item' >> '$report.files_path/options_and_arguments.txt' &&
+        #end for
+
+
+        ############ output_set
+        ## '$report'
+        ## '$report.files_path'
+        #######################
+        export REPORT='$report' &&
+        export TOOL_LOG='$tool_log' &&
+        export REPORT_FILES_PATH='$report.files_path' &&
+
+
+        ############ run render R script to render R markdowns
+        Rscript '${__tool_directory__}/list_render.R'
+
+        ]]></command>
   <inputs>
-    <expand macro="option_argument_path_relative_to_a_tool"/>
+    <repeat name="option_argument_path_relative_to_a_tool_repeat" title="INPUT DATA PATH: relative to a tool output directory" min="0" default="0">
+      <param name="a_tool_output_dir" type="data" optional="false" multiple="false" label="a tool output directory"/>
+      <param type="text" name="value" optional="true" label="relative path"/>
+    </repeat>
   </inputs>
   <outputs>
     <data format="html" name="report" label="${tool.name} report"/>
--- a/elastic_expose_to_list_paired_collection.xml	Mon Mar 26 18:40:39 2018 -0400
+++ b/elastic_expose_to_list_paired_collection.xml	Sat Mar 31 21:32:17 2018 -0400
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<tool id="elastic_expose_to_paired_collection" name="elastic_expose_to_paired_collection" version="1.0.0">
+<tool id="elastic_expose_to_paired_collection" name="expose data (list:paired)" version="1.0.0">
   <macros>
     <import>elastic_tool_wrappers_macros.xml</import>
   </macros>
@@ -8,16 +8,63 @@
     <expand macro="rmarkdown_requirements"/>
   </requirements>
   <expand macro="stdio"/>
-  <expand macro="shell_command"/>
+  <command><![CDATA[
+
+        ############ first, create a directory to store all files
+        mkdir -p $report.files_path &&
+
+
+        ############ save the tool installation directory to an environment variable
+        export TOOL_INSTALL_DIR='${__tool_directory__}' &&
+
+
+        #########################
+        ##
+        ## save user input option/argument pairs into a file
+        ##
+        #########################
+
+        ## first line will be the header
+        echo 'tool_output_dir|relative_path' > '$report.files_path/options_and_arguments.txt' &&
+
+
+
+        ####################################################
+        ## loop through repeats to get option/argument pairs
+        ####################################################
+
+
+        ############ option_argument_path_relative_to_a_tool
+        #for i in $option_argument_path_relative_to_a_tool_repeat:
+             #set $item = str($i.a_tool_output_dir) + "|" + str($i.value)
+             echo '$item' >> '$report.files_path/options_and_arguments.txt' &&
+        #end for
+
+
+        ############ output_set
+        ## '$report'
+        ## '$report.files_path'
+        #######################
+        export REPORT='$report' &&
+        export TOOL_LOG='$tool_log' &&
+        export REPORT_FILES_PATH='$report.files_path' &&
+
+
+        ############ run render R script to render R markdowns
+        Rscript '${__tool_directory__}/list_paired_render.R'
+
+        ]]></command>
   <inputs>
-    <expand macro="option_argument_path_relative_to_a_tool"/>
+    <repeat name="option_argument_path_relative_to_a_tool_repeat" title="INPUT DATA PATH: relative to a tool output directory" min="0" default="0">
+      <param name="a_tool_output_dir" type="data" optional="false" multiple="false" label="a tool output directory"/>
+      <param type="text" name="value" optional="true" label="relative path"/>
+    </repeat>
   </inputs>
   <outputs>
     <data format="html" name="report" label="${tool.name} report"/>
     <data format="txt" name="tool_log" label="${tool.name} log"/>
-    <collection type="list:paired" name="list_collection">
-      <discover_datasets pattern="(?P&lt;identifier_0&gt;[^_]+)_(?P&lt;identifier_1&gt;[^_]+)\.(?P&lt;ext&gt;[^\._]+)?"
-                         directory="list_paired"/>
+    <collection type="list:paired" name="list_paired_collection">
+      <discover_datasets pattern="(?P&lt;identifier_0&gt;[^_]+)_(?P&lt;identifier_1&gt;[^_]+)\.(?P&lt;ext&gt;[^\._]+)?" directory="list_paired"/>
     </collection>
   </outputs>
   <citations>
--- a/elastic_expose_to_paired_collection.xml	Mon Mar 26 18:40:39 2018 -0400
+++ b/elastic_expose_to_paired_collection.xml	Sat Mar 31 21:32:17 2018 -0400
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<tool id="elastic_expose_list_paired_collection" name="elastic_expose_list_paired_collection" version="1.0.0">
+<tool id="elastic_expose_list_paired_collection" name="expose data (paired)" version="1.0.0">
   <macros>
     <import>elastic_tool_wrappers_macros.xml</import>
   </macros>
@@ -8,15 +8,63 @@
     <expand macro="rmarkdown_requirements"/>
   </requirements>
   <expand macro="stdio"/>
-  <expand macro="shell_command"/>
+  <command><![CDATA[
+
+        ############ first, create a directory to store all files
+        mkdir -p $report.files_path &&
+
+
+        ############ save the tool installation directory to an environment variable
+        export TOOL_INSTALL_DIR='${__tool_directory__}' &&
+
+
+        #########################
+        ##
+        ## save user input option/argument pairs into a file
+        ##
+        #########################
+
+        ## first line will be the header
+        echo 'tool_output_dir|relative_path' > '$report.files_path/options_and_arguments.txt' &&
+
+
+
+        ####################################################
+        ## loop through repeats to get option/argument pairs
+        ####################################################
+
+
+        ############ option_argument_path_relative_to_a_tool
+        #for i in $option_argument_path_relative_to_a_tool_repeat:
+             #set $item = str($i.a_tool_output_dir) + "|" + str($i.value)
+             echo '$item' >> '$report.files_path/options_and_arguments.txt' &&
+        #end for
+
+
+        ############ output_set
+        ## '$report'
+        ## '$report.files_path'
+        #######################
+        export REPORT='$report' &&
+        export TOOL_LOG='$tool_log' &&
+        export REPORT_FILES_PATH='$report.files_path' &&
+
+
+        ############ run render R script to render R markdowns
+        Rscript '${__tool_directory__}/paired_render.R'
+
+        ]]></command>
   <inputs>
-    <expand macro="option_argument_path_relative_to_a_tool"/>
+    <repeat name="option_argument_path_relative_to_a_tool_repeat" title="INPUT DATA PATH: relative to a tool output directory" min="2" default="2" max="2">
+      <param name="a_tool_output_dir" type="data" optional="false" multiple="false" label="a tool output directory"/>
+      <param type="text" name="value" optional="true" label="relative path"/>
+    </repeat>
   </inputs>
   <outputs>
     <data format="html" name="report" label="${tool.name} report"/>
     <data format="txt" name="tool_log" label="${tool.name} log"/>
-    <collection type="paired" name="list_collection">
-      <discover_datasets pattern="__name_and_ext__" directory="paired_dir" />
+    <collection type="paired" name="paired_collection">
+      <discover_datasets pattern="__name_and_ext__" directory="paired" />
     </collection>
   </outputs>
   <citations>
--- a/elastic_tool_wrappers_macros.xml	Mon Mar 26 18:40:39 2018 -0400
+++ b/elastic_tool_wrappers_macros.xml	Sat Mar 31 21:32:17 2018 -0400
@@ -20,55 +20,6 @@
   </xml>
 
   <!--shell command fragment-->
-  <xml name="shell_command">
-    <command><![CDATA[
-        echo $tool_name &&
-
-        ############ first, create a directory to store all files
-        mkdir -p $report.files_path &&
-
-
-        ############ save the tool installation directory to an environment variable
-        export TOOL_INSTALL_DIR='${__tool_directory__}' &&
-
-
-        #########################
-        ##
-        ## save user input option/argument pairs into a file
-        ##
-        #########################
-
-        ## first line will be the header
-        echo 'tool_output_dir|relative_path' > '$report.files_path/options_and_arguments.txt' &&
-
-
-
-        ####################################################
-        ## loop through repeats to get option/argument pairs
-        ####################################################
-
-
-        ############ option_argument_path_relative_to_a_tool
-        #for i in $option_argument_path_relative_to_a_tool_repeat:
-             #set $item = str($i.a_tool_output_dir) + "|" + str($i.value)
-             echo '$item' >> '$report.files_path/options_and_arguments.txt' &&
-        #end for
-
-
-        ############ output_set
-        ## '$report'
-        ## '$report.files_path'
-        #######################
-        export REPORT='$report' &&
-        export TOOL_LOG='$tool_log' &&
-        export REPORT_FILES_PATH='$report.files_path' &&
-
-
-        ############ run render R script to render R markdowns
-        Rscript '${__tool_directory__}/elastic_tool_render.R'
-
-        ]]></command>
-  </xml>
 
   <!--<xml name="output_set">-->
     <!--<data format="html" name="report" label="${tool.name} report"/>-->
--- a/list.Rmd	Mon Mar 26 18:40:39 2018 -0400
+++ b/list.Rmd	Sat Mar 31 21:32:17 2018 -0400
@@ -1,5 +1,5 @@
 ---
-title: 'Dynamic tool'
+title: 'Expose data (list)'
 output: html_document
 ---
 
@@ -29,7 +29,7 @@
 knitr::kable(df)
 ```
 
-```{r}
+```{r, echo=FALSE}
 write('', file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/script.sh'))
 if (nrow(df) > 0) {
   for (i in 1:nrow(df)) {
--- a/list_paired.Rmd	Mon Mar 26 18:40:39 2018 -0400
+++ b/list_paired.Rmd	Sat Mar 31 21:32:17 2018 -0400
@@ -1,5 +1,5 @@
 ---
-title: 'Dynamic tool'
+title: 'Expose data (list:paired)'
 output: html_document
 ---
 
@@ -29,7 +29,7 @@
 knitr::kable(df)
 ```
 
-```{r}
+```{r, echo=FALSE}
 write('', file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/script.sh'))
 if (nrow(df) > 0) {
   for (i in 1:nrow(df)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/list_paired_render.R	Sat Mar 31 21:32:17 2018 -0400
@@ -0,0 +1,44 @@
+##============ Sink warnings and errors to a file ==============
+## use the sink() function to wrap all code within it.
+##==============================================================
+zz = file(Sys.getenv('TOOL_LOG'))
+sink(zz)
+sink(zz, type = 'message')
+
+#------------import libraries--------------------
+options(stringsAsFactors = FALSE)
+
+library(rmarkdown)
+library(stringr)
+#------------------------------------------------
+
+#------------------------------------------------
+options_and_arguments = read.table(paste0(Sys.getenv('REPORT_FILES_PATH'), '/options_and_arguments.txt'), 
+                                   sep = '|', header = TRUE)
+
+#------------------------------------------------
+# create three folders within working directory
+dir.create('list_paired')
+
+#-----------------render Rmd--------------
+# copy R markdown file to working directory and render it within the working directory.
+render(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/list_paired.Rmd'),
+       output_file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/report.html'))
+
+# for some unknow reason, directly using REPORT as the input value for output_file parameter
+# in the render function can cause empty report file when the tool runs in batch mode.
+# the solution is to render the rmarkdown to a explicitly specified file and then copy the
+# file to ${REPORT}
+system(command = 'cp ${REPORT_FILES_PATH}/report.html ${REPORT}')
+system(command = 'sh ${REPORT_FILES_PATH}/script.sh')
+
+# rename files so that all files have the name pattern BASENAME_forward.EXT and BASENAME_reverse.EXT
+from_files = list.files('list_paired', full.names = TRUE)
+to_files = str_replace_all(from_files, c('_1', '_2'), c('_forward', '_reverse'))
+file.rename(from = from_files, to = to_files)
+#------------------------------------------
+
+
+##--------end of code rendering .Rmd templates----------------
+sink()
+##=========== End of sinking output=============================
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/list_render.R	Sat Mar 31 21:32:17 2018 -0400
@@ -0,0 +1,38 @@
+##============ Sink warnings and errors to a file ==============
+## use the sink() function to wrap all code within it.
+##==============================================================
+zz = file(Sys.getenv('TOOL_LOG'))
+sink(zz)
+sink(zz, type = 'message')
+
+#------------import libraries--------------------
+options(stringsAsFactors = FALSE)
+
+library(rmarkdown)
+#------------------------------------------------
+
+#------------------------------------------------
+options_and_arguments = read.table(paste0(Sys.getenv('REPORT_FILES_PATH'), '/options_and_arguments.txt'), 
+                                   sep = '|', header = TRUE)
+
+#------------------------------------------------
+# create three folders within working directory
+dir.create('list')
+
+#-----------------render Rmd--------------
+# copy R markdown file to working directory and render it within the working directory.
+render(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/list.Rmd'),
+       output_file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/report.html'))
+
+# for some unknow reason, directly using REPORT as the input value for output_file parameter
+# in the render function can cause empty report file when the tool runs in batch mode.
+# the solution is to render the rmarkdown to a explicitly specified file and then copy the
+# file to ${REPORT}
+system(command = 'cp ${REPORT_FILES_PATH}/report.html ${REPORT}')
+system(command = 'sh ${REPORT_FILES_PATH}/script.sh')
+#------------------------------------------
+
+
+##--------end of code rendering .Rmd templates----------------
+sink()
+##=========== End of sinking output=============================
\ No newline at end of file
--- a/paired.Rmd	Mon Mar 26 18:40:39 2018 -0400
+++ b/paired.Rmd	Sat Mar 31 21:32:17 2018 -0400
@@ -1,5 +1,5 @@
 ---
-title: 'Dynamic tool'
+title: 'Expose data (paired)'
 output: html_document
 ---
 
@@ -29,7 +29,7 @@
 knitr::kable(df)
 ```
 
-```{r}
+```{r, echo=FALSE}
 write('', file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/script.sh'))
 if (nrow(df) > 0) {
   for (i in 1:nrow(df)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paired_render.R	Sat Mar 31 21:32:17 2018 -0400
@@ -0,0 +1,38 @@
+##============ Sink warnings and errors to a file ==============
+## use the sink() function to wrap all code within it.
+##==============================================================
+zz = file(Sys.getenv('TOOL_LOG'))
+sink(zz)
+sink(zz, type = 'message')
+
+#------------import libraries--------------------
+options(stringsAsFactors = FALSE)
+
+library(rmarkdown)
+#------------------------------------------------
+
+#------------------------------------------------
+options_and_arguments = read.table(paste0(Sys.getenv('REPORT_FILES_PATH'), '/options_and_arguments.txt'), 
+                                   sep = '|', header = TRUE)
+
+#------------------------------------------------
+# create three folders within working directory
+dir.create('paired')
+
+#-----------------render Rmd--------------
+# copy R markdown file to working directory and render it within the working directory.
+render(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/paired.Rmd'),
+       output_file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/report.html'))
+
+# for some unknow reason, directly using REPORT as the input value for output_file parameter
+# in the render function can cause empty report file when the tool runs in batch mode.
+# the solution is to render the rmarkdown to a explicitly specified file and then copy the
+# file to ${REPORT}
+system(command = 'cp ${REPORT_FILES_PATH}/report.html ${REPORT}')
+system(command = 'sh ${REPORT_FILES_PATH}/script.sh')
+#------------------------------------------
+
+
+##--------end of code rendering .Rmd templates----------------
+sink()
+##=========== End of sinking output=============================
\ No newline at end of file