Mercurial > repos > mingchen0919 > aurora_skewer_site
changeset 0:ad0aa8d214c1 draft
planemo upload
author | mingchen0919 |
---|---|
date | Fri, 02 Mar 2018 10:20:53 -0500 |
parents | |
children | 0483f55131d1 |
files | skewer.Rmd skewer.sh skewer.xml skewer_index.Rmd skewer_render.R skewer_site.yml |
diffstat | 6 files changed, 272 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skewer.Rmd Fri Mar 02 10:20:53 2018 -0500 @@ -0,0 +1,56 @@ +--- +title: 'Skewer Trimming' +output: html_document +--- + +```{r setup, include=FALSE, warning=FALSE, message=FALSE} +knitr::opts_chunk$set( + echo = as.logical(opt$X_e), + error = TRUE +) +``` + + +# Run Skewer + +```{bash} +cd ${X_d} + +cat >temp.sh <<EOL +skewer \\ + -q ${X_A} \\ + -Q ${X_B} \\ + -x ${X_x} \\ + -y ${X_y} \\ + ${X_X} \\ + ${X_Y} \\ + -o ${X_d}/trim > /dev/null 2>&1 +EOL + +grep -v None temp.sh > skewer-job.sh + +# run skewer +sh skewer-job.sh + +cp trim-trimmed-pair1.fastq ${X_f} +cp trim-trimmed-pair2.fastq ${X_r} +mv trim-trimmed.log trim-trimmed.txt +``` + + +```{r} +# display skewer job script +skewer_sh = paste0(opt$X_d, '/skewer-job.sh') +tags$code(tags$pre(readChar(skewer_sh, file.info(skewer_sh)$size ))) +``` + +# Results + +```{r} +tags$ul( + tags$li(tags$a(href = 'trim-trimmed.txt', 'trim-trimmed.log')), + tags$li(tags$a(href = 'trim-trimmed-pair1.fastq', 'trim-trimmed-pair1.fastq')), + tags$li(tags$a(href = 'trim-trimmed-pair2.fastq', 'trim-trimmed-pair2.fastq')) +) +``` +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skewer.sh Fri Mar 02 10:20:53 2018 -0500 @@ -0,0 +1,17 @@ +Rscript '${__tool_directory__}/skewer_render.R' + + -e $echo + -o $report + -d $report.files_path + -s $sink_message + -t '${__tool_directory__}' + + -X $first_reads + -Y $second_reads + -x $adapter_x + -y $adapter_y + -A $end_quality + -B $mean_quality + + -f $trimmed_r1 + -r $trimmed_r2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skewer.xml Fri Mar 02 10:20:53 2018 -0500 @@ -0,0 +1,86 @@ +<tool id="aurora_skewer" name="Aurora Skewer" version="1.0.0"> + <description>A fast and accurate adapter trimmer for next-generation sequencing paired-end reads
 + </description> + <requirements> + <requirement type="package" version="1.15.0.6-0">pandoc</requirement> + <requirement type="package" version="1.20.0">r-getopt</requirement> + <requirement type="package" version="1.6">r-rmarkdown</requirement> + <requirement type="package" version="0.2.2">skewer</requirement> + </requirements> + <stdio> + <regex match="XXX" source="stderr" level="warning" + description="Check the warnings_and_errors.txt file for more details."/> + </stdio> + <command><![CDATA[Rscript '${__tool_directory__}/skewer_render.R' + + -e $echo + -o $report + -d $report.files_path + -s $sink_message + -t '${__tool_directory__}' + + -X $first_reads + -Y $second_reads + -x $adapter_x + -y $adapter_y + -A $end_quality + -B $mean_quality + + -f $trimmed_r1 + -r $trimmed_r2 +]]></command> + <inputs> + <param type="data" name="first_reads" label="First reads file" optional="False" format="fastq,fastqsanger"/> + <param type="data" name="second_reads" label="Second reads" optional="False" format="fastq,fastqsanger"/> + <param type="data" name="adapter_x" argument="-x" label="Adapter sequence file for the first reads" + optional="True" format="fasta,fa"/> + <param type="data" name="adapter_y" argument="-y" label="Adapter sequence file for the second reads" + optional="True" format="fasta,fa"/> + <param type="integer" name="end_quality" argument="-q" label="3’ end quality trimming" + help="Trim 3’ end until specified or higher quality reached. The default value is 0." + optional="False" value="0"/> + <param type="integer" name="mean_quality" argument="-Q" label="Reads filtering by average quality" + help="Specifies the lowest mean quality value allowed before trimming. The default value is 0." + optional="False" value="0"/> + <param type="boolean" name="echo" truevalue="TRUE" falsevalue="FALSE" checked="false" + label="Display analysis code in report?"/> + </inputs> + <outputs> + <data name="report" format="html" label="Skewer trimmed" hidden="false"/> + <data format="txt" name="sink_message" label="Warnings and Errors" from_work_dir="warnings_and_errors.txt"/> + <data name="trimmed_r1" format="fastq" label="${tool.name} trimmed first reads on ${on_string}" hidden="false"/> + <data name="trimmed_r2" format="fastq" label="${tool.name} trimmed second reads on ${on_string}" + hidden="false"/> + </outputs> + <citations> + <citation type="bibtex"><![CDATA[ + @article{allaire2016rmarkdown, + title={rmarkdown: Dynamic Documents for R, 2016}, + author={Allaire, J and Cheng, Joe and Xie, Yihui and McPherson, Jonathan and Chang, Winston and Allen, Jeff + and Wickham, Hadley and Atkins, Aron and Hyndman, Rob}, + journal={R package version 0.9}, + volume={6}, + year={2016} + } + ]]></citation> + <citation type="bibtex"><![CDATA[ + @book{xie2015dynamic, + title={Dynamic Documents with R and knitr}, + author={Xie, Yihui}, + volume={29}, + year={2015}, + publisher={CRC Press} + } + ]]></citation> + <citation type="bibtex"><![CDATA[@article{jiang2014skewer, + title={Skewer: a fast and accurate adapter trimmer for next-generation sequencing paired-end reads}, + author={Jiang, Hongshan and Lei, Rong and Ding, Shou-Wei and Zhu, Shuifang}, + journal={BMC bioinformatics}, + volume={15}, + number={1}, + pages={182}, + year={2014}, + publisher={BioMed Central} +}]]></citation> + </citations> +</tool>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skewer_index.Rmd Fri Mar 02 10:20:53 2018 -0500 @@ -0,0 +1,16 @@ +--- +title: "Analysis Report" +output: html_document +--- + +```{r setup, include=FALSE, warning=FALSE, message=FALSE} +knitr::opts_chunk$set(echo = TRUE, error = TRUE) +``` + +# Skewer + +**A fast and accurate adapter trimmer for next-generation sequencing paired-end reads**. + +# References + +Jiang, Hongshan, et al. "Skewer: a fast and accurate adapter trimmer for next-generation sequencing paired-end reads." BMC bioinformatics 15.1 (2014): 182. \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skewer_render.R Fri Mar 02 10:20:53 2018 -0500 @@ -0,0 +1,82 @@ +##============ Sink warnings and errors to a file ============== +## use the sink() function to wrap all code within it. +##============================================================== +zz = file('warnings_and_errors.txt') +sink(zz) +sink(zz, type = 'message') + +#------------import libraries-------------------- +options(stringsAsFactors = FALSE) + +library(getopt) +library(rmarkdown) +library(htmltools) +#------------------------------------------------ + + +#------------get arguments into R-------------------- +# library(dplyr) +# getopt_specification_matrix(extract_short_flags('skewer.xml')) %>% +# write.table(file = 'spec.txt', sep = ',', row.names = FALSE, col.names = TRUE, quote = FALSE) + + +spec_matrix = as.matrix( + data.frame(stringsAsFactors=FALSE, + long_flags = c("X_e", "X_o", "X_d", "X_s", "X_t", "X_X", "X_Y", + "X_x", "X_y", "X_A", "X_B", "X_f", "X_r"), + short_flags = c("e", "o", "d", "s", "t", "X", "Y", "x", "y", "A", + "B", "f", "r"), + argument_mask_flags = c(1L, 1L, 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", + "character", "character") + ) +) +opt = getopt(spec_matrix) +#---------------------------------------------------- + + +#-----------using passed arguments in R +# to define system environment variables--- +do.call(Sys.setenv, opt[-1]) +#---------------------------------------------------- + +#---------- often used variables ---------------- +# OUTPUT_REPORT: path to galaxy output report +# OUTPUT_DIR: path to the output associated directory, which stores all outputs +# TOOL_DIR: path to the tool installation directory +OUTPUT_DIR = opt$X_d +TOOL_DIR = opt$X_t +OUTPUT_REPORT = opt$X_o + + +# create the output associated directory to store all outputs +dir.create(OUTPUT_DIR, recursive = TRUE) + +#-----------------render site-------------- +# copy site generating materials into OUTPUT_DIR +dir.create(paste0(OUTPUT_DIR, '/site_generator'), recursive = TRUE) +system(paste0('cp -r ', TOOL_DIR, '/skewer.Rmd ', OUTPUT_DIR, '/site_generator/skewer.Rmd')) +system(paste0('cp -r ', TOOL_DIR, '/skewer_site.yml ', OUTPUT_DIR, '/site_generator/_site.yml')) +system(paste0('cp -r ', TOOL_DIR, '/skewer_index.Rmd ', OUTPUT_DIR, '/site_generator/index.Rmd')) +# render site to OUTPUT_DIR/_site, this is configured in the "_site.yml" file +render_site(input = paste0(OUTPUT_DIR, '/site_generator')) +# remove site generating materials from output associated directory +unlink(paste0(OUTPUT_DIR, '//site_generator'), recursive = TRUE) +# move _site/* into output associated directory +move_cmd = paste0('mv ', OUTPUT_DIR, '/_site/* ', OUTPUT_DIR) +system(move_cmd) +#------------------------------------------ + +#-----link index.html to output----- +cp_index = paste0('cp ', OUTPUT_DIR, '/index.html ', OUTPUT_REPORT) +system(cp_index) +#----------------------------------- + +#==============the end============== + + +##--------end of code rendering .Rmd templates---------------- +sink() +##=========== End of sinking output============================= \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/skewer_site.yml Fri Mar 02 10:20:53 2018 -0500 @@ -0,0 +1,15 @@ +name: "Analysis Report" +output_dir: "../_site" +navbar: + title: "" + type: inverse + left: + - text: "Home" + icon: fa-home + href: index.html + - text: "Skewer Trimming" + href: skewer.html +output: + html_document: + theme: cosmo + highlight: textmate \ No newline at end of file