bcftools bcftools filter

bcftools filter

Version:
1.11
Identifier: TL_6b0c16_b2.cb
Tool
1__author__ = "Patrik Smeds"
2__copyright__ = "Copyright 2021, Patrik Smeds"
3__email__ = "patrik.smeds@scilifelab.uu.se"
4__license__ = "MIT"
5
6
7from snakemake.shell import shell
8
9log = snakemake.log_fmt_shell(stdout=False, stderr=True)
10
11if snakemake.output[0].endswith("bcf"):
12    output_format = "-Ou"
13elif snakemake.output[0].endswith("bcf.gz"):
14    output_format = "-Ob"
15elif snakemake.output[0].endswith("vcf"):
16    output_format = "-Ov"
17elif snakemake.output[0].endswith("vcf.gz"):
18    output_format = "-Oz"
19
20
21if len(snakemake.input) > 1:
22    raise Exception("Only one input file expected, got: " + str(len(snakemake.input)))
23
24if len(snakemake.output) > 1:
25    raise Exception("Only one output file expected, got: " + str(len(snakemake.output)))
26
27filter = snakemake.params.get("filter", "")
28extra = snakemake.params.get("extra", "")
29
30shell(
31    "bcftools filter {filter} {extra} {snakemake.input[0]} "
32    "{output_format} "
33    "-o {snakemake.output[0]} "
34    "{log}"
35)
36