SAMTOOLS STATS

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

Generate stats using samtools.

URL: http://www.htslib.org/doc/samtools-stats.html

Example

This wrapper can be used in the following way:

rule samtools_stats:
    input:
        bam="mapped/{sample}.bam",
        bed="design.bed",  #Optional input, specify target regions
    output:
        "samtools_stats/{sample}.txt",
    params:
        extra="",  # Optional: extra arguments.
        region="xx:1000000-2000000",  # Optional: region string.
    log:
        "logs/samtools_stats/{sample}.log",
    wrapper:
        "v3.8.0-49-g6f33607/bio/samtools/stats"

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.

Software dependencies

  • samtools=1.19.2

  • snakemake-wrapper-utils=0.6.2

Input/Output

Input:

  • SAM/BAM/CRAM file

Output:

  • statistics file

Params

  • extra: additional program arguments (not -@/–threads).

Authors

  • Julian de Ruiter

  • Filipe G. Vieira

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
from snakemake_wrapper_utils.samtools import get_samtools_opts


bed = snakemake.input.get("bed", "")
if bed:
    bed = f"-t {bed}"

samtools_opts = get_samtools_opts(
    snakemake, parse_write_index=False, parse_output=False, parse_output_format=False
)


extra = snakemake.params.get("extra", "")
region = snakemake.params.get("region", "")
log = snakemake.log_fmt_shell(stdout=False, stderr=True)


shell(
    "samtools stats {samtools_opts} {extra} {snakemake.input[0]} {bed} {region} > {snakemake.output[0]} {log}"
)