Mercurial > repos > mingchen0919 > mygene_and_myvariant
comparison variant_simple_search_render.R @ 0:a88f12177e6f draft
planemo upload
author | mingchen0919 |
---|---|
date | Tue, 20 Mar 2018 11:29:28 -0400 |
parents | |
children | f8ac93c41720 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a88f12177e6f |
---|---|
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) | |
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 spec_csv = paste0(Sys.getenv('TOOL_DIR'), '/getopt_specification.csv') | |
21 opt = getopt(getopt_specification_matrix(spec_csv)) | |
22 opt$X_t = Sys.getenv('TOOL_DIR') | |
23 #---------------------------------------------------- | |
24 | |
25 | |
26 #-----------using passed arguments in R | |
27 # to define system environment variables--- | |
28 do.call(Sys.setenv, opt[-1]) | |
29 #---------------------------------------------------- | |
30 | |
31 #---------- often used variables ---------------- | |
32 # OUTPUT_DIR: path to the output associated directory, which stores all outputs | |
33 # TOOL_DIR: path to the tool installation directory | |
34 OUTPUT_DIR = opt$X_d | |
35 TOOL_DIR = opt$X_t | |
36 OUTPUT_REPORT = opt$X_o | |
37 RMD_NAME = '' | |
38 | |
39 # create the output associated directory to store all outputs | |
40 dir.create(OUTPUT_DIR, recursive = TRUE) | |
41 | |
42 #-----------------render Rmd-------------- | |
43 render(paste0(TOOL_DIR, '/', RMD_NAME), output_file = OUTPUT_REPORT) | |
44 #------------------------------------------ | |
45 | |
46 #==============the end============== | |
47 | |
48 | |
49 ##--------end of code rendering .Rmd templates---------------- | |
50 sink() | |
51 ##=========== End of sinking output============================= |