comparison split_fasta_render.R @ 0:efd5c022b54d draft

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