Mercurial > repos > mingchen0919 > elastic_expose_data
annotate list_render.R @ 2:391394c022b8 draft
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
author | mingchen0919 |
---|---|
date | Sat, 31 Mar 2018 21:32:17 -0400 |
parents | |
children | 4f9f1e76f7e6 |
rev | line source |
---|---|
2
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
1 ##============ Sink warnings and errors to a file ============== |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
2 ## use the sink() function to wrap all code within it. |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
3 ##============================================================== |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
4 zz = file(Sys.getenv('TOOL_LOG')) |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
5 sink(zz) |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
6 sink(zz, type = 'message') |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
7 |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
8 #------------import libraries-------------------- |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
9 options(stringsAsFactors = FALSE) |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
10 |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
11 library(rmarkdown) |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
12 #------------------------------------------------ |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
13 |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
14 #------------------------------------------------ |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
15 options_and_arguments = read.table(paste0(Sys.getenv('REPORT_FILES_PATH'), '/options_and_arguments.txt'), |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
16 sep = '|', header = TRUE) |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
17 |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
18 #------------------------------------------------ |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
19 # create three folders within working directory |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
20 dir.create('list') |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
21 |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
22 #-----------------render Rmd-------------- |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
23 # copy R markdown file to working directory and render it within the working directory. |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
24 render(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/list.Rmd'), |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
25 output_file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/report.html')) |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
26 |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
27 # for some unknow reason, directly using REPORT as the input value for output_file parameter |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
28 # in the render function can cause empty report file when the tool runs in batch mode. |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
29 # the solution is to render the rmarkdown to a explicitly specified file and then copy the |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
30 # file to ${REPORT} |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
31 system(command = 'cp ${REPORT_FILES_PATH}/report.html ${REPORT}') |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
32 system(command = 'sh ${REPORT_FILES_PATH}/script.sh') |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
33 #------------------------------------------ |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
34 |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
35 |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
36 ##--------end of code rendering .Rmd templates---------------- |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
37 sink() |
391394c022b8
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
mingchen0919
parents:
diff
changeset
|
38 ##=========== End of sinking output============================= |