From 34eb86c8e8288d049233e6359d09f13f7b8a223c Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Fri, 6 Sep 2024 01:29:28 +1200 Subject: [PATCH] Added nf-test for homer/annotatepeaks (#6573) --- modules/nf-core/homer/annotatepeaks/main.nf | 12 ++++ .../homer/annotatepeaks/tests/main.nf.test | 68 +++++++++++++++++++ .../annotatepeaks/tests/main.nf.test.snap | 62 +++++++++++++++++ .../homer/annotatepeaks/tests/nextflow.config | 3 + tests/config/pytest_modules.yml | 3 - .../nf-core/homer/annotatepeaks/main.nf | 14 ---- .../homer/annotatepeaks/nextflow.config | 6 -- .../nf-core/homer/annotatepeaks/test.yml | 8 --- 8 files changed, 145 insertions(+), 31 deletions(-) create mode 100644 modules/nf-core/homer/annotatepeaks/tests/main.nf.test create mode 100644 modules/nf-core/homer/annotatepeaks/tests/main.nf.test.snap create mode 100644 modules/nf-core/homer/annotatepeaks/tests/nextflow.config delete mode 100644 tests/modules/nf-core/homer/annotatepeaks/main.nf delete mode 100644 tests/modules/nf-core/homer/annotatepeaks/nextflow.config delete mode 100644 tests/modules/nf-core/homer/annotatepeaks/test.yml diff --git a/modules/nf-core/homer/annotatepeaks/main.nf b/modules/nf-core/homer/annotatepeaks/main.nf index 32478df4124c..d3d752c8302e 100644 --- a/modules/nf-core/homer/annotatepeaks/main.nf +++ b/modules/nf-core/homer/annotatepeaks/main.nf @@ -39,4 +39,16 @@ process HOMER_ANNOTATEPEAKS { homer: $VERSION END_VERSIONS """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + def VERSION = '4.11' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. + """ + touch ${prefix}.annotatePeaks.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + homer: $VERSION + END_VERSIONS + """ } diff --git a/modules/nf-core/homer/annotatepeaks/tests/main.nf.test b/modules/nf-core/homer/annotatepeaks/tests/main.nf.test new file mode 100644 index 000000000000..e54c4b907681 --- /dev/null +++ b/modules/nf-core/homer/annotatepeaks/tests/main.nf.test @@ -0,0 +1,68 @@ + +nextflow_process { + + name "Test Process HOMER_ANNOTATEPEAKS" + script "../main.nf" + process "HOMER_ANNOTATEPEAKS" + config "./nextflow.config" + + tag "modules" + tag "modules_nfcore" + tag "homer" + tag "homer/annotatepeaks" + + test("test-homer-annotatepeaks") { + + when { + process { + """ + input[0] = [ + [ id:'test'], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed', checkIfExists: true) + ] + input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) + input[2] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gtf', checkIfExists: true) + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + file(process.out.txt[0][1]).name, // unstable + process.out.stats, + process.out.versions + ).match() + } + ) + } + } + + test("test-homer-annotatepeaks-stub") { + options '-stub' + + when { + process { + """ + input[0] = [ + [ id:'test'], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed', checkIfExists: true) + ] + input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) + input[2] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gtf', checkIfExists: true) + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + +} diff --git a/modules/nf-core/homer/annotatepeaks/tests/main.nf.test.snap b/modules/nf-core/homer/annotatepeaks/tests/main.nf.test.snap new file mode 100644 index 000000000000..0d6c813b2b13 --- /dev/null +++ b/modules/nf-core/homer/annotatepeaks/tests/main.nf.test.snap @@ -0,0 +1,62 @@ +{ + "test-homer-annotatepeaks-stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.annotatePeaks.txt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + + ], + "2": [ + "versions.yml:md5,d109521b6e43672cf246fd269b3833c8" + ], + "stats": [ + + ], + "txt": [ + [ + { + "id": "test" + }, + "test.annotatePeaks.txt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,d109521b6e43672cf246fd269b3833c8" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-05T21:21:30.264399" + }, + "test-homer-annotatepeaks": { + "content": [ + "test.annotatePeaks.txt", + [ + [ + { + "id": "test" + }, + "test.annStats.txt:md5,eba336bce28fb5ec5d4ea3215b502dc5" + ] + ], + [ + "versions.yml:md5,d109521b6e43672cf246fd269b3833c8" + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-05T21:28:26.487711" + } +} \ No newline at end of file diff --git a/modules/nf-core/homer/annotatepeaks/tests/nextflow.config b/modules/nf-core/homer/annotatepeaks/tests/nextflow.config new file mode 100644 index 000000000000..309aac551b00 --- /dev/null +++ b/modules/nf-core/homer/annotatepeaks/tests/nextflow.config @@ -0,0 +1,3 @@ +process { + ext.args = {"-annStats ${meta.id}.annStats.txt"} +} diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index b522eeb58f40..9da0e502f277 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -359,9 +359,6 @@ hmmer/hmmbuild: hmtnote/annotate: - modules/nf-core/hmtnote/annotate/** - tests/modules/nf-core/hmtnote/annotate/** -homer/annotatepeaks: - - modules/nf-core/homer/annotatepeaks/** - - tests/modules/nf-core/homer/annotatepeaks/** homer/makeucscfile: - modules/nf-core/homer/makeucscfile/** - tests/modules/nf-core/homer/makeucscfile/** diff --git a/tests/modules/nf-core/homer/annotatepeaks/main.nf b/tests/modules/nf-core/homer/annotatepeaks/main.nf deleted file mode 100644 index cfd52c1ba494..000000000000 --- a/tests/modules/nf-core/homer/annotatepeaks/main.nf +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { HOMER_ANNOTATEPEAKS } from '../../../../../modules/nf-core/homer/annotatepeaks/main.nf' - -workflow test_homer_annotatepeaks { - input = [ [ id:'test'], - file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true) - ] - fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - gtf = file(params.test_data['sarscov2']['genome']['genome_gtf'], checkIfExists: true) - HOMER_ANNOTATEPEAKS ( input, fasta, gtf ) -} diff --git a/tests/modules/nf-core/homer/annotatepeaks/nextflow.config b/tests/modules/nf-core/homer/annotatepeaks/nextflow.config deleted file mode 100644 index 86470e916848..000000000000 --- a/tests/modules/nf-core/homer/annotatepeaks/nextflow.config +++ /dev/null @@ -1,6 +0,0 @@ -process { - - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - ext.args = {"-annStats ${meta.id}.annStats.txt"} - -} diff --git a/tests/modules/nf-core/homer/annotatepeaks/test.yml b/tests/modules/nf-core/homer/annotatepeaks/test.yml deleted file mode 100644 index 9a07bc5d597e..000000000000 --- a/tests/modules/nf-core/homer/annotatepeaks/test.yml +++ /dev/null @@ -1,8 +0,0 @@ -- name: homer annotatepeaks test_homer_annotatepeaks - command: nextflow run ./tests/modules/nf-core/homer/annotatepeaks -entry test_homer_annotatepeaks -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/homer/annotatepeaks/nextflow.config - tags: - - homer - - homer/annotatepeaks - files: - - path: output/homer/test.annotatePeaks.txt - - path: output/homer/test.annStats.txt