GATK VARIANTANNOTATOR
Run gatk VariantAnnotator.
URL: https://gatk.broadinstitute.org/hc/en-us/articles/9570271608219-VariantAnnotator
Example
This wrapper can be used in the following way:
rule gatk_annotator:
input:
vcf="calls/snvs.vcf.gz",
aln="mapped/a.bam",
bai="mapped/a.bam.bai",
ref="genome.fasta",
db="calls/snvs.vcf.gz",
# intervals="targets.bed",
output:
vcf="snvs.annot.vcf",
log:
"logs/gatk/annotator/snvs.log",
params:
extra="--resource-allele-concordance -A Coverage --expression db.END",
java_opts="", # optional
resources:
mem_mb=1024,
wrapper:
"v5.0.1/bio/gatk/variantannotator"
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 java_opts param allows for additional arguments to be passed to the java compiler, e.g. “-XX:ParallelGCThreads=10” (not for -XmX or -Djava.io.tmpdir, since they are handled automatically).
The extra param allows for additional program arguments.
Software dependencies
gatk4=4.6.1.0
snakemake-wrapper-utils=0.6.2
Input/Output
Input:
VCF file
BAM file
reference genome
VCF of known variation
Output:
annotated VCF file
Code
__author__ = "Filipe G. Vieira"
__copyright__ = "Copyright 2022, Filipe G. Vieira"
__license__ = "MIT"
import tempfile
from snakemake.shell import shell
from snakemake_wrapper_utils.java import get_java_opts
extra = snakemake.params.get("extra", "")
java_opts = get_java_opts(snakemake)
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
input = snakemake.input.get("aln", "")
if input:
input = f"--input {input}"
reference = snakemake.input.get("ref", "")
if reference:
reference = f"--reference {reference}"
dbsnp = snakemake.input.get("known", "")
if dbsnp:
dbsnp = f"--dbsnp {dbsnp}"
intervals = snakemake.input.get("intervals", "")
if not intervals:
intervals = snakemake.params.get("intervals", "")
if intervals:
intervals = "--intervals {}".format(intervals)
resources = [
f"--resource:{name} {file}"
for name, file in snakemake.input.items()
if name not in ["vcf", "aln", "ref", "known", "intervals", "bai"]
]
with tempfile.TemporaryDirectory() as tmpdir:
shell(
"gatk --java-options '{java_opts}' VariantAnnotator"
" --variant {snakemake.input.vcf}"
" {input}"
" {reference}"
" {dbsnp}"
" {intervals}"
" {resources}"
" {extra}"
" --tmp-dir {tmpdir}"
" --output {snakemake.output.vcf}"
" {log}"
)