From f23640f813980af4fbfa28983d393ed9fa271bb6 Mon Sep 17 00:00:00 2001 From: Simon Pearce <24893913+SPPearce@users.noreply.github.com> Date: Wed, 8 Jan 2025 21:11:14 +0000 Subject: [PATCH 1/2] Swap bbmap/align to nf-test --- modules/nf-core/bbmap/align/main.nf | 13 ++ .../nf-core/bbmap/align/tests/main.nf.test | 170 ++++++++++++++++++ .../bbmap/align/tests/main.nf.test.snap | 82 +++++++++ .../nf-core/bbmap/align/tests/nextflow.config | 5 + modules/nf-core/bbmap/index/main.nf | 11 ++ tests/config/pytest_modules.yml | 3 - tests/modules/nf-core/bbmap/align/main.nf | 59 ------ .../nf-core/bbmap/align/nextflow.config | 9 - tests/modules/nf-core/bbmap/align/test.yml | 39 ---- 9 files changed, 281 insertions(+), 110 deletions(-) create mode 100644 modules/nf-core/bbmap/align/tests/main.nf.test create mode 100644 modules/nf-core/bbmap/align/tests/main.nf.test.snap create mode 100644 modules/nf-core/bbmap/align/tests/nextflow.config delete mode 100644 tests/modules/nf-core/bbmap/align/main.nf delete mode 100644 tests/modules/nf-core/bbmap/align/nextflow.config delete mode 100644 tests/modules/nf-core/bbmap/align/test.yml diff --git a/modules/nf-core/bbmap/align/main.nf b/modules/nf-core/bbmap/align/main.nf index cbdc9c932c0..c4e7acf7bde 100644 --- a/modules/nf-core/bbmap/align/main.nf +++ b/modules/nf-core/bbmap/align/main.nf @@ -48,6 +48,19 @@ process BBMAP_ALIGN { -Xmx${task.memory.toGiga()}g \\ &> ${prefix}.bbmap.log + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bbmap: \$(bbversion.sh | grep -v "Duplicate cpuset") + samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//') + pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' ) + END_VERSIONS + """ + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.bam + touch ${prefix}.bbmap.log + cat <<-END_VERSIONS > versions.yml "${task.process}": bbmap: \$(bbversion.sh | grep -v "Duplicate cpuset") diff --git a/modules/nf-core/bbmap/align/tests/main.nf.test b/modules/nf-core/bbmap/align/tests/main.nf.test new file mode 100644 index 00000000000..22074ec9c90 --- /dev/null +++ b/modules/nf-core/bbmap/align/tests/main.nf.test @@ -0,0 +1,170 @@ +nextflow_process { + + name "Test Process BBMAP_ALIGN" + script "../main.nf" + process "BBMAP_ALIGN" + + tag "modules" + tag "modules_nfcore" + tag "bbmap" + tag "bbmap/align" + + setup { + run("BBMAP_INDEX") { + script "../../index/main.nf" + process { + """ + input[0] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true) + """ + } + } + } + + test("paired_end - fasta") { + + when { + process { + """ + input[0] = [ [ id:'test', single_end:false ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true) + ] + ] + input[1] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true) + """ + } + } + + then { + assert process.success + assertAll( + { assert snapshot( + file(process.out.log[0][1]).name, + process.out.bam.collect { meta, bamfile -> bam(bamfile).getReadsMD5()}, + process.out.versions + ).match() } + ) + } + + } + + test("paired_end - index") { + + when { + process { + """ + input[0] = [ [ id:'test', single_end:false ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true) + ] + ] + input[1] = BBMAP_INDEX.out.index + """ + } + } + + then { + assert process.success + assertAll( + { assert snapshot( + file(process.out.log[0][1]).name, + process.out.bam.collect { meta, bamfile -> bam(bamfile).getReadsMD5()}, + process.out.versions + ).match() } + ) + } + + } + + test("single_end - index") { + + when { + process { + """ + input[0] = [ [ id:'test', single_end:true ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true) + ] + ] + input[1] = BBMAP_INDEX.out.index + """ + } + } + + then { + assert process.success + assertAll( + { assert snapshot( + file(process.out.log[0][1]).name, + process.out.bam.collect { meta, bamfile -> bam(bamfile).getReadsMD5()}, + process.out.versions + ).match() } + ) + } + + } + + test("paired_end - index - pigz") { + config "./nextflow.config" + when { + params { + module_args = 'unpigz=t' + } + process { + """ + input[0] = [ [ id:'test', single_end:false ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true) + ] + ] + input[1] = BBMAP_INDEX.out.index + """ + } + } + + then { + assert process.success + assertAll( + { assert snapshot( + file(process.out.log[0][1]).name, + process.out.bam.collect { meta, bamfile -> bam(bamfile).getReadsMD5()}, + process.out.versions + ).match() } + ) + } + + } + + test("paired_end - index - stub") { + options "-stub" + when { + process { + """ + input[0] = [ [ id:'test', single_end:false ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true) + ] + ] + input[1] = BBMAP_INDEX.out.index + """ + } + } + + then { + assert process.success + assertAll( + { assert snapshot( + file(process.out.log[0][1]).name, + process.out.bam.collect { meta, bamfile -> bam(bamfile).getReadsMD5()}, + process.out.versions + ).match() } + ) + } + + } + +} diff --git a/modules/nf-core/bbmap/align/tests/main.nf.test.snap b/modules/nf-core/bbmap/align/tests/main.nf.test.snap new file mode 100644 index 00000000000..2423ad444e3 --- /dev/null +++ b/modules/nf-core/bbmap/align/tests/main.nf.test.snap @@ -0,0 +1,82 @@ +{ + "single_end - index": { + "content": [ + "test.bbmap.log", + [ + "c17efa4ccc4e9018090792c71af92660" + ], + [ + "versions.yml:md5,7c9a1c72ae9ea9c54b7518e96f8f89bb" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2025-01-08T21:06:20.348251263" + }, + "paired_end - index": { + "content": [ + "test.bbmap.log", + [ + "88d78879c34214288644aec7ec3cb270" + ], + [ + "versions.yml:md5,7c9a1c72ae9ea9c54b7518e96f8f89bb" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2025-01-08T21:06:05.162378558" + }, + "paired_end - fasta": { + "content": [ + "test.bbmap.log", + [ + "88d78879c34214288644aec7ec3cb270" + ], + [ + "versions.yml:md5,7c9a1c72ae9ea9c54b7518e96f8f89bb" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2025-01-08T21:05:49.658797332" + }, + "paired_end - index - pigz": { + "content": [ + "test.bbmap.log", + [ + "88d78879c34214288644aec7ec3cb270" + ], + [ + "versions.yml:md5,7c9a1c72ae9ea9c54b7518e96f8f89bb" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2025-01-08T21:06:36.326962674" + }, + "paired_end - index - stub": { + "content": [ + "test.bbmap.log", + [ + "d41d8cd98f00b204e9800998ecf8427e" + ], + [ + "versions.yml:md5,7c9a1c72ae9ea9c54b7518e96f8f89bb" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2025-01-08T21:06:47.377762689" + } +} \ No newline at end of file diff --git a/modules/nf-core/bbmap/align/tests/nextflow.config b/modules/nf-core/bbmap/align/tests/nextflow.config new file mode 100644 index 00000000000..10088880f3b --- /dev/null +++ b/modules/nf-core/bbmap/align/tests/nextflow.config @@ -0,0 +1,5 @@ +process { + withName: BBMAP_ALIGN { + ext.args = params.module_args + } +} diff --git a/modules/nf-core/bbmap/index/main.nf b/modules/nf-core/bbmap/index/main.nf index 02785558dfc..e7b3eb113e5 100644 --- a/modules/nf-core/bbmap/index/main.nf +++ b/modules/nf-core/bbmap/index/main.nf @@ -26,6 +26,17 @@ process BBMAP_INDEX { threads=$task.cpus \\ -Xmx${task.memory.toGiga()}g + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bbmap: \$(bbversion.sh | grep -v "Duplicate cpuset") + END_VERSIONS + """ + stub: + """ + mkdir -p ref + touch ref/info.txt + touch ref/summary.txt + cat <<-END_VERSIONS > versions.yml "${task.process}": bbmap: \$(bbversion.sh | grep -v "Duplicate cpuset") diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 1f7d49a8ed7..6c15fdc2b6d 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -40,9 +40,6 @@ bamtools/split: basicpy: - modules/nf-core/basicpy/** - tests/modules/nf-core/basicpy/** -bbmap/align: - - modules/nf-core/bbmap/align/** - - tests/modules/nf-core/bbmap/align/** biohansel: - modules/nf-core/biohansel/** - tests/modules/nf-core/biohansel/** diff --git a/tests/modules/nf-core/bbmap/align/main.nf b/tests/modules/nf-core/bbmap/align/main.nf deleted file mode 100644 index f2bfcd9069c..00000000000 --- a/tests/modules/nf-core/bbmap/align/main.nf +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { BBMAP_INDEX } from '../../../../../modules/nf-core/bbmap/index/main.nf' -include { BBMAP_ALIGN } from '../../../../../modules/nf-core/bbmap/align/main.nf' -include { BBMAP_ALIGN as BBMAP_ALIGN_PIGZ } from '../../../../../modules/nf-core/bbmap/align/main.nf' - -workflow test_bbmap_align_paired_end_fasta_ref { - - input = [ [ id:'test', single_end:false ], // meta map - [ - file( params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), - file( params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) - ] - ] - fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - - BBMAP_ALIGN ( input, fasta ) -} - -workflow test_bbmap_align_paired_end_index_ref { - - input = [ [ id:'test', single_end:false ], // meta map - [ - file( params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), - file( params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) - ] - ] - fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - - BBMAP_INDEX ( fasta ) - BBMAP_ALIGN ( input, BBMAP_INDEX.out.index ) -} - -workflow test_bbmap_align_single_end_index_ref { - - input = [ [ id:'test', single_end:true ], // meta map - file( params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) - ] - fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - - BBMAP_INDEX ( fasta ) - BBMAP_ALIGN ( input, BBMAP_INDEX.out.index ) -} - -workflow test_bbmap_align_paired_end_index_ref_pigz { - - input = [ [ id:'test', single_end:false ], // meta map - [ - file( params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), - file( params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) - ] - ] - fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - - BBMAP_INDEX ( fasta ) - BBMAP_ALIGN_PIGZ ( input, BBMAP_INDEX.out.index ) -} diff --git a/tests/modules/nf-core/bbmap/align/nextflow.config b/tests/modules/nf-core/bbmap/align/nextflow.config deleted file mode 100644 index fe0afd7276c..00000000000 --- a/tests/modules/nf-core/bbmap/align/nextflow.config +++ /dev/null @@ -1,9 +0,0 @@ -process { - - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - - withName: BBMAP_ALIGN_PIGZ { - ext.args = 'unpigz=t' - } - -} diff --git a/tests/modules/nf-core/bbmap/align/test.yml b/tests/modules/nf-core/bbmap/align/test.yml deleted file mode 100644 index 19744741681..00000000000 --- a/tests/modules/nf-core/bbmap/align/test.yml +++ /dev/null @@ -1,39 +0,0 @@ -- name: bbmap align paired end fasta ref - command: nextflow run ./tests/modules/nf-core/bbmap/align -entry test_bbmap_align_paired_end_fasta_ref -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bbmap/align/nextflow.config - tags: - - bbmap - - bbmap/align - files: - - path: output/bbmap/test.bam - md5sum: ef49b3fa7bf68a35bc7837685002655e - - path: output/bbmap/test.bbmap.log - -- name: bbmap align paired end index ref - command: nextflow run ./tests/modules/nf-core/bbmap/align -entry test_bbmap_align_paired_end_index_ref -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bbmap/align/nextflow.config - tags: - - bbmap - - bbmap/align - files: - - path: output/bbmap/test.bam - md5sum: a82aadd954312833bfd24ebebb1c6811 - - path: output/bbmap/test.bbmap.log - -- name: bbmap align single end index ref - command: nextflow run ./tests/modules/nf-core/bbmap/align -entry test_bbmap_align_single_end_index_ref -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bbmap/align/nextflow.config - tags: - - bbmap - - bbmap/align - files: - - path: output/bbmap/test.bam - md5sum: 7ed717babcc392bddcfeeb1ea53ab1f3 - - path: output/bbmap/test.bbmap.log - -- name: bbmap align paired end index ref pigz - command: nextflow run ./tests/modules/nf-core/bbmap/align -entry test_bbmap_align_paired_end_index_ref_pigz -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bbmap/align/nextflow.config - tags: - - bbmap - - bbmap/align - files: - - path: output/bbmap/test.bam - md5sum: 18d5774576c6bdceaed69a9bf138b59b - - path: output/bbmap/test.bbmap.log From fcf932bb974aba8726a3ddad992fde55134b484f Mon Sep 17 00:00:00 2001 From: Simon Pearce <24893913+SPPearce@users.noreply.github.com> Date: Thu, 9 Jan 2025 09:21:41 +0000 Subject: [PATCH 2/2] Add missing tag --- modules/nf-core/bbmap/align/tests/main.nf.test | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/nf-core/bbmap/align/tests/main.nf.test b/modules/nf-core/bbmap/align/tests/main.nf.test index 22074ec9c90..5763a584693 100644 --- a/modules/nf-core/bbmap/align/tests/main.nf.test +++ b/modules/nf-core/bbmap/align/tests/main.nf.test @@ -8,6 +8,7 @@ nextflow_process { tag "modules_nfcore" tag "bbmap" tag "bbmap/align" + tag "bbmap/index" setup { run("BBMAP_INDEX") {