BCFTOOLS MPILEUP

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

Generate VCF or BCF containing genotype likelihoods for one or multiple alignment (BAM or CRAM) files.

URL: http://www.htslib.org/doc/bcftools.html#mpileup

Example

This wrapper can be used in the following way:

rule bcftools_mpileup:
    input:
        alignments=["mapped/{sample}.bam", "mapped/{sample}.bam"],
        ref="genome.fasta",  # this can be left out if --no-reference is in options
        index="genome.fasta.fai",
    output:
        pileup="pileups/{sample}.pileup.bcf",
    params:
        uncompressed_bcf=False,
        extra="--max-depth 100 --min-BQ 15",
    log:
        "logs/bcftools_mpileup/{sample}.log",
    wrapper:
        "v3.7.0/bio/bcftools/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

  • bcftools=1.19

  • snakemake-wrapper-utils=0.6.2

Input/Output

Input:

  • alignments: SAM/BAM/CRAM file(s)

  • ref: reference genome

  • reference genome index

Output:

  • pileup file

Params

  • uncompressed_bcf: uncompressed BCF (ignored otherwise)

  • extra: additional program arguments

Authors

  • Michael Hall

  • Filipe G. Vieira

Code

__author__ = "Michael Hall"
__copyright__ = "Copyright 2020, Michael Hall"
__email__ = "michael@mbh.sh"
__license__ = "MIT"


from snakemake.shell import shell
from snakemake_wrapper_utils.bcftools import get_bcftools_opts


extra = snakemake.params.get("extra", "")
bcftools_opts = get_bcftools_opts(
    snakemake, parse_ref=("--no-reference" not in extra), parse_memory=False
)
log = snakemake.log_fmt_shell(stdout=True, stderr=True)


class MissingReferenceError(Exception):
    pass


shell("bcftools mpileup {bcftools_opts} {extra} {snakemake.input.alignments} {log}")