diff --git a/modules/nf-core/vardictjava/main.nf b/modules/nf-core/vardictjava/main.nf index 6329391c837..a2c7666b520 100644 --- a/modules/nf-core/vardictjava/main.nf +++ b/modules/nf-core/vardictjava/main.nf @@ -14,7 +14,7 @@ process VARDICTJAVA { output: tuple val(meta), path("*.vcf.gz"), emit: vcf - path "versions.yml" , emit: versions + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -25,9 +25,12 @@ process VARDICTJAVA { def args3 = task.ext.args3 ?: '' def prefix = task.ext.prefix ?: "${meta.id}" + // Don't run test scripts when -fisher has been used by vardictjava + def run_test = !args.contains("-fisher") + def somatic = bams instanceof List && bams.size() == 2 ? true : false def input = somatic ? "-b \"${bams[0]}|${bams[1]}\"" : "-b ${bams}" - def filter = somatic ? "testsomatic.R" : "teststrandbias.R" + def test = run_test ? somatic ? "| testsomatic.R" : "| teststrandbias.R" : "" def convert_to_vcf = somatic ? "var2vcf_paired.pl" : "var2vcf_valid.pl" """ export JAVA_OPTS='"-Xms${task.memory.toMega()/4}m" "-Xmx${task.memory.toGiga()}g" "-Dsamjdk.reference_fasta=${fasta}"' @@ -37,7 +40,7 @@ process VARDICTJAVA { -th ${task.cpus} \\ -G ${fasta} \\ ${bed} \\ - | ${filter} \\ + ${test} \\ | ${convert_to_vcf} \\ ${args2} \\ | bgzip ${args3} --threads ${task.cpus} > ${prefix}.vcf.gz @@ -50,9 +53,6 @@ process VARDICTJAVA { """ stub: - def args = task.ext.args ?: '-c 1 -S 2 -E 3' - def args2 = task.ext.args2 ?: '' - def args3 = task.ext.args3 ?: '' def prefix = task.ext.prefix ?: "${meta.id}" """ diff --git a/modules/nf-core/vardictjava/tests/main.nf.test b/modules/nf-core/vardictjava/tests/main.nf.test index 8e5fec10266..31e1058cad8 100644 --- a/modules/nf-core/vardictjava/tests/main.nf.test +++ b/modules/nf-core/vardictjava/tests/main.nf.test @@ -10,9 +10,6 @@ nextflow_process { test("homo_sapiens - [bam, bai, bed] - fasta - fai") { when { - params { - outdir = $outputDir - } process { """ input[0] = Channel.value([ @@ -47,9 +44,6 @@ nextflow_process { test("homo_sapiens - [[bam, bam], [bai, bai], bed] - fasta - fai") { when { - params { - outdir = $outputDir - } process { """ input[0] = Channel.value([ @@ -87,4 +81,75 @@ nextflow_process { } + test("homo_sapiens - [bam, bai, bed] - fasta - fai - fisher") { + + config "./nextflow.config" + when { + process { + """ + input[0] = Channel.value([ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.bed', checkIfExists: true) + ]) + input[1] = [ + [id:"ref"], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true) + ] + input[2] = [ + [id:"ref"], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + + + } + + } + + test("homo_sapiens - [bam, bai, bed] - fasta - fai - stub") { + + options "-stub" + + when { + process { + """ + input[0] = Channel.value([ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.bed', checkIfExists: true) + ]) + input[1] = [ + [id:"ref"], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true) + ] + input[2] = [ + [id:"ref"], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + + + } + + } + } diff --git a/modules/nf-core/vardictjava/tests/main.nf.test.snap b/modules/nf-core/vardictjava/tests/main.nf.test.snap index c32a68b7424..35674ed1782 100644 --- a/modules/nf-core/vardictjava/tests/main.nf.test.snap +++ b/modules/nf-core/vardictjava/tests/main.nf.test.snap @@ -27,10 +27,10 @@ } ], "meta": { - "nf-test": "0.8.4", - "nextflow": "24.04.2" + "nf-test": "0.9.0", + "nextflow": "24.04.4" }, - "timestamp": "2024-07-04T19:08:38.328190023" + "timestamp": "2024-10-07T16:05:15.117453312" }, "homo_sapiens - [[bam, bam], [bai, bai], bed] - fasta - fai": { "content": [ @@ -60,9 +60,75 @@ } ], "meta": { - "nf-test": "0.8.4", - "nextflow": "24.04.2" + "nf-test": "0.9.0", + "nextflow": "24.04.4" }, - "timestamp": "2024-07-04T19:08:54.416661915" + "timestamp": "2024-10-07T16:05:26.932438089" + }, + "homo_sapiens - [bam, bai, bed] - fasta - fai - fisher": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5,e8411ecae49b4f6afa6ea0b681ea506e" + ] + ], + "1": [ + "versions.yml:md5,6bf7aa0cbaac4a6e2acab2c475ec2389" + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5,e8411ecae49b4f6afa6ea0b681ea506e" + ] + ], + "versions": [ + "versions.yml:md5,6bf7aa0cbaac4a6e2acab2c475ec2389" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-10-07T16:05:38.456816851" + }, + "homo_sapiens - [bam, bai, bed] - fasta - fai - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "1": [ + "versions.yml:md5,6bf7aa0cbaac4a6e2acab2c475ec2389" + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "versions": [ + "versions.yml:md5,6bf7aa0cbaac4a6e2acab2c475ec2389" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-10-07T16:05:48.440804849" } } \ No newline at end of file diff --git a/modules/nf-core/vardictjava/tests/nextflow.config b/modules/nf-core/vardictjava/tests/nextflow.config new file mode 100644 index 00000000000..c6e8571bd41 --- /dev/null +++ b/modules/nf-core/vardictjava/tests/nextflow.config @@ -0,0 +1,3 @@ +process { + ext.args = "-c 1 -S 2 -E 3 -fisher" +} \ No newline at end of file