|
0
|
1 ---
|
|
|
2 title: 'FASTA splitter'
|
|
|
3 output:
|
|
|
4 html_document:
|
|
|
5 highlight: pygments
|
|
|
6 ---
|
|
|
7
|
|
|
8 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
|
|
|
9 knitr::opts_chunk$set(echo = TRUE, error = TRUE)
|
|
|
10 ```
|
|
|
11
|
|
|
12
|
|
|
13 ```{bash}
|
|
|
14 # build job-script
|
|
|
15 mkdir -p ${WORKING_DIR}/fasta_files
|
|
|
16
|
|
|
17 # single-end.sh
|
|
1
|
18 cat <<EOF >${X_d}/job-script.sh
|
|
2
|
19 cd ${WORKING_DIR}/fasta_files && \\
|
|
|
20 cp ${X_A} input.fasta && \\
|
|
|
21 ${X_t}/split.pl input.fasta ${X_B} > ${X_d}/fasta_splitter-log.txt 2>&1
|
|
0
|
22 EOF
|
|
|
23 ```
|
|
|
24
|
|
|
25 ```{bash, 'run jobs', echo=FALSE}
|
|
|
26 # run job script, always use absolute path.
|
|
|
27 # we want to run all jobs within the working path.
|
|
1
|
28 sh ${X_d}/job-script.sh
|
|
0
|
29 ```
|
|
|
30
|
|
2
|
31 ```{bash}
|
|
|
32 # remove original input fasta
|
|
|
33 rm ${WORKING_DIR}/fasta_files/input.fasta
|
|
|
34 mv ${WORKING_DIR}/fasta_files/out ${X_d}/split-out.txt
|
|
|
35 ```
|
|
|
36
|
|
0
|
37 ```{r, 'display output directory contents', results='asis', echo=FALSE}
|
|
|
38 ## after the job is done, we list all files from the output directory.
|
|
|
39 ## full relative path to the output directory needs to be displayed.
|
|
|
40
|
|
|
41 cat('##All output files')
|
|
|
42 cat('\n\n')
|
|
1
|
43 all_files = list.files(path = opt$X_d,
|
|
0
|
44 full.names = TRUE,
|
|
|
45 recursive = TRUE)
|
|
|
46
|
|
1
|
47 for (f in sub(opt$X_d, '.', all_files) ) {
|
|
0
|
48 cat('* [', f, '](', f, ')\n')
|
|
|
49 }
|
|
|
50 cat('\n')
|
|
|
51 ```
|
|
|
52
|