BCFTOOLS CALL

Call variants with bcftools call.

URL:

Example

This wrapper can be used in the following way:

rule bcftools_call:
    input:
        pileup="{sample}.pileup.bcf",
    output:
        calls="{sample}.calls.bcf",
    params:
        caller="-m", # valid options include -c/--consensus-caller or -m/--multiallelic-caller
        options="--ploidy 1 --prior 0.001",
    log:
        "logs/bcftools_call/{sample}.log",
    wrapper:
        "v1.1.0/bio/bcftools/call"

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

Authors

  • Johannes Köster
  • Michael Hall

Code

__author__ = "Johannes Köster"
__copyright__ = "Copyright 2016, Johannes Köster"
__email__ = "koester@jimmy.harvard.edu"
__license__ = "MIT"


from snakemake.shell import shell

log = snakemake.log_fmt_shell(stdout=True, stderr=True)


class CallerOptionError(Exception):
    pass


valid_caller_opts = {"-c", "--consensus-caller", "-m", "--multiallelic-caller"}

caller_opt = snakemake.params.get("caller", "")
if caller_opt.strip() not in valid_caller_opts:
    raise CallerOptionError(
        "bcftools call expects either -m/--multiallelic-caller or "
        "-c/--consensus-caller as caller option."
    )

options = snakemake.params.get("options", "")

shell(
    "bcftools call {options} {caller_opt} --threads {snakemake.threads} "
    "-o {snakemake.output.calls} {snakemake.input.pileup} "
    "{log}"
)