Mercurial > repos > mingchen0919 > dynamic_tool_test
comparison dynamic_tool_render.R @ 0:b49e227ec738 draft default tip
planemo upload commit fe1408d418f7f1354a736f73ece704219baa3190
author | mingchen0919 |
---|---|
date | Wed, 21 Mar 2018 17:26:27 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b49e227ec738 |
---|---|
1 ##============ Sink warnings and errors to a file ============== | |
2 ## use the sink() function to wrap all code within it. | |
3 ##============================================================== | |
4 zz = file('tool_log.txt') | |
5 sink(zz) | |
6 sink(zz, type = 'message') | |
7 | |
8 #------------import libraries-------------------- | |
9 options(stringsAsFactors = FALSE) | |
10 | |
11 library(getopt) | |
12 library(rmarkdown) | |
13 #------------------------------------------------ | |
14 | |
15 | |
16 #------------get arguments into R-------------------- | |
17 # load helper function | |
18 source(paste0(Sys.getenv('TOOL_DIR'), '/helper.R')) | |
19 # import getopt specification matrix from a csv file | |
20 opt = getopt(getopt_specification_matrix('/dynamic_tool.csv')) | |
21 opt$X_T = Sys.getenv('TOOL_DIR') | |
22 #---------------------------------------------------- | |
23 | |
24 | |
25 #-----------using passed arguments in R | |
26 # to define system environment variables--- | |
27 do.call(Sys.setenv, opt[-1]) | |
28 #---------------------------------------------------- | |
29 | |
30 #---------- often used variables ---------------- | |
31 # OUTPUT_DIR: path to the output associated directory, which stores all outputs | |
32 # TOOL_DIR: path to the tool installation directory | |
33 OUTPUT_REPORT = opt$X_R | |
34 OUTPUT_DIR = opt$X_D | |
35 TOOL_DIR = opt$X_T | |
36 RMD_NAME = 'dynamic_tool.Rmd' | |
37 | |
38 # create the output associated directory to store all outputs | |
39 dir.create(OUTPUT_DIR, recursive = TRUE) | |
40 | |
41 #-----------------render Rmd-------------- | |
42 render(paste0(TOOL_DIR, '/', RMD_NAME), output_file = OUTPUT_REPORT) | |
43 #------------------------------------------ | |
44 | |
45 #==============the end============== | |
46 | |
47 | |
48 ##--------end of code rendering .Rmd templates---------------- | |
49 sink() | |
50 ##=========== End of sinking output============================= |