GATK3 REALIGNERTARGETCREATOR

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

Run gatk3 RealignerTargetCreator

Example

This wrapper can be used in the following way:

rule realignertargetcreator:
    input:
        bam="{sample}.bam",
        bai="{sample}.bai",
        ref="genome.fasta",
        fai="genome.fasta.fai",
        dict="genome.dict",
        known="dbsnp.vcf.gz",
        known_idx="dbsnp.vcf.gz.tbi",
    output:
        intervals="{sample}.intervals",
    log:
        "logs/gatk/realignertargetcreator/{sample}.log",
    params:
        extra="--defaultBaseQualities 20 --filter_reads_with_N_cigar",  # optional
    resources:
        mem_mb=1024,
    threads: 16
    wrapper:
        "v1.21.4-1-g701abe08/bio/gatk3/realignertargetcreator"

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

Software dependencies

  • gatk=3.8
  • python=3.11.0
  • snakemake-wrapper-utils=0.5.0

Input/Output

Input:

  • bam file
  • reference genome
  • bed file (optional)
  • vcf files known variation (optional)

Output:

  • target intervals
  • temp dir (optional)

Authors

  • Patrik Smeds
  • Filipe G. Vieira

Code

__author__ = "Patrik Smeds"
__copyright__ = "Copyright 2019, Patrik Smeds"
__email__ = "patrik.smeds@gmail.com.com"
__license__ = "MIT"

import os

from snakemake.shell import shell
from snakemake_wrapper_utils.java import get_java_opts

extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
java_opts = get_java_opts(snakemake)


bed = snakemake.input.get("bed", "")
if bed:
    bed = f"--intervals {bed}"


known = snakemake.input.get("known", "")
if known:
    if isinstance(known, str):
        known = f"--known {known}"
    else:
        known = list(map("--known {}".format, known))


shell(
    "gatk3 {java_opts}"
    " --analysis_type RealignerTargetCreator"
    " --num_threads {snakemake.threads}"
    " --input_file {snakemake.input.bam}"
    " --reference_sequence {snakemake.input.ref}"
    " {known}"
    " {bed}"
    " {extra}"
    " --out {snakemake.output.intervals}"
    " {log}"
)