view split_fasta.Rmd @ 1:8ef62ca3938b draft default tip

initial tool
author mingchen0919
date Mon, 09 Apr 2018 12:30:44 -0400
parents efd5c022b54d
children
line wrap: on
line source

---
title: 'FASTA splitter'
output: 
  html_document:
    highlight: pygments
---

```{r setup, include=FALSE, warning=FALSE, message=FALSE}
knitr::opts_chunk$set(echo = TRUE, error = TRUE)
```


```{bash}
# build job-script
mkdir -p ${WORKING_DIR}/fasta_files

# single-end.sh
cat <<EOF >${X_d}/job-script.sh
${X_t}/split_multifasta.pl \\
  --input_file=${X_A} \\
  --seqs_per_file=${X_B} \\
  --output_dir=${WORKING_DIR}/fasta_files > ${X_d}/fasta_splitter-log.txt 2>&1
EOF
```

```{bash, 'run jobs', echo=FALSE}
# run job script, always use absolute path. 
# we want to run all jobs within the working path.
sh ${X_d}/job-script.sh
```

```{r, 'display output directory contents', results='asis', echo=FALSE}
## after the job is done, we list all files from the output directory.
## full relative path to the output directory needs to be displayed.

cat('##All output files')
cat('\n\n')
all_files = list.files(path = opt$X_d, 
                       full.names = TRUE, 
                       recursive = TRUE)

for (f in sub(opt$X_d, '.', all_files) ) {
  cat('* [', f, '](', f, ')\n')
}
cat('\n')
```