From 91e7b15ab14d3d08ed6713209cd6e7c1278fcb01 Mon Sep 17 00:00:00 2001 From: Simon Pearce <24893913+SPPearce@users.noreply.github.com> Date: Thu, 18 Jul 2024 10:03:55 +0000 Subject: [PATCH 1/3] Swap samtools dict to nftest --- .../nf-core/samtools/dict/tests/main.nf.test | 59 +++++++++++++++++++ .../samtools/dict/tests/main.nf.test.snap | 49 +++++++++++++++ tests/config/pytest_modules.yml | 3 - tests/modules/nf-core/samtools/dict/main.nf | 13 ---- .../nf-core/samtools/dict/nextflow.config | 5 -- tests/modules/nf-core/samtools/dict/test.yml | 12 ---- 6 files changed, 108 insertions(+), 33 deletions(-) create mode 100644 modules/nf-core/samtools/dict/tests/main.nf.test create mode 100644 modules/nf-core/samtools/dict/tests/main.nf.test.snap delete mode 100644 tests/modules/nf-core/samtools/dict/main.nf delete mode 100644 tests/modules/nf-core/samtools/dict/nextflow.config delete mode 100644 tests/modules/nf-core/samtools/dict/test.yml diff --git a/modules/nf-core/samtools/dict/tests/main.nf.test b/modules/nf-core/samtools/dict/tests/main.nf.test new file mode 100644 index 00000000000..bcb74f60785 --- /dev/null +++ b/modules/nf-core/samtools/dict/tests/main.nf.test @@ -0,0 +1,59 @@ +nextflow_process { + + name "Test Process SAMTOOLS_DICT" + script "../main.nf" + process "SAMTOOLS_DICT" + + tag "modules" + tag "modules_nfcore" + tag "samtools" + tag "samtools/dict" + + test("sarscov2 - fasta") { + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match() }, + { assert path(process.out.dict[0][1]).readLines().first().contains("@HD\tVN:1.0\tSO:unsorted") } + ) + } + + } + + test("sarscov2 - fasta - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/samtools/dict/tests/main.nf.test.snap b/modules/nf-core/samtools/dict/tests/main.nf.test.snap new file mode 100644 index 00000000000..760bcab3a9c --- /dev/null +++ b/modules/nf-core/samtools/dict/tests/main.nf.test.snap @@ -0,0 +1,49 @@ +{ + "sarscov2 - fasta - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "genome.fasta.dict:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,47f9e889ed1e779cb54e61d707a7135d" + ], + "dict": [ + [ + { + "id": "test", + "single_end": false + }, + "genome.fasta.dict:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,47f9e889ed1e779cb54e61d707a7135d" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.3" + }, + "timestamp": "2024-07-18T09:43:30.509703257" + }, + "sarscov2 - fasta": { + "content": [ + [ + "versions.yml:md5,0af6b2d2d6d9d96bc5abe98b99b91446" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.3" + }, + "timestamp": "2024-07-18T09:51:18.221597999" + } +} \ No newline at end of file diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 49aed145a6b..e1c73c5d403 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1346,9 +1346,6 @@ samtools/collatefastq: samtools/depth: - modules/nf-core/samtools/depth/** - tests/modules/nf-core/samtools/depth/** -samtools/dict: - - modules/nf-core/samtools/dict/** - - tests/modules/nf-core/samtools/dict/** samtools/fasta: - modules/nf-core/samtools/fasta/** - tests/modules/nf-core/samtools/fasta/** diff --git a/tests/modules/nf-core/samtools/dict/main.nf b/tests/modules/nf-core/samtools/dict/main.nf deleted file mode 100644 index 7bac114a4f1..00000000000 --- a/tests/modules/nf-core/samtools/dict/main.nf +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { SAMTOOLS_DICT } from '../../../../../modules/nf-core/samtools/dict/main.nf' - -workflow test_samtools_dict { - - input = [ [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) ] - - SAMTOOLS_DICT ( input ) -} diff --git a/tests/modules/nf-core/samtools/dict/nextflow.config b/tests/modules/nf-core/samtools/dict/nextflow.config deleted file mode 100644 index 8730f1c4b93..00000000000 --- a/tests/modules/nf-core/samtools/dict/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/samtools/dict/test.yml b/tests/modules/nf-core/samtools/dict/test.yml deleted file mode 100644 index a037744fc8a..00000000000 --- a/tests/modules/nf-core/samtools/dict/test.yml +++ /dev/null @@ -1,12 +0,0 @@ -- name: samtools dict test_samtools_dict - command: nextflow run ./tests/modules/nf-core/samtools/dict -entry test_samtools_dict -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/samtools/dict/nextflow.config - tags: - - samtools/dict - - samtools - files: - - path: output/samtools/genome.fasta.dict - contains: - - "SN:MT192765.1" - - "LN:29829" - - "M5:c95f3e5592d0ad9974e41e7f0ea14eb0" - - path: output/samtools/versions.yml From 6f6acd9846b7dcd612708a144ecedf249fdb16e5 Mon Sep 17 00:00:00 2001 From: Simon Pearce <24893913+SPPearce@users.noreply.github.com> Date: Mon, 29 Jul 2024 09:00:18 +0000 Subject: [PATCH 2/3] Change test path --- modules/nf-core/samtools/dict/tests/main.nf.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/nf-core/samtools/dict/tests/main.nf.test b/modules/nf-core/samtools/dict/tests/main.nf.test index bcb74f60785..d712f6a7f8b 100644 --- a/modules/nf-core/samtools/dict/tests/main.nf.test +++ b/modules/nf-core/samtools/dict/tests/main.nf.test @@ -16,7 +16,7 @@ nextflow_process { """ input[0] = [ [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) ] """ } @@ -41,7 +41,7 @@ nextflow_process { """ input[0] = [ [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) ] """ } From 0fef8f4e160a53f558d6c77969cd374850057e9d Mon Sep 17 00:00:00 2001 From: Simon Pearce <24893913+SPPearce@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:33:07 +0000 Subject: [PATCH 3/3] Explicitly test first line of the dict --- modules/nf-core/samtools/dict/tests/main.nf.test | 7 +++++-- modules/nf-core/samtools/dict/tests/main.nf.test.snap | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/nf-core/samtools/dict/tests/main.nf.test b/modules/nf-core/samtools/dict/tests/main.nf.test index d712f6a7f8b..c467081f82f 100644 --- a/modules/nf-core/samtools/dict/tests/main.nf.test +++ b/modules/nf-core/samtools/dict/tests/main.nf.test @@ -25,8 +25,11 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot(process.out.versions).match() }, - { assert path(process.out.dict[0][1]).readLines().first().contains("@HD\tVN:1.0\tSO:unsorted") } + { assert snapshot( + path(process.out.dict[0][1]).readLines()[0], + process.out.versions + ).match() + } ) } diff --git a/modules/nf-core/samtools/dict/tests/main.nf.test.snap b/modules/nf-core/samtools/dict/tests/main.nf.test.snap index 760bcab3a9c..66d7b1fcff5 100644 --- a/modules/nf-core/samtools/dict/tests/main.nf.test.snap +++ b/modules/nf-core/samtools/dict/tests/main.nf.test.snap @@ -36,14 +36,15 @@ }, "sarscov2 - fasta": { "content": [ + "@HD\tVN:1.0\tSO:unsorted", [ "versions.yml:md5,0af6b2d2d6d9d96bc5abe98b99b91446" ] ], "meta": { - "nf-test": "0.8.4", + "nf-test": "0.9.0", "nextflow": "24.04.3" }, - "timestamp": "2024-07-18T09:51:18.221597999" + "timestamp": "2024-07-30T12:12:31.201483952" } } \ No newline at end of file