Mercurial > repos > mingchen0919 > aurora_star_site
comparison aurora_star_site_render.R @ 0:5f6352750d82 draft
planemo upload
author | mingchen0919 |
---|---|
date | Sun, 04 Mar 2018 11:42:48 -0500 |
parents | |
children | bcf9ea03aefe |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:5f6352750d82 |
---|---|
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 # library(dplyr) | |
18 # getopt_specification_matrix(extract_short_flags('aurora_star_site.xml')) %>% | |
19 # write.table(file = 'spec.txt', sep = ',', row.names = FALSE, col.names = TRUE, quote = FALSE) | |
20 | |
21 | |
22 spec_matrix = as.matrix( | |
23 data.frame(stringsAsFactors=FALSE, | |
24 long_flags = c("X_e", "X_o", "X_d", "X_s", "X_t", "X_A", "X_B", | |
25 "X_C", "X_F", "X_R", "X_S"), | |
26 short_flags = c("e", "o", "d", "s", "t", "A", "B", "C", "F", "R", | |
27 "S"), | |
28 argument_mask_flags = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), | |
29 data_type_flags = c("character", "character", "character", "character", | |
30 "character", "character", "character", | |
31 "character", "character", "character", "character") | |
32 ) | |
33 ) | |
34 opt = getopt(spec_matrix) | |
35 #---------------------------------------------------- | |
36 | |
37 | |
38 #-----------using passed arguments in R | |
39 # to define system environment variables--- | |
40 do.call(Sys.setenv, opt[-1]) | |
41 #---------------------------------------------------- | |
42 | |
43 #---------- often used variables ---------------- | |
44 # OUTPUT_REPORT: path to galaxy output report | |
45 # OUTPUT_DIR: path to the output associated directory, which stores all outputs | |
46 # TOOL_DIR: path to the tool installation directory | |
47 OUTPUT_DIR = opt$X_d | |
48 TOOL_DIR = opt$X_t | |
49 OUTPUT_REPORT = opt$X_o | |
50 | |
51 | |
52 # create the output associated directory to store all outputs | |
53 dir.create(OUTPUT_DIR, recursive = TRUE) | |
54 | |
55 #-----------------render site-------------- | |
56 # copy site generating materials into OUTPUT_DIR | |
57 dir.create(paste0(OUTPUT_DIR, '/site_generator'), recursive = TRUE) | |
58 system(paste0('cp -r ', TOOL_DIR, '/aurora_star_site.Rmd ', OUTPUT_DIR, '/site_generator/skewer.Rmd')) | |
59 system(paste0('cp -r ', TOOL_DIR, '/aurora_star_site_site.yml ', OUTPUT_DIR, '/site_generator/_site.yml')) | |
60 system(paste0('cp -r ', TOOL_DIR, '/aurora_star_site_index.Rmd ', OUTPUT_DIR, '/site_generator/index.Rmd')) | |
61 # render site to OUTPUT_DIR/_site, this is configured in the "_site.yml" file | |
62 render_site(input = paste0(OUTPUT_DIR, '/site_generator')) | |
63 # remove site generating materials from output associated directory | |
64 unlink(paste0(OUTPUT_DIR, '/site_generator'), recursive = TRUE) | |
65 # move _site/* into output associated directory | |
66 move_cmd = paste0('mv ', OUTPUT_DIR, '/_site/* ', OUTPUT_DIR) | |
67 system(move_cmd) | |
68 #------------------------------------------ | |
69 | |
70 #-----link index.html to output----- | |
71 cp_index = paste0('cp ', OUTPUT_DIR, '/index.html ', OUTPUT_REPORT) | |
72 system(cp_index) | |
73 #----------------------------------- | |
74 | |
75 #==============the end============== | |
76 | |
77 | |
78 ##--------end of code rendering .Rmd templates---------------- | |
79 sink() | |
80 ##=========== End of sinking output============================= |