# HG changeset patch # User mingchen0919 # Date 1522546337 14400 # Node ID 391394c022b8d5f147fa80e75fdb65022f5fd3d3 # Parent 16e0f4b7a286e3089969e39ef3bf6e45413705b8 planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty diff -r 16e0f4b7a286 -r 391394c022b8 elastic_expose_to_list_collection.xml --- 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 @@ - + elastic_tool_wrappers_macros.xml @@ -8,9 +8,57 @@ - + '$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' + + ]]> - + + + + diff -r 16e0f4b7a286 -r 391394c022b8 elastic_expose_to_list_paired_collection.xml --- 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 @@ - + elastic_tool_wrappers_macros.xml @@ -8,16 +8,63 @@ - + '$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' + + ]]> - + + + + - - + + diff -r 16e0f4b7a286 -r 391394c022b8 elastic_expose_to_paired_collection.xml --- 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 @@ - + elastic_tool_wrappers_macros.xml @@ -8,15 +8,63 @@ - + '$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' + + ]]> - + + + + - - + + diff -r 16e0f4b7a286 -r 391394c022b8 elastic_tool_wrappers_macros.xml --- 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 @@ - - '$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' - - ]]> - diff -r 16e0f4b7a286 -r 391394c022b8 list.Rmd --- 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)) { diff -r 16e0f4b7a286 -r 391394c022b8 list_paired.Rmd --- 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)) { diff -r 16e0f4b7a286 -r 391394c022b8 list_paired_render.R --- /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 diff -r 16e0f4b7a286 -r 391394c022b8 list_render.R --- /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 diff -r 16e0f4b7a286 -r 391394c022b8 paired.Rmd --- 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)) { diff -r 16e0f4b7a286 -r 391394c022b8 paired_render.R --- /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