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