From fe9e4ece00c03c1082e0c9f911cf1f2fdc065941 Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Thu, 9 Jun 2022 14:56:55 +0200 Subject: [PATCH 1/5] new module gatk4/reblockgvcf --- modules/gatk4/reblockgvcf/main.nf | 52 +++++++++++++ modules/gatk4/reblockgvcf/meta.yml | 74 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 + tests/modules/gatk4/reblockgvcf/main.nf | 55 ++++++++++++++ .../modules/gatk4/reblockgvcf/nextflow.config | 5 ++ tests/modules/gatk4/reblockgvcf/test.yml | 32 ++++++++ 6 files changed, 222 insertions(+) create mode 100644 modules/gatk4/reblockgvcf/main.nf create mode 100644 modules/gatk4/reblockgvcf/meta.yml create mode 100644 tests/modules/gatk4/reblockgvcf/main.nf create mode 100644 tests/modules/gatk4/reblockgvcf/nextflow.config create mode 100644 tests/modules/gatk4/reblockgvcf/test.yml diff --git a/modules/gatk4/reblockgvcf/main.nf b/modules/gatk4/reblockgvcf/main.nf new file mode 100644 index 00000000..d27ac222 --- /dev/null +++ b/modules/gatk4/reblockgvcf/main.nf @@ -0,0 +1,52 @@ +process GATK4_REBLOCKGVCF { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::gatk4=4.2.6.1" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/gatk4:4.2.6.1--hdfd78af_0': + 'quay.io/biocontainers/gatk4:4.2.6.1--hdfd78af_0' }" + + input: + tuple val(meta), path(gvcf), path(tbi), path(intervals) + path fasta + path fai + path dict + path dbsnp + path dbsnp_tbi + + output: + tuple val(meta), path("*.reblock.g.vcf.gz"), path("*.tbi") , emit: bam + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def dbsnp_command = dbsnp ? "--dbsnp $dbsnp" : "" + def interval_command = intervals ? "--intervals $intervals" : "" + + def avail_mem = 3 + if (!task.memory) { + log.info '[GATK ReblockGVCF] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.' + } else { + avail_mem = task.memory.giga + } + """ + gatk --java-options "-Xmx${avail_mem}g" ReblockGVCF \\ + --variant $gvcf \\ + --output ${prefix}.reblock.g.vcf.gz \\ + --reference $fasta \\ + $dbsnp_command \\ + $interval_command \\ + --tmp-dir . \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + gatk4: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//') + END_VERSIONS + """ +} diff --git a/modules/gatk4/reblockgvcf/meta.yml b/modules/gatk4/reblockgvcf/meta.yml new file mode 100644 index 00000000..407eeec2 --- /dev/null +++ b/modules/gatk4/reblockgvcf/meta.yml @@ -0,0 +1,74 @@ +name: "gatk4_reblockgvcf" +description: Condenses homRef blocks in a single-sample GVCF +keywords: + - gatk4 + - reblockgvcf + - gvcf +tools: + - gatk4: + description: | + Developed in the Data Sciences Platform at the Broad Institute, the toolkit offers a wide variety of tools + with a primary focus on variant discovery and genotyping. Its powerful processing engine + and high-performance computing features make it capable of taking on projects of any size. + homepage: https://gatk.broadinstitute.org/hc/en-us + documentation: https://gatk.broadinstitute.org/hc/en-us/categories/360002369672s + doi: 10.1158/1538-7445.AM2017-3590 + licence: ["Apache-2.0"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - gvcf: + type: file + description: GVCF file created using HaplotypeCaller using the '-ERC GVCF' or '-ERC BP_RESOLUTION' mode + pattern: "*.{vcf,gvcf}.gz" + - tbi: + type: file + description: Index of the GVCF file + pattern: "*.tbi" + - intervals: + type: file + description: Bed file with the genomic regions included in the library (optional) + - fasta: + type: file + description: The reference fasta file + pattern: "*.fasta" + - fai: + type: file + description: Index of reference fasta file + pattern: "fasta.fai" + - dict: + type: file + description: GATK sequence dictionary + pattern: "*.dict" + - dbsnp: + type: file + description: VCF file containing known sites (optional) + - dbsnp_tbi: + type: file + description: VCF index of dbsnp (optional) + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - gvcf: + type: file + description: Filtered GVCF + pattern: "*reblock.g.vcf.gz" + - tbi: + type: file + description: Index of the filtered GVCF + pattern: "*reblock.g.vcf.gz.tbi" + +authors: + - "@nvnieuwk" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index b3a5a24c..7325f02d 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -859,6 +859,10 @@ gatk4/mutect2: - modules/gatk4/mutect2/** - tests/modules/gatk4/mutect2/** +gatk4/reblockgvcf: + - modules/gatk4/reblockgvcf/** + - tests/modules/gatk4/reblockgvcf/** + gatk4/revertsam: - modules/gatk4/revertsam/** - tests/modules/gatk4/revertsam/** diff --git a/tests/modules/gatk4/reblockgvcf/main.nf b/tests/modules/gatk4/reblockgvcf/main.nf new file mode 100644 index 00000000..2233a5c5 --- /dev/null +++ b/tests/modules/gatk4/reblockgvcf/main.nf @@ -0,0 +1,55 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { GATK4_REBLOCKGVCF } from '../../../../modules/gatk4/reblockgvcf/main.nf' + +workflow test_gatk4_reblockgvcf { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true), + [] + ] + + fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + fasta_index = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true) + dict = file(params.test_data['sarscov2']['genome']['genome_dict'], checkIfExists: true) + + GATK4_REBLOCKGVCF ( input, fasta, fasta_index, dict, [], [] ) +} + +workflow test_gatk4_reblockgvcf_intervals { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true), + file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true) + ] + + fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + fasta_index = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true) + dict = file(params.test_data['sarscov2']['genome']['genome_dict'], checkIfExists: true) + + GATK4_REBLOCKGVCF ( input, fasta, fasta_index, dict, [], [] ) +} + +workflow test_gatk4_reblockgvcf_dbsnp { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_haplotc_cnn_vcf_gz'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test_haplotc_cnn_vcf_gz_tbi'], checkIfExists: true), + [] + ] + + fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + fasta_index = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true) + dict = file(params.test_data['homo_sapiens']['genome']['genome_dict'], checkIfExists: true) + dbsnp = file(params.test_data['homo_sapiens']['genome']['dbsnp_146_hg38_vcf_gz'], checkIfExists: true) + dbsnp_tbi = file(params.test_data['homo_sapiens']['genome']['dbsnp_146_hg38_vcf_gz_tbi'], checkIfExists: true) + + GATK4_REBLOCKGVCF ( input, fasta, fasta_index, dict, dbsnp, dbsnp_tbi ) +} \ No newline at end of file diff --git a/tests/modules/gatk4/reblockgvcf/nextflow.config b/tests/modules/gatk4/reblockgvcf/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/gatk4/reblockgvcf/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} \ No newline at end of file diff --git a/tests/modules/gatk4/reblockgvcf/test.yml b/tests/modules/gatk4/reblockgvcf/test.yml new file mode 100644 index 00000000..e5461341 --- /dev/null +++ b/tests/modules/gatk4/reblockgvcf/test.yml @@ -0,0 +1,32 @@ +- name: gatk4 reblockgvcf test_gatk4_reblockgvcf + command: nextflow run ./tests/modules/gatk4/reblockgvcf -entry test_gatk4_reblockgvcf -c ./tests/config/nextflow.config -c ./tests/modules/gatk4/reblockgvcf/nextflow.config + tags: + - gatk4/reblockgvcf + - gatk4 + files: + - path: output/gatk4/test.reblock.g.vcf.gz + contains: '[ # TODO nf-core: file md5sum was variable, please replace this text with a string found in the file instead ]' + - path: output/gatk4/test.reblock.g.vcf.gz.tbi + md5sum: e1aab7d826a151828fd0671ec5aed2e0 + +- name: gatk4 reblockgvcf test_gatk4_reblockgvcf_intervals + command: nextflow run ./tests/modules/gatk4/reblockgvcf -entry test_gatk4_reblockgvcf_intervals -c ./tests/config/nextflow.config -c ./tests/modules/gatk4/reblockgvcf/nextflow.config + tags: + - gatk4/reblockgvcf + - gatk4 + files: + - path: output/gatk4/test.reblock.g.vcf.gz + contains: '[ # TODO nf-core: file md5sum was variable, please replace this text with a string found in the file instead ]' + - path: output/gatk4/test.reblock.g.vcf.gz.tbi + md5sum: e7ca7e9fe76ce12198fd54ec9a64fad4 + +- name: gatk4 reblockgvcf test_gatk4_reblockgvcf_dbsnp + command: nextflow run ./tests/modules/gatk4/reblockgvcf -entry test_gatk4_reblockgvcf_dbsnp -c ./tests/config/nextflow.config -c ./tests/modules/gatk4/reblockgvcf/nextflow.config + tags: + - gatk4/reblockgvcf + - gatk4 + files: + - path: output/gatk4/test.reblock.g.vcf.gz + contains: '[ # TODO nf-core: file md5sum was variable, please replace this text with a string found in the file instead ]' + - path: output/gatk4/test.reblock.g.vcf.gz.tbi + md5sum: 017edea27a253eb51cc4505d00dcb295 From 14d38e43cf00c42a09a9b6e80914daa0ef135de1 Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Thu, 9 Jun 2022 14:58:20 +0200 Subject: [PATCH 2/5] fix test.yml --- tests/modules/gatk4/reblockgvcf/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/modules/gatk4/reblockgvcf/test.yml b/tests/modules/gatk4/reblockgvcf/test.yml index e5461341..97f1515f 100644 --- a/tests/modules/gatk4/reblockgvcf/test.yml +++ b/tests/modules/gatk4/reblockgvcf/test.yml @@ -5,7 +5,6 @@ - gatk4 files: - path: output/gatk4/test.reblock.g.vcf.gz - contains: '[ # TODO nf-core: file md5sum was variable, please replace this text with a string found in the file instead ]' - path: output/gatk4/test.reblock.g.vcf.gz.tbi md5sum: e1aab7d826a151828fd0671ec5aed2e0 @@ -16,7 +15,6 @@ - gatk4 files: - path: output/gatk4/test.reblock.g.vcf.gz - contains: '[ # TODO nf-core: file md5sum was variable, please replace this text with a string found in the file instead ]' - path: output/gatk4/test.reblock.g.vcf.gz.tbi md5sum: e7ca7e9fe76ce12198fd54ec9a64fad4 @@ -27,6 +25,5 @@ - gatk4 files: - path: output/gatk4/test.reblock.g.vcf.gz - contains: '[ # TODO nf-core: file md5sum was variable, please replace this text with a string found in the file instead ]' - path: output/gatk4/test.reblock.g.vcf.gz.tbi md5sum: 017edea27a253eb51cc4505d00dcb295 From 81fff7384d8342439cf4fc4cce51433d979c97a2 Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Thu, 9 Jun 2022 15:08:02 +0200 Subject: [PATCH 3/5] small fix and typo --- modules/gatk4/reblockgvcf/main.nf | 6 +++--- modules/gatk4/reblockgvcf/meta.yml | 4 ++-- tests/modules/gatk4/reblockgvcf/test.yml | 3 --- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/gatk4/reblockgvcf/main.nf b/modules/gatk4/reblockgvcf/main.nf index d27ac222..bbd8e2ae 100644 --- a/modules/gatk4/reblockgvcf/main.nf +++ b/modules/gatk4/reblockgvcf/main.nf @@ -16,8 +16,8 @@ process GATK4_REBLOCKGVCF { path dbsnp_tbi output: - tuple val(meta), path("*.reblock.g.vcf.gz"), path("*.tbi") , emit: bam - path "versions.yml" , emit: versions + tuple val(meta), path("*.rb.g.vcf.gz"), path("*.tbi") , emit: bam + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -37,7 +37,7 @@ process GATK4_REBLOCKGVCF { """ gatk --java-options "-Xmx${avail_mem}g" ReblockGVCF \\ --variant $gvcf \\ - --output ${prefix}.reblock.g.vcf.gz \\ + --output ${prefix}.rb.g.vcf.gz \\ --reference $fasta \\ $dbsnp_command \\ $interval_command \\ diff --git a/modules/gatk4/reblockgvcf/meta.yml b/modules/gatk4/reblockgvcf/meta.yml index 407eeec2..23518416 100644 --- a/modules/gatk4/reblockgvcf/meta.yml +++ b/modules/gatk4/reblockgvcf/meta.yml @@ -64,11 +64,11 @@ output: - gvcf: type: file description: Filtered GVCF - pattern: "*reblock.g.vcf.gz" + pattern: "*rb.g.vcf.gz" - tbi: type: file description: Index of the filtered GVCF - pattern: "*reblock.g.vcf.gz.tbi" + pattern: "*rb.g.vcf.gz.tbi" authors: - "@nvnieuwk" diff --git a/tests/modules/gatk4/reblockgvcf/test.yml b/tests/modules/gatk4/reblockgvcf/test.yml index 97f1515f..9cef81ae 100644 --- a/tests/modules/gatk4/reblockgvcf/test.yml +++ b/tests/modules/gatk4/reblockgvcf/test.yml @@ -6,7 +6,6 @@ files: - path: output/gatk4/test.reblock.g.vcf.gz - path: output/gatk4/test.reblock.g.vcf.gz.tbi - md5sum: e1aab7d826a151828fd0671ec5aed2e0 - name: gatk4 reblockgvcf test_gatk4_reblockgvcf_intervals command: nextflow run ./tests/modules/gatk4/reblockgvcf -entry test_gatk4_reblockgvcf_intervals -c ./tests/config/nextflow.config -c ./tests/modules/gatk4/reblockgvcf/nextflow.config @@ -16,7 +15,6 @@ files: - path: output/gatk4/test.reblock.g.vcf.gz - path: output/gatk4/test.reblock.g.vcf.gz.tbi - md5sum: e7ca7e9fe76ce12198fd54ec9a64fad4 - name: gatk4 reblockgvcf test_gatk4_reblockgvcf_dbsnp command: nextflow run ./tests/modules/gatk4/reblockgvcf -entry test_gatk4_reblockgvcf_dbsnp -c ./tests/config/nextflow.config -c ./tests/modules/gatk4/reblockgvcf/nextflow.config @@ -26,4 +24,3 @@ files: - path: output/gatk4/test.reblock.g.vcf.gz - path: output/gatk4/test.reblock.g.vcf.gz.tbi - md5sum: 017edea27a253eb51cc4505d00dcb295 From 873215c8ae3882e3ce1c8c62fbae16e74d631270 Mon Sep 17 00:00:00 2001 From: nvnieuwk <101190534+nvnieuwk@users.noreply.github.com> Date: Thu, 9 Jun 2022 15:11:18 +0200 Subject: [PATCH 4/5] Update modules/gatk4/reblockgvcf/main.nf Co-authored-by: Maxime U. Garcia --- modules/gatk4/reblockgvcf/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gatk4/reblockgvcf/main.nf b/modules/gatk4/reblockgvcf/main.nf index bbd8e2ae..5640e8ae 100644 --- a/modules/gatk4/reblockgvcf/main.nf +++ b/modules/gatk4/reblockgvcf/main.nf @@ -16,7 +16,7 @@ process GATK4_REBLOCKGVCF { path dbsnp_tbi output: - tuple val(meta), path("*.rb.g.vcf.gz"), path("*.tbi") , emit: bam + tuple val(meta), path("*.rb.g.vcf.gz"), path("*.tbi") , emit: vcf path "versions.yml" , emit: versions when: From c50df9ad04900067adf6ddfc855a485633813bc6 Mon Sep 17 00:00:00 2001 From: Nicolas Vannieuwkerke Date: Thu, 9 Jun 2022 15:14:37 +0200 Subject: [PATCH 5/5] fix test.yml --- tests/modules/gatk4/reblockgvcf/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/modules/gatk4/reblockgvcf/test.yml b/tests/modules/gatk4/reblockgvcf/test.yml index 9cef81ae..623f58a6 100644 --- a/tests/modules/gatk4/reblockgvcf/test.yml +++ b/tests/modules/gatk4/reblockgvcf/test.yml @@ -4,8 +4,8 @@ - gatk4/reblockgvcf - gatk4 files: - - path: output/gatk4/test.reblock.g.vcf.gz - - path: output/gatk4/test.reblock.g.vcf.gz.tbi + - path: output/gatk4/test.rb.g.vcf.gz + - path: output/gatk4/test.rb.g.vcf.gz.tbi - name: gatk4 reblockgvcf test_gatk4_reblockgvcf_intervals command: nextflow run ./tests/modules/gatk4/reblockgvcf -entry test_gatk4_reblockgvcf_intervals -c ./tests/config/nextflow.config -c ./tests/modules/gatk4/reblockgvcf/nextflow.config @@ -13,8 +13,8 @@ - gatk4/reblockgvcf - gatk4 files: - - path: output/gatk4/test.reblock.g.vcf.gz - - path: output/gatk4/test.reblock.g.vcf.gz.tbi + - path: output/gatk4/test.rb.g.vcf.gz + - path: output/gatk4/test.rb.g.vcf.gz.tbi - name: gatk4 reblockgvcf test_gatk4_reblockgvcf_dbsnp command: nextflow run ./tests/modules/gatk4/reblockgvcf -entry test_gatk4_reblockgvcf_dbsnp -c ./tests/config/nextflow.config -c ./tests/modules/gatk4/reblockgvcf/nextflow.config @@ -22,5 +22,5 @@ - gatk4/reblockgvcf - gatk4 files: - - path: output/gatk4/test.reblock.g.vcf.gz - - path: output/gatk4/test.reblock.g.vcf.gz.tbi + - path: output/gatk4/test.rb.g.vcf.gz + - path: output/gatk4/test.rb.g.vcf.gz.tbi