BCFTOOLS VIEW

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

View vcf/bcf file in a different format.

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

Example

This wrapper can be used in the following way:

rule bcf_view_sample_file:
    input:
        "{prefix}.bcf",  # input bcf/vcf needs to be first input
        index="{prefix}.bcf.csi",  # other inputs are optional
        samples="samples.txt",
    output:
        "{prefix}.view_sample.vcf",
    log:
        "log/{prefix}.view_sample.vcf.log",
    params:
        # optional extra parameters
        extra=lambda w, input: f"-S {input.samples}",
    wrapper:
        "v3.9.0/bio/bcftools/view"


rule bcf_view_o_vcf:
    input:
        "{prefix}.bcf",
    output:
        "{prefix}.view.vcf",
    log:
        "log/{prefix}.view.vcf.log",
    params:
        extra="",
    wrapper:
        "v3.9.0/bio/bcftools/view"


rule bcf_view_o_vcf_gz:
    input:
        "{prefix}.bcf",
    output:
        "{prefix}.view.vcf.gz",
    log:
        "log/{prefix}.view.vcf.gz.log",
    params:
        extra="",
    wrapper:
        "v3.9.0/bio/bcftools/view"


rule bcf_view_o_bcf:
    input:
        "{prefix}.bcf",
    output:
        "{prefix}.view.bcf",
    log:
        "log/{prefix}.view.bcf.log",
    params:
        extra="",
    wrapper:
        "v3.9.0/bio/bcftools/view"


rule bcf_view_o_uncompressed_bcf:
    input:
        "{prefix}.bcf",
    output:
        "{prefix}.view.uncompressed.bcf",
    log:
        "log/{prefix}.view.uncompressed.bcf.log",
    params:
        uncompressed_bcf=True,
        extra="",
    wrapper:
        "v3.9.0/bio/bcftools/view"

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 uncompressed_bcf param allows to specify that a BCF output should be uncompressed (ignored otherwise).

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

Software dependencies

  • bcftools=1.20

  • snakemake-wrapper-utils=0.6.2

Input/Output

Input:

  • VCF/BCF file

Output:

  • Filtered VCF/BCF file

Authors

  • Johannes Köster

  • Nikos Tsardakas Renhuldt

  • 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_memory=False)
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)

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