From 749d72f162cb1493dca66b454064ed201de2cd95 Mon Sep 17 00:00:00 2001 From: Leon Hafner <60394289+LeonHafner@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:50:17 +0200 Subject: [PATCH] Added nf-test for bedtools/intersect (#6658) * migrate bedtools/intersect to nftest * changed test file paths --------- Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com> --- .../bedtools/intersect/tests/main.nf.test | 90 ++++++++++++++++ .../intersect/tests/main.nf.test.snap | 101 ++++++++++++++++++ .../bedtools/intersect/tests/nextflow.config | 5 + .../nf-core/bedtools/intersect/tests/tags.yml | 2 + tests/config/pytest_modules.yml | 3 - .../nf-core/bedtools/intersect/main.nf | 27 ----- .../bedtools/intersect/nextflow.config | 14 --- .../nf-core/bedtools/intersect/test.yml | 17 --- 8 files changed, 198 insertions(+), 61 deletions(-) create mode 100644 modules/nf-core/bedtools/intersect/tests/main.nf.test create mode 100644 modules/nf-core/bedtools/intersect/tests/main.nf.test.snap create mode 100644 modules/nf-core/bedtools/intersect/tests/nextflow.config create mode 100644 modules/nf-core/bedtools/intersect/tests/tags.yml delete mode 100644 tests/modules/nf-core/bedtools/intersect/main.nf delete mode 100644 tests/modules/nf-core/bedtools/intersect/nextflow.config delete mode 100644 tests/modules/nf-core/bedtools/intersect/test.yml diff --git a/modules/nf-core/bedtools/intersect/tests/main.nf.test b/modules/nf-core/bedtools/intersect/tests/main.nf.test new file mode 100644 index 00000000000..cd77094679d --- /dev/null +++ b/modules/nf-core/bedtools/intersect/tests/main.nf.test @@ -0,0 +1,90 @@ +nextflow_process { + + name "Test Process BEDTOOLS_INTERSECT" + script "../main.nf" + process "BEDTOOLS_INTERSECT" + config "./nextflow.config" + + tag "modules" + tag "modules_nfcore" + tag "bedtools" + tag "bedtools/intersect" + + test("sarscov2 - bed - bed") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test2.bed', checkIfExists: true) + ] + + input[1] = [[:], []] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + + test("sarscov2 - bam - bam") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/baits.bed', checkIfExists: true) + ] + + input[1] = [[:], []] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + + test("sarscov2 - bed - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test.bed', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/bed/test2.bed', checkIfExists: true) + ] + + input[1] = [[:], []] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/bedtools/intersect/tests/main.nf.test.snap b/modules/nf-core/bedtools/intersect/tests/main.nf.test.snap new file mode 100644 index 00000000000..b748dd499e4 --- /dev/null +++ b/modules/nf-core/bedtools/intersect/tests/main.nf.test.snap @@ -0,0 +1,101 @@ +{ + "sarscov2 - bam - bam": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_out.bam:md5,738324efe2b1e442ceb6539a630c3fe6" + ] + ], + "1": [ + "versions.yml:md5,42ba439339672f4a9193f0f0fe7a7f64" + ], + "intersect": [ + [ + { + "id": "test" + }, + "test_out.bam:md5,738324efe2b1e442ceb6539a630c3fe6" + ] + ], + "versions": [ + "versions.yml:md5,42ba439339672f4a9193f0f0fe7a7f64" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-17T20:55:57.454847668" + }, + "sarscov2 - bed - bed": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_out.bed:md5,afcbf01c2f2013aad71dbe8e34f2c15c" + ] + ], + "1": [ + "versions.yml:md5,42ba439339672f4a9193f0f0fe7a7f64" + ], + "intersect": [ + [ + { + "id": "test" + }, + "test_out.bed:md5,afcbf01c2f2013aad71dbe8e34f2c15c" + ] + ], + "versions": [ + "versions.yml:md5,42ba439339672f4a9193f0f0fe7a7f64" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-17T20:55:49.072132931" + }, + "sarscov2 - bed - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_out.bed:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,42ba439339672f4a9193f0f0fe7a7f64" + ], + "intersect": [ + [ + { + "id": "test" + }, + "test_out.bed:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,42ba439339672f4a9193f0f0fe7a7f64" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-17T20:56:06.259192552" + } +} \ No newline at end of file diff --git a/modules/nf-core/bedtools/intersect/tests/nextflow.config b/modules/nf-core/bedtools/intersect/tests/nextflow.config new file mode 100644 index 00000000000..f1f9e6937fb --- /dev/null +++ b/modules/nf-core/bedtools/intersect/tests/nextflow.config @@ -0,0 +1,5 @@ +process { + withName: BEDTOOLS_INTERSECT { + ext.prefix = { "${meta.id}_out" } + } +} diff --git a/modules/nf-core/bedtools/intersect/tests/tags.yml b/modules/nf-core/bedtools/intersect/tests/tags.yml new file mode 100644 index 00000000000..6219cc40b59 --- /dev/null +++ b/modules/nf-core/bedtools/intersect/tests/tags.yml @@ -0,0 +1,2 @@ +bedtools/intersect: + - "modules/nf-core/bedtools/intersect/**" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index b9c06ca0132..d9519ace74a 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -40,9 +40,6 @@ bbmap/align: bcftools/convert: - modules/nf-core/bcftools/convert/** - tests/modules/nf-core/bcftools/convert/** -bedtools/intersect: - - modules/nf-core/bedtools/intersect/** - - tests/modules/nf-core/bedtools/intersect/** bedtools/unionbedg: - modules/nf-core/bedtools/unionbedg/** - tests/modules/nf-core/bedtools/unionbedg/** diff --git a/tests/modules/nf-core/bedtools/intersect/main.nf b/tests/modules/nf-core/bedtools/intersect/main.nf deleted file mode 100644 index 1b924bb5c97..00000000000 --- a/tests/modules/nf-core/bedtools/intersect/main.nf +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { BEDTOOLS_INTERSECT } from '../../../../../modules/nf-core/bedtools/intersect/main.nf' -include { BEDTOOLS_INTERSECT as BEDTOOLS_INTERSECT_BAM } from '../../../../../modules/nf-core/bedtools/intersect/main.nf' - -workflow test_bedtools_intersect { - input = [ - [ id:'test' ], - file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true), - file(params.test_data['sarscov2']['genome']['test2_bed'], checkIfExists: true) - ] - - - BEDTOOLS_INTERSECT ( input, [[:],[]] ) -} - -workflow test_bedtools_intersect_bam { - input = [ - [ id:'test' ], - file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true), - file(params.test_data['sarscov2']['genome']['baits_bed'], checkIfExists: true) - ] - - BEDTOOLS_INTERSECT_BAM ( input, [[:],[]] ) -} diff --git a/tests/modules/nf-core/bedtools/intersect/nextflow.config b/tests/modules/nf-core/bedtools/intersect/nextflow.config deleted file mode 100644 index 8343cd66520..00000000000 --- a/tests/modules/nf-core/bedtools/intersect/nextflow.config +++ /dev/null @@ -1,14 +0,0 @@ -process { - - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - - withName: BEDTOOLS_INTERSECT { - ext.prefix = { "${meta.id}_out" } - } - - withName: BEDTOOLS_INTERSECT_BAM { - ext.prefix = { "${meta.id}_out" } - ext.suffix = "bam" - } - -} diff --git a/tests/modules/nf-core/bedtools/intersect/test.yml b/tests/modules/nf-core/bedtools/intersect/test.yml deleted file mode 100644 index fc96a00b71e..00000000000 --- a/tests/modules/nf-core/bedtools/intersect/test.yml +++ /dev/null @@ -1,17 +0,0 @@ -- name: bedtools intersect test_bedtools_intersect - command: nextflow run ./tests/modules/nf-core/bedtools/intersect -entry test_bedtools_intersect -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bedtools/intersect/nextflow.config - tags: - - bedtools - - bedtools/intersect - files: - - path: output/bedtools/test_out.bed - md5sum: afcbf01c2f2013aad71dbe8e34f2c15c - -- name: bedtools intersect test_bedtools_intersect_bam - command: nextflow run ./tests/modules/nf-core/bedtools/intersect -entry test_bedtools_intersect_bam -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bedtools/intersect/nextflow.config - tags: - - bedtools - - bedtools/intersect - files: - - path: output/bedtools/test_out.bam - md5sum: 738324efe2b1e442ceb6539a630c3fe6