SAMTOOLS MPILEUP

https://img.shields.io/badge/wrapper_version-v7.3.0-10785b https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/samtools/mpileup?label=version%20update%20pull%20requests&color=1cb481

Generate pileup using samtools.

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

Example

This wrapper can be used in the following way:

rule mpileup:
    input:
        # single or list of bam files
        bam="mapped/{sample}.bam",
        ref="genome.fasta",
    output:
        "mpileup/{sample}.mpileup.gz",
    log:
        "logs/samtools/mpileup/{sample}.log",
    params:
        extra="-d 10000",  # optional
    wrapper:
        "v7.3.0/bio/samtools/mpileup"

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

  • pigz=2.8

Input/Output

Input:

  • bam: input SAM/BAM/CRAM file

  • ref: input reference genome FASTA file

Output:

  • Output mpileup file (gzip’ed)

Params

  • extra: additional program arguments.

Authors

  • Patrik Smeds

  • Filipe G. Vieira

Code

"""Snakemake wrapper for running mpileup."""

__author__ = "Julian de Ruiter"
__copyright__ = "Copyright 2017, Julian de Ruiter"
__email__ = "julianderuiter@gmail.com"
__license__ = "MIT"


from snakemake.shell import shell

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

if not snakemake.output[0].endswith(".gz"):
    raise Exception(
        'output file will be compressed and therefore filename should end with ".gz"'
    )

shell(
    "(samtools mpileup {extra} -f {snakemake.input.ref} {snakemake.input.bam} | pigz > {snakemake.output}) {log}"
)