Mercurial > repos > mingchen0919 > tripal_db_explorer
comparison search_contents_render.R @ 6:4bc7752bfd72 draft
resources summary + search
| author | mingchen0919 |
|---|---|
| date | Mon, 19 Mar 2018 16:29:51 -0400 |
| parents | 5accedb3133e |
| children |
comparison
equal
deleted
inserted
replaced
| 5:5accedb3133e | 6:4bc7752bfd72 |
|---|---|
| 8 #------------import libraries-------------------- | 8 #------------import libraries-------------------- |
| 9 options(stringsAsFactors = FALSE) | 9 options(stringsAsFactors = FALSE) |
| 10 | 10 |
| 11 library(getopt) | 11 library(getopt) |
| 12 library(rmarkdown) | 12 library(rmarkdown) |
| 13 library(jsonlite) | |
| 13 #------------------------------------------------ | 14 #------------------------------------------------ |
| 14 | 15 |
| 15 | 16 |
| 16 #------------get arguments into R-------------------- | 17 #------------get arguments into R-------------------- |
| 17 # load helper function | 18 # load helper function |
| 18 source(paste0(Sys.getenv('TOOL_DIR'), '/helper.R')) | 19 source(paste0(Sys.getenv('TOOL_DIR'), '/helper.R')) |
| 19 # import getopt specification matrix from a csv file | 20 # 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('/search_contents.csv')) |
| 21 opt = getopt(getopt_specification_matrix(spec_csv)) | |
| 22 opt$X_t = Sys.getenv('TOOL_DIR') | 22 opt$X_t = Sys.getenv('TOOL_DIR') |
| 23 print(opt) | |
| 23 #---------------------------------------------------- | 24 #---------------------------------------------------- |
| 24 | 25 |
| 25 | 26 |
| 26 #-----------using passed arguments in R | 27 #-----------using passed arguments in R |
| 27 # to define system environment variables--- | 28 # to define system environment variables--- |
| 28 do.call(Sys.setenv, opt[-1]) | 29 do.call(Sys.setenv, opt[-1]) |
| 29 #---------------------------------------------------- | 30 #---------------------------------------------------- |
| 30 | 31 |
| 31 #---------- often used variables ---------------- | 32 #---------- often used variables ---------------- |
| 32 # OUTPUT_DIR: path to the output associated directory, which stores all outputs | 33 # OUTPUT_DIR: path to the output associated directory, which stores all outputs |
| 33 # TOOL_DIR: path to the tool installation directory | 34 # TOOL_DIR: path to the tool installation directory |
| 34 OUTPUT_DIR = opt$X_d | 35 OUTPUT_DIR = opt$X_d |
| 35 TOOL_DIR = opt$X_t | 36 TOOL_DIR = opt$X_t |
| 36 OUTPUT_REPORT = opt$X_o | 37 OUTPUT_REPORT = opt$X_o |
| 37 RMD_NAME = '' | 38 RMD_NAME = 'search_contents.Rmd' |
| 38 | 39 |
| 39 # create the output associated directory to store all outputs | 40 # create the output associated directory to store all outputs |
| 40 dir.create(OUTPUT_DIR, recursive = TRUE) | 41 dir.create(OUTPUT_DIR, recursive = TRUE) |
| 41 | 42 |
| 42 #-----------------render Rmd-------------- | 43 #-----------------render Rmd-------------- |
