CUTADAPT-PE
Trim paired-end reads using cutadapt.
URL: https://github.com/marcelm/cutadapt
Example
This wrapper can be used in the following way:
rule cutadapt:
input:
["reads/{sample}.1.fastq", "reads/{sample}.2.fastq"],
output:
fastq1="trimmed/{sample}.1.fastq",
fastq2="trimmed/{sample}.2.fastq",
qc="trimmed/{sample}.qc.txt",
params:
# https://cutadapt.readthedocs.io/en/stable/guide.html#adapter-types
adapters="-a AGAGCACACGTCTGAACTCCAGTCAC -g AGATCGGAAGAGCACACGT -A AGAGCACACGTCTGAACTCCAGTCAC -G AGATCGGAAGAGCACACGT",
# https://cutadapt.readthedocs.io/en/stable/guide.html#
extra="--minimum-length 1 -q 20",
log:
"logs/cutadapt/{sample}.log",
threads: 4 # set desired number of threads here
wrapper:
"v4.6.0/bio/cutadapt/pe"
Note that input, output and log file paths can be chosen freely.
When running with
snakemake --use-conda
the software dependencies will be automatically deployed into an isolated environment before execution.
Notes
The extra param allows for additional program arguments.
The adapters param allows for separatelly specifying adapter options (optional).
Software dependencies
cutadapt=4.9
Input/Output
Input:
two (paired-end) fastq files
Output:
two trimmed (paired-end) fastq files
text file containing trimming statistics
Code
"""Snakemake wrapper for trimming paired-end reads using cutadapt."""
__author__ = "Julian de Ruiter"
__copyright__ = "Copyright 2017, Julian de Ruiter"
__email__ = "julianderuiter@gmail.com"
__license__ = "MIT"
from snakemake.shell import shell
n = len(snakemake.input)
assert n == 2, "Input must contain 2 (paired-end) elements."
extra = snakemake.params.get("extra", "")
adapters = snakemake.params.get("adapters", "")
log = snakemake.log_fmt_shell(stdout=False, stderr=True)
assert (
extra != "" or adapters != ""
), "No options provided to cutadapt. Please use 'params: adapters=' or 'params: extra='."
shell(
"cutadapt"
" --cores {snakemake.threads}"
" {adapters}"
" {extra}"
" -o {snakemake.output.fastq1}"
" -p {snakemake.output.fastq2}"
" {snakemake.input}"
" > {snakemake.output.qc} {log}"
)