diff fastqc_site_render.R @ 1:645291efd2e7 draft

working version
author mingchen0919
date Tue, 27 Feb 2018 10:36:24 -0500
parents f74fdae99053
children acb9908e68e4
line wrap: on
line diff
--- a/fastqc_site_render.R	Tue Feb 27 00:39:56 2018 -0500
+++ b/fastqc_site_render.R	Tue Feb 27 10:36:24 2018 -0500
@@ -19,27 +19,50 @@
 # getopt_specification_matrix(extract_short_flags('fastqc_report.xml')) %>%
 #   write.table(file = 'spec.txt', sep = ',', row.names = FALSE, col.names = TRUE, quote = FALSE)
 
+
+# get arguments into R
 spec_matrix = as.matrix(
   data.frame(stringsAsFactors=FALSE,
               long_flags = c("X_e", "X_r", "X_n", "X_R", "X_N", "X_c", "X_l",
-                             "X_o", "X_d", "X_s", "X_p"),
+                             "X_o", "X_d", "X_s", "X_t"),
              short_flags = c("e", "r", "n", "R", "N", "c", "l", "o", "d", "s",
-                             "p"),
+                             "t"),
      argument_mask_flags = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L),
          data_type_flags = c("character", "character", "character", "character",
                              "character", "character", "character",
                              "character", "character", "character", "character")
   )
 )
-# get arguments into R
 opt = getopt(spec_matrix)
-# define system environment variables
+
+# using passed arguments in R to define system environment variables
 do.call(Sys.setenv, opt[-1])
 
-# render website
-# render(input = opt$X_p, output_file = opt$X_o)
-render_site()
-file.copy(paste0(opt$X_d, '/index.html'), opt$X_o, recursive = TRUE)
+# create the output associated directory to store all outputs
+dir.create(opt$X_d, recursive = TRUE)
+
+#-----------------render site--------------
+# copy site generating materials into folder "_site" within the output associated directory
+file.copy(opt$X_t, opt$X_d, recursive = TRUE)
+# render site to the output associated directory
+render_site(input = paste0(opt$X_d, '/aurora_fastqc_site'))
+# remove site generating materials from output associated directory
+unlink(paste0(opt$X_d, '/aurora_fastqc_site'), recursive = TRUE)
+# move _site/* into output associated directory
+move_cmd = paste0('mv ', opt$X_d, '/_site/* ', opt$X_d)
+system(move_cmd)
+#------------------------------------------
+
+#-----link index.html to output-----
+cp_index = paste0('cp ', opt$X_d, '/index.html ', opt$X_o)
+system(cp_index)
+#-----------------------------------
+
+#==============the end==============
+
+
+
+# file.copy(paste0(opt$X_d, '/index.html'), opt$X_o, recursive = TRUE)
 
 ##--------end of code rendering .Rmd templates----------------
 sink()