comparison fastqc_site_render.R @ 0:b7c115edd970 draft

planemo upload
author mingchen0919
date Tue, 27 Feb 2018 10:37:12 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:b7c115edd970
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 library(getopt)
9 library(rmarkdown)
10 library(htmltools)
11 library(plyr)
12 library(dplyr)
13 library(stringr)
14 library(DT)
15 library(reshape2)
16 library(plotly)
17 options(stringsAsFactors = FALSE)
18
19 # getopt_specification_matrix(extract_short_flags('fastqc_report.xml')) %>%
20 # write.table(file = 'spec.txt', sep = ',', row.names = FALSE, col.names = TRUE, quote = FALSE)
21
22
23 # get arguments into R
24 spec_matrix = as.matrix(
25 data.frame(stringsAsFactors=FALSE,
26 long_flags = c("X_e", "X_r", "X_n", "X_R", "X_N", "X_c", "X_l",
27 "X_o", "X_d", "X_s", "X_t"),
28 short_flags = c("e", "r", "n", "R", "N", "c", "l", "o", "d", "s",
29 "t"),
30 argument_mask_flags = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L),
31 data_type_flags = c("character", "character", "character", "character",
32 "character", "character", "character",
33 "character", "character", "character", "character")
34 )
35 )
36 opt = getopt(spec_matrix)
37
38 # using passed arguments in R to define system environment variables
39 do.call(Sys.setenv, opt[-1])
40
41 # create the output associated directory to store all outputs
42 dir.create(opt$X_d, recursive = TRUE)
43
44 #-----------------render site--------------
45 # copy site generating materials into folder "_site" within the output associated directory
46 file.copy(opt$X_t, opt$X_d, recursive = TRUE)
47 # render site to the output associated directory
48 render_site(input = paste0(opt$X_d, '/aurora_fastqc_site'))
49 # remove site generating materials from output associated directory
50 unlink(paste0(opt$X_d, '/aurora_fastqc_site'), recursive = TRUE)
51 # move _site/* into output associated directory
52 move_cmd = paste0('mv ', opt$X_d, '/_site/* ', opt$X_d)
53 system(move_cmd)
54 #------------------------------------------
55
56 #-----link index.html to output-----
57 cp_index = paste0('cp ', opt$X_d, '/index.html ', opt$X_o)
58 system(cp_index)
59 #-----------------------------------
60
61 #==============the end==============
62
63
64
65 # file.copy(paste0(opt$X_d, '/index.html'), opt$X_o, recursive = TRUE)
66
67 ##--------end of code rendering .Rmd templates----------------
68 sink()
69 ##=========== End of sinking output=============================