diff --git a/modules/nf-core/parabricks/haplotypecaller/main.nf b/modules/nf-core/parabricks/haplotypecaller/main.nf index d8853130da7..644f7059a06 100644 --- a/modules/nf-core/parabricks/haplotypecaller/main.nf +++ b/modules/nf-core/parabricks/haplotypecaller/main.nf @@ -1,40 +1,41 @@ process PARABRICKS_HAPLOTYPECALLER { tag "$meta.id" label 'process_high' + label 'process_gpu' + stageInMode 'copy' // needed by the module to work properly can be removed when fixed upstream - Issue #7226 - container "nvcr.io/nvidia/clara/clara-parabricks:4.3.0-1" + container "nvcr.io/nvidia/clara/clara-parabricks:4.4.0-1" input: tuple val(meta), path(input), path(input_index), path(interval_file) tuple val(ref_meta), path(fasta) output: - tuple val(meta), path("*.vcf"), emit: vcf + tuple val(meta), path("*.vcf"), optional: true, emit: vcf + tuple val(meta), path("*.g.vcf.gz"), optional: true, emit: gvcf path "versions.yml", emit: versions when: task.ext.when == null || task.ext.when script: - // Exit if running this module with -profile conda / -profile mamba if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { exit 1, "Parabricks module does not support Conda. Please use Docker / Singularity / Podman instead." } - def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - def output_file = args =~ "gvcf" ? "${prefix}.g.vcf" : "${prefix}.vcf" + def output_file = ("gvcf" =~ args)? "${prefix}.g.vcf.gz" : "${prefix}.vcf" def interval_file_command = interval_file ? interval_file.collect{"--interval-file $it"}.join(' ') : "" + def num_gpus = task.accelerator ? "--num-gpus $task.accelerator.request" : '' """ - pbrun \\ haplotypecaller \\ --ref $fasta \\ --in-bam $input \\ --out-variants $output_file \\ $interval_file_command \\ - --num-gpus $task.accelerator.request \\ + $num_gpus \\ $args cat <<-END_VERSIONS > versions.yml @@ -46,9 +47,9 @@ process PARABRICKS_HAPLOTYPECALLER { stub: def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - def output_file = args =~ "gvcf" ? "${prefix}.g.vcf" : "${prefix}.vcf" + def output_cmd = ("gvcf" =~ args)? "echo '' | gzip > ${prefix}.g.vcf.gz" : "touch ${prefix}.vcf" """ - touch $output_file + $output_cmd cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-core/parabricks/haplotypecaller/tests/main.nf.test b/modules/nf-core/parabricks/haplotypecaller/tests/main.nf.test new file mode 100644 index 00000000000..8128a67e806 --- /dev/null +++ b/modules/nf-core/parabricks/haplotypecaller/tests/main.nf.test @@ -0,0 +1,229 @@ +nextflow_process { + + name "Test Process PARABRICKS_HAPLOTYPECALLER" + script "../main.nf" + process "PARABRICKS_HAPLOTYPECALLER" + + tag "modules" + tag "modules_nfcore" + tag "parabricks" + tag "parabricks/haplotypecaller" + tag "gpu" + + config './nextflow.config' + + test("human - bam") { + + when { + params { + module_args = '--htvc-low-memory' + } + process { + """ + input[0] = [ + [ id:'test'], + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam'], checkIfExists: true), + [], + [] + ] + input[1] = [ + [ id:'reference'], + file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + path(process.out.vcf[0][1]).vcf.variantsMD5, + process.out.versions, + ).match() + } + ) + } + + } + + test("human - bam - intervals") { + + when { + params { + module_args = '--htvc-low-memory' + } + process { + """ + input[0] = [ + [ id:'test'], + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam_bai'], checkIfExists: true), + file(params.test_data['homo_sapiens']['genome']['genome_21_multi_interval_bed'], checkIfExists: true) + ] + input[1] = [ + [ id:'reference'], + file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + path(process.out.vcf[0][1]).vcf.variantsMD5, + process.out.versions, + ).match() + } + ) + } + + } + + test("human - bam - intervals - gvcf") { + + when { + params { + module_args = '--gvcf --htvc-low-memory' + } + process { + """ + input[0] = [ + [ id:'test'], + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam_bai'], checkIfExists: true), + file(params.test_data['homo_sapiens']['genome']['genome_21_multi_interval_bed'], checkIfExists: true) + ] + input[1] = [ + [ id:'reference'], + file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + path(process.out.gvcf[0][1]).vcf.variantsMD5, + process.out.versions, + ).match() + } + ) + } + + } + + test("human - bam - stub") { + + options "-stub" + + when { + params { + module_args = '--htvc-low-memory' + } + process { + """ + input[0] = [ + [ id:'test'], + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam'], checkIfExists: true), + [], + [] + ] + input[1] = [ + [ id:'reference'], + file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + process.out, + path(process.out.versions[0]).yaml + ).match() + } + ) + } + + } + + test("human - bam - intervals - stub") { + + options "-stub" + + when { + params { + module_args = '--htvc-low-memory' + } + process { + """ + input[0] = [ + [ id:'test'], + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam_bai'], checkIfExists: true), + file(params.test_data['homo_sapiens']['genome']['genome_21_multi_interval_bed'], checkIfExists: true) + ] + input[1] = [ + [ id:'reference'], + file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + process.out, + path(process.out.versions[0]).yaml + ).match() + } + ) + } + + } + + test("human - bam - intervals - gvcf - stub") { + + when { + params { + module_args = '--gvcf --htvc-low-memory' + } + process { + """ + input[0] = [ + [ id:'test'], + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam_bai'], checkIfExists: true), + file(params.test_data['homo_sapiens']['genome']['genome_21_multi_interval_bed'], checkIfExists: true) + ] + input[1] = [ + [ id:'reference'], + file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + process.out, + path(process.out.versions[0]).yaml + ).match() + } + ) + } + + } + +} diff --git a/modules/nf-core/parabricks/haplotypecaller/tests/main.nf.test.snap b/modules/nf-core/parabricks/haplotypecaller/tests/main.nf.test.snap new file mode 100644 index 00000000000..f42b25d07a1 --- /dev/null +++ b/modules/nf-core/parabricks/haplotypecaller/tests/main.nf.test.snap @@ -0,0 +1,144 @@ +{ + "human - bam - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + + ], + "2": [ + "versions.yml:md5,cc6d48cc1e81c73a02d158459281b500" + ], + "gvcf": [ + + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,cc6d48cc1e81c73a02d158459281b500" + ] + }, + { + "PARABRICKS_HAPLOTYPECALLER": { + "pbrun": "4.4.0-1" + } + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.4" + }, + "timestamp": "2025-02-11T15:33:36.60016204" + }, + "human - bam - intervals - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + + ], + "2": [ + "versions.yml:md5,cc6d48cc1e81c73a02d158459281b500" + ], + "gvcf": [ + + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,cc6d48cc1e81c73a02d158459281b500" + ] + }, + { + "PARABRICKS_HAPLOTYPECALLER": { + "pbrun": "4.4.0-1" + } + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.4" + }, + "timestamp": "2025-02-11T15:33:57.570177599" + }, + "human - bam - intervals - gvcf - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.g.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + { + "id": "test" + }, + "test.g.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + "versions.yml:md5,cc6d48cc1e81c73a02d158459281b500" + ], + "gvcf": [ + [ + { + "id": "test" + }, + "test.g.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.g.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,cc6d48cc1e81c73a02d158459281b500" + ] + }, + { + "PARABRICKS_HAPLOTYPECALLER": { + "pbrun": "4.4.0-1" + } + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.4" + }, + "timestamp": "2025-02-11T15:34:30.120235321" + } +} \ No newline at end of file diff --git a/modules/nf-core/parabricks/haplotypecaller/tests/nextflow.config b/modules/nf-core/parabricks/haplotypecaller/tests/nextflow.config new file mode 100644 index 00000000000..fc5fc11c715 --- /dev/null +++ b/modules/nf-core/parabricks/haplotypecaller/tests/nextflow.config @@ -0,0 +1,7 @@ +process { + + withName: 'PARABRICKS_HAPLOTYPECALLER' { + ext.args = params.module_args + } + +} \ No newline at end of file diff --git a/tests/config/nf-test.config b/tests/config/nf-test.config index d8350fafaea..8d9c06cdc59 100644 --- a/tests/config/nf-test.config +++ b/tests/config/nf-test.config @@ -23,7 +23,7 @@ profiles { } docker { docker.enabled = true - docker.runOptions = '-u $(id -u):$(id -g) --platform=linux/amd64' + docker.runOptions = '-u $(id -u):$(id -g) --platform=linux/amd64 --gpus all' } docker_self_hosted { docker.enabled = true diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 8340ebbd175..56c37e51751 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -296,9 +296,6 @@ ncbitools/vecscreen: oncocnv: - modules/nf-core/oncocnv/** - tests/modules/nf-core/oncocnv/** -parabricks/haplotypecaller: - - modules/nf-core/parabricks/haplotypecaller/** - - tests/modules/nf-core/parabricks/haplotypecaller/** paraclu: - modules/nf-core/paraclu/** - tests/modules/nf-core/paraclu/** diff --git a/tests/modules/nf-core/parabricks/haplotypecaller/main.nf b/tests/modules/nf-core/parabricks/haplotypecaller/main.nf deleted file mode 100644 index 413ba77ce18..00000000000 --- a/tests/modules/nf-core/parabricks/haplotypecaller/main.nf +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { PARABRICKS_HAPLOTYPECALLER } from '../../../../../modules/nf-core/parabricks/haplotypecaller/main.nf' -include { PARABRICKS_HAPLOTYPECALLER as PARABRICKS_HAPLOTYPECALLER_GVCF } from '../../../../../modules/nf-core/parabricks/haplotypecaller/main.nf' - -workflow test_parabricks_haplotypecaller { - - input = [ - [ id:'test'], - file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam'], checkIfExists: true), - [], - [] - ] - fasta = [ - [ id:'test'], - file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) - ] - - PARABRICKS_HAPLOTYPECALLER ( input, fasta ) -} - -workflow test_parabricks_haplotypecaller_intervals { - - input = [ - [ id:'test'], - file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam'], checkIfExists: true), - file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam_bai'], checkIfExists: true), - file(params.test_data['homo_sapiens']['genome']['genome_21_multi_interval_bed'], checkIfExists: true) - ] - - fasta = [ - [ id:'test'], - file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) - ] - - PARABRICKS_HAPLOTYPECALLER ( input, fasta ) -} - -workflow test_parabricks_haplotypecaller_gvcf { - - input = [ - [ id:'test'], - file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam'], checkIfExists: true), - file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_recalibrated_sorted_bam_bai'], checkIfExists: true), - file(params.test_data['homo_sapiens']['genome']['genome_21_multi_interval_bed'], checkIfExists: true) - ] - - fasta = [ - [ id:'test'], - file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) - ] - - PARABRICKS_HAPLOTYPECALLER_GVCF ( input, fasta ) -} diff --git a/tests/modules/nf-core/parabricks/haplotypecaller/nextflow.config b/tests/modules/nf-core/parabricks/haplotypecaller/nextflow.config deleted file mode 100644 index a5e4aff38de..00000000000 --- a/tests/modules/nf-core/parabricks/haplotypecaller/nextflow.config +++ /dev/null @@ -1,8 +0,0 @@ -process { - - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - - withName: PARABRICKS_HAPLOTYPECALLER_GVCF { - ext.args = "--gvcf" - } -} diff --git a/tests/modules/nf-core/parabricks/haplotypecaller/test.yml b/tests/modules/nf-core/parabricks/haplotypecaller/test.yml deleted file mode 100644 index b250023831f..00000000000 --- a/tests/modules/nf-core/parabricks/haplotypecaller/test.yml +++ /dev/null @@ -1,29 +0,0 @@ -- name: parabricks haplotypecaller test_parabricks_haplotypecaller - command: nextflow run ./tests/modules/nf-core/parabricks/haplotypecaller -entry test_parabricks_haplotypecaller -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/parabricks/haplotypecaller/nextflow.config -stub-run - tags: - - parabricks - - parabricks/haplotypecaller - files: - - path: output/parabricks/test.vcf - should_exist: true - - path: output/parabricks/versions.yml - -- name: parabricks haplotypecaller test_parabricks_haplotypecaller_intervals - command: nextflow run ./tests/modules/nf-core/parabricks/haplotypecaller -entry test_parabricks_haplotypecaller_intervals -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/parabricks/haplotypecaller/nextflow.config -stub-run - tags: - - parabricks - - parabricks/haplotypecaller - files: - - path: output/parabricks/test.vcf - should_exist: true - - path: output/parabricks/versions.yml - -- name: parabricks haplotypecaller test_parabricks_haplotypecaller_gvcf - command: nextflow run ./tests/modules/nf-core/parabricks/haplotypecaller -entry test_parabricks_haplotypecaller_gvcf -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/parabricks/haplotypecaller/nextflow.config -stub-run - tags: - - parabricks - - parabricks/haplotypecaller - files: - - path: output/parabricks/test.g.vcf - should_exist: true - - path: output/parabricks/versions.yml diff --git a/tests/modules/nf-core/parabricks/haplotypecaller/test_GPU_config.txt b/tests/modules/nf-core/parabricks/haplotypecaller/test_GPU_config.txt deleted file mode 100644 index 588854f2423..00000000000 --- a/tests/modules/nf-core/parabricks/haplotypecaller/test_GPU_config.txt +++ /dev/null @@ -1,14 +0,0 @@ -process { - - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - memory = "15.GB" - cpus = 4 - accelerator = 1 - - withName: PARABRICKS_HAPLOTYPECALLER_GVCF { - ext.args = "--gvcf" - } -} - -docker.runOptions = "--gpus all" -singularity.runOptions = "--nv" diff --git a/tests/modules/nf-core/parabricks/haplotypecaller/test_GPU_yml.txt b/tests/modules/nf-core/parabricks/haplotypecaller/test_GPU_yml.txt deleted file mode 100644 index 36071e75136..00000000000 --- a/tests/modules/nf-core/parabricks/haplotypecaller/test_GPU_yml.txt +++ /dev/null @@ -1,29 +0,0 @@ -- name: parabricks haplotypecaller test_parabricks_haplotypecaller - command: nextflow run ./tests/modules/nf-core/parabricks/haplotypecaller -entry test_parabricks_haplotypecaller -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/parabricks/haplotypecaller/nextflow.config - tags: - - parabricks - - parabricks/haplotypecaller - files: - - path: output/parabricks/test.vcf - should_exist: true - - path: output/parabricks/versions.yml - -- name: parabricks haplotypecaller test_parabricks_haplotypecaller_intervals - command: nextflow run ./tests/modules/nf-core/parabricks/haplotypecaller -entry test_parabricks_haplotypecaller_intervals -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/parabricks/haplotypecaller/nextflow.config - tags: - - parabricks - - parabricks/haplotypecaller - files: - - path: output/parabricks/test.vcf - should_exist: true - - path: output/parabricks/versions.yml - -- name: parabricks haplotypecaller test_parabricks_haplotypecaller_gvcf - command: nextflow run ./tests/modules/nf-core/parabricks/haplotypecaller -entry test_parabricks_haplotypecaller_gvcf -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/parabricks/haplotypecaller/nextflow.config - tags: - - parabricks - - parabricks/haplotypecaller - files: - - path: output/parabricks/test.g.vcf - should_exist: true - - path: output/parabricks/versions.yml