CUTADAPT-SE

https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/cutadapt/se?label=version%20update%20pull%20requests

Trim single-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}.fastq",
    output:
        fastq="trimmed/{sample}.fastq",
        qc="trimmed/{sample}.qc.txt",
    params:
        adapters="-a AGATCGGAAGAGCACACGTCTGAACTCCAGTCAC",
        extra="-q 20",
    log:
        "logs/cutadapt/{sample}.log",
    threads: 4  # set desired number of threads here
    wrapper:
        "v3.8.0-49-g6f33607/bio/cutadapt/se"

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.8

Input/Output

Input:

  • fastq file

Output:

  • trimmed fastq file

  • text file containing trimming statistics

Authors

  • Julian de Ruiter

Code

"""Snakemake wrapper for trimming single-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 == 1, "Input must contain 1 (single-end) element."

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.fastq}"
    " {snakemake.input[0]}"
    " > {snakemake.output.qc} {log}"
)