# HG changeset patch # User mingchen0919 # Date 1524680552 14400 # Node ID 578a96df86908527a6b736f9535f04e8c56a3c21 # Parent 1696f5ee0fe73307d128e18d2fb5f889d13e7a86 planemo upload commit 1cb2dd80dcb431563edbe1e763b3dde3a1adb2ae-dirty diff -r 1696f5ee0fe7 -r 578a96df8690 expose-outputs.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/expose-outputs.sh Wed Apr 25 14:22:32 2018 -0400 @@ -0,0 +1,7 @@ +# change directory to tool outputs directory +cd ${REPORT_FILES_PATH} + +# copy files to corresponding tool output paths. +cp htseq_count.html ${REPORT} +cp counts.RData ${X_O} +cp counts.txt ${X_c} \ No newline at end of file diff -r 1696f5ee0fe7 -r 578a96df8690 helper.R --- a/helper.R Wed Apr 18 17:12:06 2018 -0400 +++ b/helper.R Wed Apr 25 14:22:32 2018 -0400 @@ -4,9 +4,14 @@ #' The first column are short flags, the second column are argument masks, the third column #' is data types. The fourth column are variable names used in the tool XML. These three columns are required. #' @param gtg_name the name of a running GTG. -getopt_specification_matrix = function(specification_file, gtg_name = 'gtg', tool_dir = Sys.getenv('TOOL_DIR')) { - df = read.csv(paste0(tool_dir, '/', specification_file), - header = TRUE, stringsAsFactors = FALSE) +getopt_specification_matrix = function(specification_file, + gtg_name = 'gtg', + tool_dir = Sys.getenv('TOOL_DIR')) { + df = read.csv( + paste0(tool_dir, '/', specification_file), + header = TRUE, + stringsAsFactors = FALSE + ) # check if there are duplicated short flags short_flags = df[, 1] if (length(unique(short_flags)) < length(short_flags)) { @@ -19,10 +24,12 @@ long_flags = paste0('X_', df[, 1]) # specification matrix - df2 = data.frame(long_flags = long_flags, - short_flags = df[, 1], - argument_mask = df[, 2], - data_type = df[, 3]) + df2 = data.frame( + long_flags = long_flags, + short_flags = df[, 1], + argument_mask = df[, 2], + data_type = df[, 3] + ) as.matrix(df2) } @@ -30,43 +37,46 @@ #' \code{file_tree} generate file tree of a directory in the format of HTML lists. -#' +#' #' @param dir the path to the directory for generating the file tree. #' @param output_dir the REPORT_FILES_PATH folder name, which has the name style: dataset_NUMBER_files. # define a recursive function to build html string of the file tree -file_tree = function(dir = '.'){ +file_tree = function(dir = '.') { # get the OUTPUT_DIR folder data: dataset_NUMBER_files report_files_path = Sys.getenv('REPORT_FILES_PATH') output_dir = tail(strsplit(report_files_path, '/')[[1]], 1) - files = list.files(path = dir, recursive = FALSE, full.names = TRUE) + files = list.files(path = dir, + recursive = FALSE, + full.names = TRUE) # files also include directorys, need to remove directorys files = files[!dir.exists(files)] - dirs = list.dirs(path = dir, recursive = FALSE, full.names = TRUE) - # hide vakata-jstree-3.3.5 folder - #jstree_index = grep(pattern = 'vakata-jstree-3.3.5', x = dirs) - #dirs = dirs[-jstree_index] - tags$ul( - { - if (length(files) > 0) { - lapply(files, function(x){ - path_end = tail(strsplit(x, '/')[[1]],1) - href_path = strsplit(x, paste0(output_dir, '/'))[[1]][2] - li_item = tags$li(tags$a(path_end, href=href_path)) - li_item$attribs = list('data-jstree'='{"icon":"jstree-file"}') + dirs = list.dirs(path = dir, + recursive = FALSE, + full.names = TRUE) + tags$ul({ + if (length(files) > 0) { + lapply(files, function(x) { + path_end = tail(strsplit(x, '/')[[1]], 1) + href_path = strsplit(x, paste0(output_dir, '/'))[[1]][2] + li_item = tags$li(tags$a(path_end, href = href_path)) + li_item$attribs = list('data-jstree' = '{"icon":"jstree-file"}') + li_item + }) + } + }, + { + if (length(dirs) > 0) { + lapply(dirs, function(x) { + path_end = tail(strsplit(x, '/')[[1]], 1) + # hide vakata-jstree-3.3.5 folder + if (path_end != 'vakata-jstree-3.3.5') { + # x_path = strsplit(x, paste0(output_dir, '/'))[[1]][2] + li_item = tags$li(path_end, file_tree(x)) + li_item$attribs = list('data-jstree' = '{"icon":"jstree-folder"}') li_item - }) - } - }, - { - if (length(dirs) > 0) { - lapply(dirs, function(x){ - x_path = strsplit(x, paste0(output_dir, '/'))[[1]][2] - li_item = tags$li(x_path, file_tree(x)) - li_item$attribs = list('data-jstree'='{"icon":"jstree-folder"}') - li_item - }) - } + } + }) } - ) + }) } diff -r 1696f5ee0fe7 -r 578a96df8690 htseq_count.Rmd --- a/htseq_count.Rmd Wed Apr 18 17:12:06 2018 -0400 +++ b/htseq_count.Rmd Wed Apr 25 14:22:32 2018 -0400 @@ -47,7 +47,7 @@ * htseq-count analysis: [htseq-count.sh](htseq-count.sh) ```{bash, echo=FALSE} -sh ${TOOL_INSTALL_DIR}/run_htseq-count.sh +sh ${TOOL_INSTALL_DIR}/shell-script-template.sh ``` @@ -62,12 +62,7 @@ ```{r, echo=FALSE} # save count data as an R object -save(count_data, file = paste0(opt$X_d, '/counts.RData')) -``` - -```{bash, echo=FALSE} -# expose counts.RData to galaxy history -cp ${X_d}/counts.RData ${X_O} +save(count_data, file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/counts.RData')) ``` ----------------------------------------- diff -r 1696f5ee0fe7 -r 578a96df8690 htseq_count_render.R --- a/htseq_count_render.R Wed Apr 18 17:12:06 2018 -0400 +++ b/htseq_count_render.R Wed Apr 25 14:22:32 2018 -0400 @@ -38,10 +38,8 @@ #------------------------------------------ -#---------------- copy the output html to REPORT ---- -system(command = 'cp ${REPORT_FILES_PATH}/htseq_count.html ${REPORT}') -# add more lines below if there are more output html files - +#--------- expose outputs to galaxy history ---- +system(command = 'sh ${TOOL_INSTALL_DIR}/expose-outputs.sh') #==============the end============== diff -r 1696f5ee0fe7 -r 578a96df8690 run_htseq-count.sh --- a/run_htseq-count.sh Wed Apr 18 17:12:06 2018 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -cd ${X_d} - -cat >htseq-count.sh < htseq-counts-raw.txt - - grep -v '__no_feature\|__ambiguous\|__too_low_aQual\|__not_aligned\|__alignment_not_unique' htseq-counts-raw.txt > counts.txt - - cp counts.txt ${X_c} -EOF - -sh htseq-count.sh \ No newline at end of file diff -r 1696f5ee0fe7 -r 578a96df8690 shell-script-template.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/shell-script-template.sh Wed Apr 25 14:22:32 2018 -0400 @@ -0,0 +1,28 @@ +# SHELL_SCRIPT file name +SHELL_SCRIPT='htseq-count.sh' + +# run SHELL_SCRIPT within tool outputs directory +cd ${REPORT_FILES_PATH} + +# build job-script.sh +cat >${SHELL_SCRIPT} < htseq-counts-raw.txt + + grep -v '__no_feature\|__ambiguous\|__too_low_aQual\|__not_aligned\|__alignment_not_unique' htseq-counts-raw.txt > counts.txt + +#------------ END OF SHELL SCRIPT ------------------------------------------ +EOF + +# run SHELL_SCRIPT +sh ${SHELL_SCRIPT} \ No newline at end of file