GATK MUTECT2¶
Call somatic SNVs and indels via local assembly of haplotypes
URL:
Example¶
This wrapper can be used in the following way:
rule mutect2:
input:
fasta = "genome/genome.fasta",
map = "mapped/{sample}.bam"
output:
vcf = "variant/{sample}.vcf"
message:
"Testing Mutect2 with {wildcards.sample}"
threads:
1
# optional specification of memory usage of the JVM that snakemake will respect with global
# resource restrictions (https://snakemake.readthedocs.io/en/latest/snakefiles/rules.html#resources)
# and which can be used to request RAM during cluster job submission as `{resources.mem_mb}`:
# https://snakemake.readthedocs.io/en/latest/executing/cluster.html#job-properties
resources:
mem_mb=1024
log:
"logs/mutect_{sample}.log"
wrapper:
"v1.1.0/bio/gatk/mutect"
rule mutect2_bam:
input:
fasta = "genome/genome.fasta",
map = "mapped/{sample}.bam"
output:
vcf = "variant_bam/{sample}.vcf",
bam = "variant_bam/{sample}.bam"
message:
"Testing Mutect2 with {wildcards.sample}"
threads:
1
# optional specification of memory usage of the JVM that snakemake will respect with global
# resource restrictions (https://snakemake.readthedocs.io/en/latest/snakefiles/rules.html#resources)
# and which can be used to request RAM during cluster job submission as `{resources.mem_mb}`:
# https://snakemake.readthedocs.io/en/latest/executing/cluster.html#job-properties
resources:
mem_mb=1024
log:
"logs/mutect_{sample}.log"
wrapper:
"v1.1.0/bio/gatk/mutect"
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.
Software dependencies¶
gatk4==4.1.4.1
snakemake-wrapper-utils==0.1.3
Authors¶
- Thibault Dayris
Code¶
"""Snakemake wrapper for GATK4 Mutect2"""
__author__ = "Thibault Dayris"
__copyright__ = "Copyright 2019, Dayris Thibault"
__email__ = "thibault.dayris@gustaveroussy.fr"
__license__ = "MIT"
from snakemake.shell import shell
from snakemake.utils import makedirs
from snakemake_wrapper_utils.java import get_java_opts
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
bam_output = "--bam-output"
if snakemake.output.get("bam", None) is not None:
bam_output = bam_output + " " + snakemake.output.bam
else:
bam_output = ""
extra = snakemake.params.get("extra", "")
java_opts = get_java_opts(snakemake)
shell(
"gatk --java-options '{java_opts}' Mutect2 " # Tool and its subprocess
"--input {snakemake.input.map} " # Path to input mapping file
"{bam_output} " # Path to output bam file, optional
"--output {snakemake.output.vcf} " # Path to output vcf file
"--reference {snakemake.input.fasta} " # Path to reference fasta file
"{extra} " # Extra parameters
"{log}" # Logging behaviour
)