GATK3 PRINTREADS

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

Run gatk3 PrintReads

Example

This wrapper can be used in the following way:

rule printreads:
    input:
        bam="{sample}.bam",
        bai="{sample}.bai",
#        recal_data="{sample}.recal_data_table",
        ref="genome.fasta",
        fai="genome.fasta.fai",
        dict="genome.dict",
    output:
        bam="{sample}.bqsr.bam",
        bai="{sample}.bqsr.bai",
    log:
        "logs/gatk/bqsr/{sample}.log",
    params:
        extra="--defaultBaseQualities 20 --filter_reads_with_N_cigar",  # optional
    resources:
        mem_mb=1024,
    threads: 16
    wrapper:
        "v3.8.0-49-g6f33607/bio/gatk3/printreads"

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. “-Xmx4G” for one, and “-Xmx4G -XX:ParallelGCThreads=10” for two options.

  • The extra param allows for additional program arguments.

  • For more information see, https://software.broadinstitute.org/gatk/documentation/article?id=11050

  • Gatk3.jar is not included in the bioconda package, i.e it need to be added to the conda environment manually.

Software dependencies

  • gatk=3.8

  • python=3.12.2

  • snakemake-wrapper-utils=0.6.2

Input/Output

Input:

  • bam file

  • recalibration table

  • reference genome

Output:

  • bam file

Authors

  • Patrik Smeds

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)


bqsr = snakemake.input.get("recal_data", "")
if bqsr:
    bqsr = f"--BQSR {bqsr}"


shell(
    "gatk3 {java_opts}"
    " --analysis_type PrintReads"
    " --input_file {snakemake.input.bam}"
    " --reference_sequence {snakemake.input.ref}"
    " {bqsr}"
    " {extra}"
    " --out {snakemake.output.bam}"
    " {log}"
)