From 448e5d9b1551a86dd38283b5c168a6c9353d56f7 Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Thu, 5 Sep 2024 20:05:11 +1200 Subject: [PATCH 1/2] Added nf-test for metabat2/jgisummarizebamcontigdepths --- .../jgisummarizebamcontigdepths/main.nf | 11 +++ .../tests/main.nf.test | 60 ++++++++++++++++ .../tests/main.nf.test.snap | 68 +++++++++++++++++++ tests/config/pytest_modules.yml | 3 - .../jgisummarizebamcontigdepths/main.nf | 14 ---- .../nextflow.config | 5 -- .../jgisummarizebamcontigdepths/test.yml | 8 --- 7 files changed, 139 insertions(+), 30 deletions(-) create mode 100644 modules/nf-core/metabat2/jgisummarizebamcontigdepths/tests/main.nf.test create mode 100644 modules/nf-core/metabat2/jgisummarizebamcontigdepths/tests/main.nf.test.snap delete mode 100644 tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/main.nf delete mode 100644 tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/nextflow.config delete mode 100644 tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/test.yml diff --git a/modules/nf-core/metabat2/jgisummarizebamcontigdepths/main.nf b/modules/nf-core/metabat2/jgisummarizebamcontigdepths/main.nf index 60b38e0e71b..df3971fc3fb 100644 --- a/modules/nf-core/metabat2/jgisummarizebamcontigdepths/main.nf +++ b/modules/nf-core/metabat2/jgisummarizebamcontigdepths/main.nf @@ -35,4 +35,15 @@ process METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS { metabat2: \$( metabat2 --help 2>&1 | head -n 2 | tail -n 1| sed 's/.*\\:\\([0-9]*\\.[0-9]*\\).*/\\1/' ) END_VERSIONS """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + echo | gzip > ${prefix}.txt.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + metabat2: \$( metabat2 --help 2>&1 | head -n 2 | tail -n 1| sed 's/.*\\:\\([0-9]*\\.[0-9]*\\).*/\\1/' ) + END_VERSIONS + """ } diff --git a/modules/nf-core/metabat2/jgisummarizebamcontigdepths/tests/main.nf.test b/modules/nf-core/metabat2/jgisummarizebamcontigdepths/tests/main.nf.test new file mode 100644 index 00000000000..d4852ba5b06 --- /dev/null +++ b/modules/nf-core/metabat2/jgisummarizebamcontigdepths/tests/main.nf.test @@ -0,0 +1,60 @@ + +nextflow_process { + + name "Test Process METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS" + script "../main.nf" + process "METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS" + + tag "modules" + tag "modules_nfcore" + tag "metabat2" + tag "metabat2/jgisummarizebamcontigdepths" + + test("test-metabat2-jgisummarizebamcontigdepths") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true) + ] + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test-metabat2-jgisummarizebamcontigdepths-stub") { + options '-stub' + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true) + ] + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + +} diff --git a/modules/nf-core/metabat2/jgisummarizebamcontigdepths/tests/main.nf.test.snap b/modules/nf-core/metabat2/jgisummarizebamcontigdepths/tests/main.nf.test.snap new file mode 100644 index 00000000000..29e60c37dee --- /dev/null +++ b/modules/nf-core/metabat2/jgisummarizebamcontigdepths/tests/main.nf.test.snap @@ -0,0 +1,68 @@ +{ + "test-metabat2-jgisummarizebamcontigdepths": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.txt.gz:md5,c7448ff92b336561540717e7b0ca0702" + ] + ], + "1": [ + "versions.yml:md5,2884d72385b65d0737899da5cb9e89d5" + ], + "depth": [ + [ + { + "id": "test" + }, + "test.txt.gz:md5,c7448ff92b336561540717e7b0ca0702" + ] + ], + "versions": [ + "versions.yml:md5,2884d72385b65d0737899da5cb9e89d5" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-05T20:02:46.985235" + }, + "test-metabat2-jgisummarizebamcontigdepths-stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.txt.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "1": [ + "versions.yml:md5,2884d72385b65d0737899da5cb9e89d5" + ], + "depth": [ + [ + { + "id": "test" + }, + "test.txt.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "versions": [ + "versions.yml:md5,2884d72385b65d0737899da5cb9e89d5" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-05T20:01:24.531629" + } +} \ No newline at end of file diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index cc2ae91d905..47f9cf4564a 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -485,9 +485,6 @@ merquryfk/katgc: merquryfk/ploidyplot: - modules/nf-core/merquryfk/ploidyplot/** - tests/modules/nf-core/merquryfk/ploidyplot/** -metabat2/jgisummarizebamcontigdepths: - - modules/nf-core/metabat2/jgisummarizebamcontigdepths/** - - tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/** metabat2/metabat2: - modules/nf-core/metabat2/metabat2/** - tests/modules/nf-core/metabat2/metabat2/** diff --git a/tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/main.nf b/tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/main.nf deleted file mode 100644 index 861e0cb5f74..00000000000 --- a/tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/main.nf +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS } from '../../../../../modules/nf-core/metabat2/jgisummarizebamcontigdepths/main.nf' - -workflow test_metabat2_jgisummarizebamcontigdepths { - - input = [ [ id:'test' ], // meta map - file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true), - file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true) ] - - METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS ( input ) -} diff --git a/tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/nextflow.config b/tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/nextflow.config deleted file mode 100644 index 8730f1c4b93..00000000000 --- a/tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/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/metabat2/jgisummarizebamcontigdepths/test.yml b/tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/test.yml deleted file mode 100644 index c68fac757b7..00000000000 --- a/tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/test.yml +++ /dev/null @@ -1,8 +0,0 @@ -- name: metabat2 jgisummarizebamcontigdepths test_metabat2_jgisummarizebamcontigdepths - command: nextflow run ./tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths -entry test_metabat2_jgisummarizebamcontigdepths -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/metabat2/jgisummarizebamcontigdepths/nextflow.config - tags: - - metabat2/jgisummarizebamcontigdepths - - metabat2 - files: - - path: output/metabat2/test.txt.gz - md5sum: 8f735aa408d6c90e5a0310e06ace7a9a From 1bdc0c20b08c32069203b8fab746281d3cfea728 Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Fri, 6 Sep 2024 19:56:49 +1200 Subject: [PATCH 2/2] Removed defaults --- .../nf-core/metabat2/jgisummarizebamcontigdepths/environment.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/nf-core/metabat2/jgisummarizebamcontigdepths/environment.yml b/modules/nf-core/metabat2/jgisummarizebamcontigdepths/environment.yml index 3140be6a47b..887fc413fd6 100644 --- a/modules/nf-core/metabat2/jgisummarizebamcontigdepths/environment.yml +++ b/modules/nf-core/metabat2/jgisummarizebamcontigdepths/environment.yml @@ -2,6 +2,5 @@ name: metabat2_jgisummarizebamcontigdepths channels: - conda-forge - bioconda - - defaults dependencies: - bioconda::metabat2=2.15