BCFTOOLS SORT
Sort vcf/bcf file.
URL: http://www.htslib.org/doc/bcftools.html#sort
Example
This wrapper can be used in the following way:
rule bcftools_sort:
input:
"{sample}.bcf",
output:
"{sample}.sorted.bcf",
log:
"logs/bcftools/sort/{sample}.log",
params:
# Set to True, in case you want uncompressed BCF output
uncompressed_bcf=False,
# Extra arguments
extras="",
resources:
mem_mb=8000,
wrapper:
"v5.8.0/bio/bcftools/sort"
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, -O/–output-type, -m/–max-mem, or -T/–temp-dir).
Software dependencies
bcftools=1.21
snakemake-wrapper-utils=0.6.2
Code
__author__ = "Filipe G. Vieira"
__copyright__ = "Copyright 2020, Filipe G. Vieira"
__license__ = "MIT"
import tempfile
from snakemake.shell import shell
from snakemake_wrapper_utils.bcftools import get_bcftools_opts
bcftools_opts = get_bcftools_opts(snakemake, parse_ref=False)
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
with tempfile.TemporaryDirectory() as tmpdir:
shell(
"bcftools sort"
" {bcftools_opts}"
" {extra}"
" --temp-dir {tmpdir}"
" {snakemake.input[0]}"
" {log}"
)