BCFTOOLS INDEX

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

Index vcf/bcf file.

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

Example

This wrapper can be used in the following way:

rule bcftools_index:
    input:
        "a.bcf",
    output:
        "a.bcf.csi",
    log:
        "index/a.log",
    params:
        extra="",  # optional parameters for bcftools index
    wrapper:
        "v3.9.0-1-gc294552/bio/bcftools/index"

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

  • The extra param allows for additional program arguments (not –threads, -o/–output).

Software dependencies

  • bcftools=1.20

  • snakemake-wrapper-utils=0.6.2

Authors

  • Jan Forster

  • Filipe G. Vieira

Code

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


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


bcftools_opts = get_bcftools_opts(
    snakemake, parse_ref=False, parse_output_format=False, parse_memory=False
)
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)


if "--tbi" in extra or "--csi" in extra:
    raise ValueError(
        "You have specified index format (`--tbi/--csi`) in `params.extra`; this is automatically infered from the first output file."
    )

if snakemake.output[0].endswith(".tbi"):
    extra += " --tbi"
elif snakemake.output[0].endswith(".csi"):
    extra += " --csi"
else:
    raise ValueError("invalid index file format ('.tbi', '.csi').")


shell("bcftools index {bcftools_opts} {extra} {snakemake.input[0]} {log}")