0
|
1 ##============ Sink warnings and errors to a file ==============
|
|
2 ## use the sink() function to wrap all code within it.
|
|
3 ##==============================================================
|
|
4 zz = file('warnings_and_errors.txt')
|
|
5 sink(zz)
|
|
6 sink(zz, type = 'message')
|
|
7
|
|
8 #------------import libraries--------------------
|
|
9 options(stringsAsFactors = FALSE)
|
|
10
|
|
11 library(getopt)
|
|
12 library(rmarkdown)
|
1
|
13 library(jsonlite)
|
|
14 library(DT)
|
0
|
15 #------------------------------------------------
|
|
16
|
|
17
|
|
18 #------------get arguments into R--------------------
|
|
19 # load helper function
|
|
20 source(paste0(Sys.getenv('TOOL_DIR'), '/helper.R'))
|
|
21 # import getopt specification matrix from a csv file
|
1
|
22 opt = getopt(getopt_specification_matrix('/variant_simple_search.csv'))
|
0
|
23 opt$X_t = Sys.getenv('TOOL_DIR')
|
|
24 #----------------------------------------------------
|
|
25
|
1
|
26 print(opt)
|
0
|
27
|
|
28 #-----------using passed arguments in R
|
|
29 # to define system environment variables---
|
|
30 do.call(Sys.setenv, opt[-1])
|
|
31 #----------------------------------------------------
|
|
32
|
|
33 #---------- often used variables ----------------
|
|
34 # OUTPUT_DIR: path to the output associated directory, which stores all outputs
|
|
35 # TOOL_DIR: path to the tool installation directory
|
|
36 OUTPUT_DIR = opt$X_d
|
|
37 TOOL_DIR = opt$X_t
|
|
38 OUTPUT_REPORT = opt$X_o
|
1
|
39 RMD_NAME = 'variant_simple_search.Rmd'
|
0
|
40
|
|
41 # create the output associated directory to store all outputs
|
|
42 dir.create(OUTPUT_DIR, recursive = TRUE)
|
|
43
|
|
44 #-----------------render Rmd--------------
|
|
45 render(paste0(TOOL_DIR, '/', RMD_NAME), output_file = OUTPUT_REPORT)
|
|
46 #------------------------------------------
|
|
47
|
|
48 #==============the end==============
|
|
49
|
|
50
|
|
51 ##--------end of code rendering .Rmd templates----------------
|
|
52 sink()
|
|
53 ##=========== End of sinking output============================= |