0
|
1 ##============ Sink warnings and errors to a file ==============
|
|
2 ## use the sink() function to wrap all code within it.
|
|
3 ##==============================================================
|
4
|
4 zz = file(paste0(Sys.getenv('REPORT_FILES_PATH'), '/.r_rendering.log.txt'))
|
0
|
5 sink(zz)
|
|
6 sink(zz, type = 'message')
|
|
7
|
4
|
8 #-------------------preparation -----------------
|
0
|
9 options(stringsAsFactors = FALSE)
|
4
|
10 # import libraries
|
0
|
11 library(getopt)
|
|
12 library(rmarkdown)
|
1
|
13 library(htmltools)
|
4
|
14 # load helper functions
|
|
15 source(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/helper.R'))
|
|
16 # import getopt specification matrix from a csv file
|
|
17 opt = getopt(getopt_specification_matrix('getopt_specification.csv',
|
|
18 tool_dir=Sys.getenv('TOOL_INSTALL_DIR')))
|
|
19 # define a unix variable versions for all input values. this is useful when we
|
|
20 # want to use input values by other programming language in r markdown
|
|
21 do.call(Sys.setenv, opt[-1])
|
0
|
22 #------------------------------------------------
|
|
23
|
|
24
|
|
25
|
|
26
|
4
|
27 #-----------------render Rmd files --------------
|
|
28 # NOTICE:
|
|
29 # we should copy all rmarkdown files from tool install directory to REPORT_FILES_PATH directory.
|
|
30 # and render rmarkdown files in the REPORT_FILES_PATH directory.
|
|
31 file.copy(from = paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/vakata-jstree-3.3.5'),
|
|
32 to = Sys.getenv('REPORT_FILES_PATH'), recursive = TRUE)
|
|
33 system(command = 'cp -r ${TOOL_INSTALL_DIR}/*.Rmd ${REPORT_FILES_PATH}')
|
|
34 # render Rmd files in order
|
|
35 render(input = paste0(Sys.getenv('REPORT_FILES_PATH'), '/skewer.Rmd'))
|
0
|
36 #------------------------------------------
|
|
37
|
4
|
38
|
|
39 #---------------- copy the output html to REPORT ----
|
|
40 system(command = 'cp ${REPORT_FILES_PATH}/skewer.html ${REPORT}')
|
0
|
41 #==============the end==============
|
|
42
|
|
43
|
|
44 ##--------end of code rendering .Rmd templates----------------
|
|
45 sink()
|
|
46 ##=========== End of sinking output============================= |