SAMTOOLS FLAGSTAT

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

Use samtools to create a flagstat file from a bam or sam file.

Example

This wrapper can be used in the following way:

rule samtools_flagstat:
    input:
        "mapped/{sample}.bam",
    output:
        "mapped/{sample}.bam.flagstat",
    log:
        "{sample}.log",
    params:
        extra="",  # optional params string
    wrapper:
        "v3.10.2-32-gf4e5b66/bio/samtools/flagstat"

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

Software dependencies

  • samtools=1.20

  • snakemake-wrapper-utils=0.6.2

Input/Output

Input:

  • bam or sam file (.bam,.sam)

Output:

  • flagstat file (.flagstat)

Authors

  • Christopher Preusch

  • Filipe G. Vieira

Code

__author__ = "Christopher Preusch"
__copyright__ = "Copyright 2017, Christopher Preusch"
__email__ = "cpreusch[at]ust.hk"
__license__ = "MIT"


from snakemake.shell import shell
from snakemake_wrapper_utils.samtools import get_samtools_opts

samtools_opts = get_samtools_opts(
    snakemake, parse_write_index=False, parse_output=False, parse_output_format=False
)
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=False, stderr=True)

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