Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added GATK variantAnnotator wrapper (#462)
* Added GATK variantAnnotator wrapper * BGziped VCF * Fixed typo * Added intervals to example Snakefile
- Loading branch information
Showing
14 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: gatk VariantAnnotator | ||
description: | | ||
Run gatk VariantAnnotator. | ||
authors: | ||
- Filipe G. Vieira | ||
input: | ||
- VCF file | ||
- BAM file | ||
- reference genome | ||
- VCF of known variation | ||
output: | ||
- annotated VCF file | ||
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. | ||
* For more information see, https://gatk.broadinstitute.org/hc/en-us/articles/4418054223003-VariantAnnotator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
rule gatk_annotator: | ||
input: | ||
vcf="calls/snvs.vcf.gz", | ||
aln="mapped/a.bam", | ||
ref="genome.fasta", | ||
db="calls/snvs.vcf.gz", | ||
# intervals="targets.bed", | ||
output: | ||
vcf="snvs.annot.vcf", | ||
log: | ||
"logs/gatk/annotator/snvs.log", | ||
params: | ||
extra="--resource-allele-concordance -A Coverage --expression db.END", | ||
java_opts="", # optional | ||
resources: | ||
mem_mb=1024, | ||
wrapper: | ||
"master/bio/gatk/variantannotator" |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@HD VN:1.5 | ||
@SQ SN:ref LN:45 M5:7a66cae8ab14aef8d635bc80649e730b UR:file:/home/johannes/scms/snakemake-wrappers/bio/picard/createsequencedictionary/test/genome.fasta | ||
@SQ SN:ref2 LN:40 M5:1636753510ec27476fdd109a6684680e UR:file:/home/johannes/scms/snakemake-wrappers/bio/picard/createsequencedictionary/test/genome.fasta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
>ref | ||
AGCATGTTAGATAAGATAGCTGTGCTAGTAGGCAGTCAGCGCCAT | ||
>ref2 | ||
aggttttataaaacaattaagtctacagagcaactacgcg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ref 45 5 45 46 | ||
ref2 40 57 40 41 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
__author__ = "Filipe G. Vieira" | ||
__copyright__ = "Copyright 2022, Filipe G. Vieira" | ||
__license__ = "MIT" | ||
|
||
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) | ||
log = snakemake.log_fmt_shell(stdout=True, stderr=True) | ||
|
||
|
||
input = snakemake.input.get("aln", "") | ||
if input: | ||
input = f"--input {input}" | ||
|
||
reference = snakemake.input.get("ref", "") | ||
if reference: | ||
reference = f"--reference {reference}" | ||
|
||
dbsnp = snakemake.input.get("known", "") | ||
if dbsnp: | ||
dbsnp = f"--dbsnp {dbsnp}" | ||
|
||
intervals = snakemake.input.get("intervals", "") | ||
if not intervals: | ||
intervals = snakemake.params.get("intervals", "") | ||
if intervals: | ||
intervals = "--intervals {}".format(intervals) | ||
|
||
resources = [ | ||
f"--resource:{name} {file}" | ||
for name, file in snakemake.input.items() | ||
if name not in ["vcf", "aln", "ref", "known", "intervals"] | ||
] | ||
|
||
|
||
with tempfile.TemporaryDirectory() as tmpdir: | ||
shell( | ||
"gatk --java-options '{java_opts}' VariantAnnotator" | ||
" --variant {snakemake.input.vcf}" | ||
" {input}" | ||
" {reference}" | ||
" {dbsnp}" | ||
" {intervals}" | ||
" {resources}" | ||
" {extra}" | ||
" --tmp-dir {tmpdir}" | ||
" --output {snakemake.output.vcf}" | ||
" {log}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters