Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: gatk Learnreadorientationmodel #523

Merged
merged 14 commits into from
Aug 16, 2022
Merged
7 changes: 7 additions & 0 deletions bio/gatk/learnreadorientationmodel/environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
channels:
- bioconda
- conda-forge
- defaults
dependencies:
- gatk4 =4.2
- snakemake-wrapper-utils =0.3
12 changes: 12 additions & 0 deletions bio/gatk/learnreadorientationmodel/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: GATK LearnOrientationModel
url: https://gatk.broadinstitute.org/hc/en-us/articles/4405451237147-LearnReadOrientationModel
description: Get the maximum likelihood estimates of artifact prior probabilities in the orientation bias mixture model filter
authors:
- Thibault Dayris
input:
- f1r2: Path to one or multiple f1r2 files
output:
- Path to tar.gz of artifact prior tables
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.
13 changes: 13 additions & 0 deletions bio/gatk/learnreadorientationmodel/test/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rule test_gatk_learnreadorientationmodel:
input:
f1r2="f1r2.tar.gz",
output:
"artifacts_prior.tar.gz",
resources:
mem_mb=1024,
params:
extra="",
log:
"learnreadorientationbias.log",
wrapper:
"master/bio/gatk/learnreadorientationmodel"
Binary file not shown.
36 changes: 36 additions & 0 deletions bio/gatk/learnreadorientationmodel/wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# coding: utf-8

"""Snakemake wrapper for GATK4 LearnReadOrientationModel"""

__author__ = "Thibault Dayris"
__copyright__ = "Copyright 2022, Dayris Thibault"
__email__ = "[email protected]"
__license__ = "MIT"

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

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

f1r2 = "--input "
if isinstance(snakemake.input["f1r2"], list):
# Case user provided a list of archives
f1r2 += "--input ".join(snakemake.input["f1r2"])
else:
# Case user provided a single archive as a string
f1r2 += snakemake.input["f1r2"]


with tempfile.TemporaryDirectory() as tmpdir:
shell(
"gatk --java-options '{java_opts}' LearnReadOrientationModel" # Tool and its subprocess
" {f1r2}" # Path to input mapping file
" {extra}" # Extra parameters
" --tmp-dir {tmpdir}"
" --output {snakemake.output[0]}" # Path to output vcf file
" {log}" # Logging behaviour
)
8 changes: 8 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3395,6 +3395,14 @@ def test_gatk_mutect():
)


@skip_if_not_modified
def test_gatk_learn_read_orientation():
run(
"bio/gatk/learnreadorientationmodel",
["snakemake", "--cores", "1", "--use-conda"]
)


@skip_if_not_modified
def test_gatk_mutect_bam():
run(
Expand Down