Mercurial > repos > mingchen0919 > aurora_skewer
comparison skewer_render.R @ 7:c5c297020c36 draft
planemo upload commit 5b03cf1a31307c262701d4f267972bd01be24311
| author | mingchen0919 |
|---|---|
| date | Thu, 26 Apr 2018 12:49:35 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 6:5b07e567864b | 7:c5c297020c36 |
|---|---|
| 1 ##============ Sink warnings and errors to a file ============== | |
| 2 ## use the sink() function to wrap all code within it. | |
| 3 ##============================================================== | |
| 4 zz = file(paste0(Sys.getenv('REPORT_FILES_PATH'), '/.r_rendering.log.txt')) | |
| 5 sink(zz) | |
| 6 sink(zz, type = 'message') | |
| 7 | |
| 8 #============== preparation ==================================== | |
| 9 options(stringsAsFactors = FALSE) | |
| 10 # import libraries | |
| 11 #------------------------------------------------------------------ | |
| 12 # ADD MORE LIBRARIES HERE IF YOUR TOOL DEPENDS ON OTHER R LIBRARIES | |
| 13 #------------------------------------------------------------------ | |
| 14 library('getopt') | |
| 15 library('rmarkdown') | |
| 16 library('htmltools') | |
| 17 | |
| 18 | |
| 19 # load helper functions | |
| 20 source(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/helper.R')) | |
| 21 # import getopt specification matrix from a csv file | |
| 22 opt = getopt(getopt_specification_matrix('getopt_specification.csv', | |
| 23 tool_dir=Sys.getenv('TOOL_INSTALL_DIR'))) | |
| 24 # define environment variables for all input values. this is useful when we | |
| 25 # want to use input values by other programming language in r markdown | |
| 26 do.call(Sys.setenv, opt[-1]) | |
| 27 #=============================================================== | |
| 28 | |
| 29 | |
| 30 #======================== render Rmd files ========================= | |
| 31 # NOTICE: | |
| 32 # we should copy all rmarkdown files from tool install directory to REPORT_FILES_PATH directory. | |
| 33 # and render rmarkdown files in the REPORT_FILES_PATH directory. | |
| 34 file.copy(from = paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/vakata-jstree-3.3.5'), | |
| 35 to = Sys.getenv('REPORT_FILES_PATH'), recursive = TRUE) | |
| 36 system(command = 'cp -r ${TOOL_INSTALL_DIR}/*.Rmd ${REPORT_FILES_PATH}') | |
| 37 | |
| 38 #----------------BELOW IS WHERE YOU NEED TO CUSTOMIZE --------------------- | |
| 39 render(input = paste0(Sys.getenv('REPORT_FILES_PATH'), '/skewer.Rmd')) | |
| 40 # add more lines below if there are more Rmd files to be rendered | |
| 41 | |
| 42 #=============================================================== | |
| 43 | |
| 44 | |
| 45 #============== expose outputs to galaxy history =============== | |
| 46 system(command = 'sh ${TOOL_INSTALL_DIR}/expose-outputs.sh') | |
| 47 #=============================================================== | |
| 48 | |
| 49 | |
| 50 ##--------end of code rendering .Rmd templates---------------- | |
| 51 sink() | |
| 52 ##=========== End of sinking output============================= |
