annotate fastqc_site_render.R @ 0:b7c115edd970 draft

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