0
|
1 ##============ Sink warnings and errors to a file ==============
|
|
2 ## use the sink() function to wrap all code within it.
|
|
3 ##==============================================================
|
5
|
4 zz = file(paste0(Sys.getenv('REPORT_FILES_PATH'), '/.r_rendering.log.txt'))
|
0
|
5 sink(zz)
|
|
6 sink(zz, type = 'message')
|
|
7
|
5
|
8 #-------------------preparation -----------------
|
0
|
9 options(stringsAsFactors = FALSE)
|
5
|
10 # import libraries
|
0
|
11 library(getopt)
|
|
12 library(rmarkdown)
|
2
|
13 library(htmltools)
|
5
|
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
|
5
|
25 #-----------------render Rmd files --------------
|
|
26 # NOTICE:
|
|
27 # we should copy all rmarkdown files from tool install directory to REPORT_FILES_PATH directory.
|
|
28 # and render rmarkdown files in the REPORT_FILES_PATH directory.
|
|
29 file.copy(from = paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/vakata-jstree-3.3.5'),
|
|
30 to = Sys.getenv('REPORT_FILES_PATH'), recursive = TRUE)
|
|
31 system(command = 'cp -r ${TOOL_INSTALL_DIR}/*.Rmd ${REPORT_FILES_PATH}')
|
|
32 # render Rmd files in order
|
|
33 render(input = paste0(Sys.getenv('REPORT_FILES_PATH'), '/htseq_count.Rmd'))
|
|
34 # add more lines below if there are more Rmd files to be rendered
|
|
35
|
|
36 #------------------------------------------
|
0
|
37
|
|
38
|
5
|
39 #---------------- copy the output html to REPORT ----
|
|
40 system(command = 'cp ${REPORT_FILES_PATH}/htseq_count.html ${REPORT}')
|
|
41 # add more lines below if there are more output html files
|
0
|
42
|
|
43 #==============the end==============
|
|
44
|
|
45
|
|
46 ##--------end of code rendering .Rmd templates----------------
|
|
47 sink()
|
|
48 ##=========== End of sinking output============================= |