GATK GENOMICSDBIMPORT

Run gatk GenomicsDBImport.

Example

This wrapper can be used in the following way:

rule genomics_db_import:
    input:
        gvcfs=["calls/a.g.vcf.gz", "calls/b.g.vcf.gz"],
    output:
        db=directory("db"),
    log:
        "logs/gatk/genomicsdbimport.log",
    params:
        intervals="ref",
        db_action="create",  # optional
        extra="",  # optional
        java_opts="",  # optional
    resources:
        mem_mb=1024,
    wrapper:
        "v1.9.0/bio/gatk/genomicsdbimport"

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 intervals param is mandatory
  • By default, the wrapper will create a new database (output directory must be empty or non-existent). If you want to update an existing DB, set db_action param to update.
  • The extra param allows for additional program arguments.
  • For more information see, https://gatk.broadinstitute.org/hc/en-us/articles/4405451266331-GenomicsDBImport

Software dependencies

  • gatk4=4.2
  • snakemake-wrapper-utils=0.3

Input/Output

Input:

  • GVCF files of multiple samples

Output:

  • A GenomicsDB workspace

Authors

  • Filipe G. Vieira

Code

__author__ = "Filipe G. Vieira"
__copyright__ = "Copyright 2021, Filipe G. Vieira"
__license__ = "MIT"


import os
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)

gvcfs = list(map("--variant {}".format, snakemake.input.gvcfs))

db_action = snakemake.params.get("db_action", "create")
if db_action == "create":
    db_action = "--genomicsdb-workspace-path"
elif db_action == "update":
    db_action = "--genomicsdb-update-workspace-path"
else:
    raise ValueError(
        "invalid option provided to 'params.db_action'; please choose either 'create' or 'update'."
    )

intervals = snakemake.input.get("intervals")
if not intervals:
    intervals = snakemake.params.get("intervals")

log = snakemake.log_fmt_shell(stdout=True, stderr=True)

with tempfile.TemporaryDirectory() as tmpdir:
    shell(
        "gatk --java-options '{java_opts}' GenomicsDBImport"
        " {gvcfs}"
        " --intervals {intervals}"
        " {extra}"
        " --tmp-dir {tmpdir}"
        " {db_action} {snakemake.output.db}"
        " {log}"
    )