diff --git a/modules/nf-core/biobambam/bamsormadup/main.nf b/modules/nf-core/biobambam/bamsormadup/main.nf index dc25a3fae40..10bb1a7f2e8 100644 --- a/modules/nf-core/biobambam/bamsormadup/main.nf +++ b/modules/nf-core/biobambam/bamsormadup/main.nf @@ -48,4 +48,22 @@ process BIOBAMBAM_BAMSORMADUP { bamsormadup: \$(echo \$(bamsormadup --version 2>&1) | sed 's/^This is biobambam2 version //; s/..biobambam2 is .*\$//' ) END_VERSIONS """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def suffix = args.contains("outputformat=cram") ? "cram" : "bam" + if (args.contains("outputformat=cram") && reference == null) error "Reference required for CRAM output." + + """ + touch ${prefix}.${suffix} + touch ${prefix}.metrics.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bamcat: \$(echo \$(bamcat --version 2>&1) | sed 's/^This is biobambam2 version //; s/..biobambam2 is .*\$//' ) + bamcollate2: \$(echo \$(bamcollate2 --version 2>&1) | sed 's/^This is biobambam2 version //; s/..biobambam2 is .*\$//' ) + bamsormadup: \$(echo \$(bamsormadup --version 2>&1) | sed 's/^This is biobambam2 version //; s/..biobambam2 is .*\$//' ) + END_VERSIONS + """ } diff --git a/modules/nf-core/biobambam/bamsormadup/tests/main.nf.test b/modules/nf-core/biobambam/bamsormadup/tests/main.nf.test new file mode 100644 index 00000000000..43272ff1604 --- /dev/null +++ b/modules/nf-core/biobambam/bamsormadup/tests/main.nf.test @@ -0,0 +1,105 @@ + +nextflow_process { + + name "Test Process BIOBAMBAM_BAMSORMADUP" + script "../main.nf" + process "BIOBAMBAM_BAMSORMADUP" + + tag "modules" + tag "modules_nfcore" + tag "biobambam" + tag "biobambam/bamsormadup" + + test("test-biobambam-bamsormadup-multi-input") { + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true) + ] + ] + input[1] = [[:],[]] + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + bam(process.out.bam[0][1]).getReadsMD5(), + process.out.bam_index, + process.out.cram, + file(process.out.metrics[0][1]).readLines()[3..5], + process.out.versions + ).match() + } + ) + } + } + + test("test-biobambam-bamsormadup-single-input") { + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists: true) + ] + ] + input[1] = [[:],[]] + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + bam(process.out.bam[0][1]).getReadsMD5(), + process.out.bam_index, + process.out.cram, + file(process.out.metrics[0][1]).readLines()[3..5], + process.out.versions + ).match() + } + ) + } + } + + test("test-biobambam-bamsormadup-single-input-stub") { + + options '-stub' + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists: true) + ] + ] + input[1] = [[:],[]] + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + +} diff --git a/modules/nf-core/biobambam/bamsormadup/tests/main.nf.test.snap b/modules/nf-core/biobambam/bamsormadup/tests/main.nf.test.snap new file mode 100644 index 00000000000..f7a41ca6fff --- /dev/null +++ b/modules/nf-core/biobambam/bamsormadup/tests/main.nf.test.snap @@ -0,0 +1,115 @@ +{ + "test-biobambam-bamsormadup-single-input": { + "content": [ + "e296148e4f68882cc91fb624e392f539", + [ + + ], + [ + + ], + [ + "LIBRARY\tUNPAIRED_READS_EXAMINED\tREAD_PAIRS_EXAMINED\tUNMAPPED_READS\tUNPAIRED_READ_DUPLICATES\tREAD_PAIR_DUPLICATES\tREAD_PAIR_OPTICAL_DUPLICATES\tPERCENT_DUPLICATION\tESTIMATED_LIBRARY_SIZE", + "lib1\t3\t97\t3\t0\t0\t0\t0\t-1", + "" + ], + [ + "versions.yml:md5,67ab301f20567acd9d0e648c2a3e158c" + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-05T22:00:39.772883" + }, + "test-biobambam-bamsormadup-multi-input": { + "content": [ + "3dc03384b330e3f16e15691c9189e890", + [ + + ], + [ + + ], + [ + "LIBRARY\tUNPAIRED_READS_EXAMINED\tREAD_PAIRS_EXAMINED\tUNMAPPED_READS\tUNPAIRED_READ_DUPLICATES\tREAD_PAIR_DUPLICATES\tREAD_PAIR_OPTICAL_DUPLICATES\tPERCENT_DUPLICATION\tESTIMATED_LIBRARY_SIZE", + "lib1\t3\t97\t3\t0\t0\t0\t0\t-1", + "testN\t0\t2820\t2\t0\t828\t0\t0.293617\t3807" + ], + [ + "versions.yml:md5,67ab301f20567acd9d0e648c2a3e158c" + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-05T22:00:31.187999" + }, + "test-biobambam-bamsormadup-single-input-stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "test.bam:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + + ], + "2": [ + + ], + "3": [ + [ + { + "id": "test", + "single_end": false + }, + "test.metrics.txt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "4": [ + "versions.yml:md5,67ab301f20567acd9d0e648c2a3e158c" + ], + "bam": [ + [ + { + "id": "test", + "single_end": false + }, + "test.bam:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "bam_index": [ + + ], + "cram": [ + + ], + "metrics": [ + [ + { + "id": "test", + "single_end": false + }, + "test.metrics.txt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,67ab301f20567acd9d0e648c2a3e158c" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-05T21:57:13.430982" + } +} \ No newline at end of file diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 2335353adda..a28d56954cf 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -52,9 +52,6 @@ bedtools/intersect: bedtools/unionbedg: - modules/nf-core/bedtools/unionbedg/** - tests/modules/nf-core/bedtools/unionbedg/** -biobambam/bamsormadup: - - modules/nf-core/biobambam/bamsormadup/** - - tests/modules/nf-core/biobambam/bamsormadup/** biohansel: - modules/nf-core/biohansel/** - tests/modules/nf-core/biohansel/** diff --git a/tests/modules/nf-core/biobambam/bamsormadup/main.nf b/tests/modules/nf-core/biobambam/bamsormadup/main.nf deleted file mode 100644 index b00cd505a71..00000000000 --- a/tests/modules/nf-core/biobambam/bamsormadup/main.nf +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { BIOBAMBAM_BAMSORMADUP } from '../../../../../modules/nf-core/biobambam/bamsormadup/main.nf' - -workflow test_biobambam_bamsormadup_multi_input { - - input = [ - [ id:'test', single_end:false ], // meta map - [file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true), file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true)], - ] - - BIOBAMBAM_BAMSORMADUP ( input, [[:],[]] ) -} - -workflow test_biobambam_bamsormadup_single_input { - - input = [ - [ id:'test', single_end:false ], // meta map - [file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true)], - ] - - BIOBAMBAM_BAMSORMADUP ( input, [[:],[]] ) -} diff --git a/tests/modules/nf-core/biobambam/bamsormadup/nextflow.config b/tests/modules/nf-core/biobambam/bamsormadup/nextflow.config deleted file mode 100644 index 8730f1c4b93..00000000000 --- a/tests/modules/nf-core/biobambam/bamsormadup/nextflow.config +++ /dev/null @@ -1,5 +0,0 @@ -process { - - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - -} diff --git a/tests/modules/nf-core/biobambam/bamsormadup/test.yml b/tests/modules/nf-core/biobambam/bamsormadup/test.yml deleted file mode 100644 index 69808d797f6..00000000000 --- a/tests/modules/nf-core/biobambam/bamsormadup/test.yml +++ /dev/null @@ -1,23 +0,0 @@ -- name: biobambam bamsormadup test_biobambam_bamsormadup_multi_input - command: nextflow run ./tests/modules/nf-core/biobambam/bamsormadup -entry test_biobambam_bamsormadup_multi_input -c ./tests/config/nextflow.config - tags: - - biobambam/bamsormadup - - biobambam - files: - - path: output/biobambam/test.bam - md5sum: 532b96d9826bc9b01973e49cc4bb316f - - path: output/biobambam/test.metrics.txt - md5sum: 020be21f1b7da0dca721a41e22d7ee02 - - path: output/biobambam/versions.yml - -- name: biobambam bamsormadup test_biobambam_bamsormadup_single_input - command: nextflow run ./tests/modules/nf-core/biobambam/bamsormadup -entry test_biobambam_bamsormadup_single_input -c ./tests/config/nextflow.config - tags: - - biobambam/bamsormadup - - biobambam - files: - - path: output/biobambam/test.bam - md5sum: 238f20beb8f62763e35cb96f311c8f04 - - path: output/biobambam/test.metrics.txt - md5sum: b97458eff0d4b259055e4902849ee53b - - path: output/biobambam/versions.yml