Mercurial > repos > mingchen0919 > dynamic_star
diff dynamic_tool.Rmd @ 2:a9579c344a90 draft default tip
planemo upload commit 8f84e3911c6ff4103c0ad5fb8dd774f80d9b2559
| author | mingchen0919 |
|---|---|
| date | Fri, 23 Mar 2018 21:50:16 -0400 |
| parents | d79569f269c7 |
| children |
line wrap: on
line diff
--- a/dynamic_tool.Rmd Fri Mar 23 02:01:52 2018 -0400 +++ b/dynamic_tool.Rmd Fri Mar 23 21:50:16 2018 -0400 @@ -3,6 +3,15 @@ output: html_document --- +<style> +pre code, pre, code { + white-space: pre !important; + overflow-x: scroll !important; + word-break: keep-all !important; + word-wrap: initial !important; +} +</style> + ```{r setup, include=FALSE, warning=FALSE, message=FALSE} knitr::opts_chunk$set(error = TRUE) ``` @@ -16,13 +25,23 @@ df = read.table(paste0(Sys.getenv('REPORT_FILES_PATH'), '/options_and_arguments.txt'), sep = '|', header = TRUE) +# prepend A_TOOL_OUTPUT_PATH +if (nrow(df[df$type == 'path_relative_to_a_tool', ]) > 0) { + for (i in 1:nrow(df[df$type == 'path_relative_to_a_tool', ])) { + root_path = readLines(df[df$type == 'path_relative_to_a_tool', ][i, 'path_type'])[1] + df[df$type == 'path_relative_to_a_tool', ][i, 'value'] = paste(root_path, + df[df$type == 'path_relative_to_a_tool', ][i, 'value'], + sep = '/') + } +} + # get tool name tool_name = df[df$type == 'tool_name', 'value'] # build script for displaying help messages (this probably should be tool specific) write(paste0(tool_name, ' -h'), file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/help.sh')) -knitr::kable(df[, c('flag', 'value')]) +knitr::kable(df) # if the number of option/argument pairs is larger than 0, build script file df2 = df[df$type != 'tool_name', ] @@ -56,13 +75,31 @@ sh ${REPORT_FILES_PATH}/help.sh > ${TOOL_HELP_DOC} ``` -```{bash, results='asis', echo=FALSE} -echo '## Show help documentation' -echo '' -echo '' -echo '```bash' -cat ${REPORT_FILES_PATH}/help.sh -echo '```' + +```{r, echo=FALSE} +# create paths before running the job script +df_paths = df[df$type == 'path_relative_to_this_tool', ] + +if (nrow(df_paths) > 0) { + for (i in 1:nrow(df_paths)) { + path = paste0(Sys.getenv('REPORT_FILES_PATH'), '/', df_paths[i, 'value']) + path_type = df_paths[i, 'path_type'] + + # create file paths + if ((path_type == 'file_path') & !file.exists(path)) { + dir_path = paste(head(strsplit(path, '/')[[1]], -1), collapse = '/' ) + if (!dir.exists(dir_path)) { + dir.create(dir_path, recursive = TRUE) + } + file.create(path) + } + + # create dir paths + if ((path_type == 'dir_path') & !dir.exists(path)) { + dir.create(path, recursive = TRUE) + } + } +} ``` @@ -72,6 +109,8 @@ cd ${REPORT_FILES_PATH} && sh script.sh ``` + + ```{bash, results='asis', echo=FALSE} echo '## Job script' echo '' @@ -82,6 +121,15 @@ ``` +```{r, echo=FALSE} +## obtain REPORT_FILES_PAHT and save it to a galaxy output. +database_root = paste(head(strsplit(Sys.getenv('TOOL_LOG'), '/')[[1]], -1), collapse = '/') +tool_output_dir_id = tail(strsplit(Sys.getenv('REPORT_FILES_PATH'), '/')[[1]], 1) +tool_output_dir = paste0(database_root, '/', tool_output_dir_id) +write(tool_output_dir, Sys.getenv('TOOL_OUTPUT_DIR')) +``` + + ```{r, results='asis', echo=FALSE} cat('##All output files') cat('\n\n')
