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)
|
2
|
15 library(httr)
|
0
|
16 #------------------------------------------------
|
|
17
|
|
18
|
|
19 #------------get arguments into R--------------------
|
|
20 # load helper function
|
|
21 source(paste0(Sys.getenv('TOOL_DIR'), '/helper.R'))
|
|
22 # import getopt specification matrix from a csv file
|
1
|
23 opt = getopt(getopt_specification_matrix('/variant_simple_search.csv'))
|
0
|
24 opt$X_t = Sys.getenv('TOOL_DIR')
|
|
25 #----------------------------------------------------
|
|
26
|
1
|
27 print(opt)
|
0
|
28
|
|
29 #-----------using passed arguments in R
|
|
30 # to define system environment variables---
|
|
31 do.call(Sys.setenv, opt[-1])
|
|
32 #----------------------------------------------------
|
|
33
|
|
34 #---------- often used variables ----------------
|
|
35 # OUTPUT_DIR: path to the output associated directory, which stores all outputs
|
|
36 # TOOL_DIR: path to the tool installation directory
|
|
37 OUTPUT_DIR = opt$X_d
|
|
38 TOOL_DIR = opt$X_t
|
|
39 OUTPUT_REPORT = opt$X_o
|
1
|
40 RMD_NAME = 'variant_simple_search.Rmd'
|
0
|
41
|
|
42 # create the output associated directory to store all outputs
|
|
43 dir.create(OUTPUT_DIR, recursive = TRUE)
|
|
44
|
|
45 #-----------------render Rmd--------------
|
|
46 render(paste0(TOOL_DIR, '/', RMD_NAME), output_file = OUTPUT_REPORT)
|
|
47 #------------------------------------------
|
|
48
|
|
49 #==============the end==============
|
|
50
|
|
51
|
|
52 ##--------end of code rendering .Rmd templates----------------
|
|
53 sink()
|
|
54 ##=========== End of sinking output============================= |