From fee2f3dcaaf3b9bf53cc65de4ddb69f8ec59b6e0 Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Thu, 22 Aug 2024 16:37:59 +1200 Subject: [PATCH 1/2] Added nf-test for vsearch/usearchglobal --- .../nf-core/vsearch/usearchglobal/meta.yml | 4 +- .../vsearch/usearchglobal/tests/main.nf.test | 59 +++++++ .../usearchglobal/tests/main.nf.test.snap | 164 ++++++++++++++++++ tests/config/pytest_modules.yml | 3 - .../nf-core/vsearch/usearchglobal/main.nf | 25 --- .../vsearch/usearchglobal/nextflow.config | 4 - .../nf-core/vsearch/usearchglobal/test.yml | 26 --- 7 files changed, 225 insertions(+), 60 deletions(-) create mode 100644 modules/nf-core/vsearch/usearchglobal/tests/main.nf.test create mode 100644 modules/nf-core/vsearch/usearchglobal/tests/main.nf.test.snap delete mode 100644 tests/modules/nf-core/vsearch/usearchglobal/main.nf delete mode 100644 tests/modules/nf-core/vsearch/usearchglobal/nextflow.config delete mode 100644 tests/modules/nf-core/vsearch/usearchglobal/test.yml diff --git a/modules/nf-core/vsearch/usearchglobal/meta.yml b/modules/nf-core/vsearch/usearchglobal/meta.yml index dc953946a17..ba56f1778e4 100644 --- a/modules/nf-core/vsearch/usearchglobal/meta.yml +++ b/modules/nf-core/vsearch/usearchglobal/meta.yml @@ -11,7 +11,7 @@ tools: homepage: "https://github.com/torognes/vsearch" tool_dev_url: "https://github.com/torognes/vsearch" doi: "10.7717/peerj.2584" - licence: "['GPL v3-or-later OR BSD-2-clause']" + licence: ["GPL v3-or-later OR BSD-2-clause"] input: - meta: type: map @@ -25,7 +25,7 @@ input: description: Reference database file in FASTA or UDB format pattern: "*" - idcutoff: - type: real + type: float description: Reject the sequence match if the pairwise identity is lower than the given id cutoff value (value ranging from 0.0 to 1.0 included) - outoption: type: string diff --git a/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test b/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test new file mode 100644 index 00000000000..4e8ec93bc60 --- /dev/null +++ b/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test @@ -0,0 +1,59 @@ + +nextflow_process { + + name "Test Process VSEARCH_USEARCHGLOBAL" + script "../main.nf" + process "VSEARCH_USEARCHGLOBAL" + + tag "modules" + tag "modules_nfcore" + tag "vsearch" + tag "vsearch/usearchglobal" + + test("test-vsearch-usearchglobal") { + + when { + process { + """ + input[0] = [[id:'test'], file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/transcriptome.fasta', checkIfExists: true)] + input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) + input[2] = 0.985 + input[3] = "xcfert" + input[4] = "" + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test-vsearch-usearchglobal-userout") { + + when { + process { + """ + input[0] = [[id:'test'], file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/transcriptome.fasta', checkIfExists: true)] + input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true) + input[2] = 0.985 + input[3] = "userout" + input[4] = "query+target+id" + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + +} diff --git a/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test.snap b/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test.snap new file mode 100644 index 00000000000..165de0ee4eb --- /dev/null +++ b/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test.snap @@ -0,0 +1,164 @@ +{ + "test-vsearch-usearchglobal": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.aln:md5,8d06b92689ddf08ecafecea883f656d6" + ] + ], + "1": [ + + ], + "2": [ + + ], + "3": [ + + ], + "4": [ + + ], + "5": [ + + ], + "6": [ + + ], + "7": [ + + ], + "8": [ + + ], + "9": [ + "versions.yml:md5,12310613a8f7129bab978fdfb8ac8bc4" + ], + "aln": [ + [ + { + "id": "test" + }, + "test.aln:md5,8d06b92689ddf08ecafecea883f656d6" + ] + ], + "biom": [ + + ], + "lca": [ + + ], + "mothur": [ + + ], + "otu": [ + + ], + "sam": [ + + ], + "tsv": [ + + ], + "txt": [ + + ], + "uc": [ + + ], + "versions": [ + "versions.yml:md5,12310613a8f7129bab978fdfb8ac8bc4" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.4" + }, + "timestamp": "2024-08-22T16:33:12.271626" + }, + "test-vsearch-usearchglobal-userout": { + "content": [ + { + "0": [ + + ], + "1": [ + + ], + "2": [ + + ], + "3": [ + + ], + "4": [ + + ], + "5": [ + + ], + "6": [ + [ + { + "id": "test" + }, + "test.tsv:md5,b6cc50f7c8d18cb82e74dab70ed4baab" + ] + ], + "7": [ + + ], + "8": [ + + ], + "9": [ + "versions.yml:md5,12310613a8f7129bab978fdfb8ac8bc4" + ], + "aln": [ + + ], + "biom": [ + + ], + "lca": [ + + ], + "mothur": [ + + ], + "otu": [ + + ], + "sam": [ + + ], + "tsv": [ + [ + { + "id": "test" + }, + "test.tsv:md5,b6cc50f7c8d18cb82e74dab70ed4baab" + ] + ], + "txt": [ + + ], + "uc": [ + + ], + "versions": [ + "versions.yml:md5,12310613a8f7129bab978fdfb8ac8bc4" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.4" + }, + "timestamp": "2024-08-22T16:33:20.01829" + } +} \ No newline at end of file diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index d56754160c9..364c105485b 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1668,9 +1668,6 @@ vrhyme/vrhyme: vsearch/sintax: - modules/nf-core/vsearch/sintax/** - tests/modules/nf-core/vsearch/sintax/** -vsearch/usearchglobal: - - modules/nf-core/vsearch/usearchglobal/** - - tests/modules/nf-core/vsearch/usearchglobal/** vt/decompose: - modules/nf-core/vt/decompose/** - tests/modules/nf-core/vt/decompose/** diff --git a/tests/modules/nf-core/vsearch/usearchglobal/main.nf b/tests/modules/nf-core/vsearch/usearchglobal/main.nf deleted file mode 100644 index 925f0cb2ac3..00000000000 --- a/tests/modules/nf-core/vsearch/usearchglobal/main.nf +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { VSEARCH_USEARCHGLOBAL } from '../../../../../modules/nf-core/vsearch/usearchglobal/main.nf' - -workflow test_vsearch_usearchglobal { - - query = file(params.test_data['sarscov2']['genome']['transcriptome_fasta'], checkIfExists: true) - db = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - idcutoff = 0.985 - outoption = "xcfert" // Nonsense text to check default case. - columns = "" - VSEARCH_USEARCHGLOBAL ( [[id:'test'], query], db, idcutoff, outoption, columns ) -} - -workflow test_vsearch_usearchglobal_userout { - - query = file(params.test_data['sarscov2']['genome']['transcriptome_fasta'], checkIfExists: true) - db = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - idcutoff = 0.985 - outoption = "userout" - columns = "query+target+id" - VSEARCH_USEARCHGLOBAL ( [[id:'test'], query], db, idcutoff, outoption, columns ) -} diff --git a/tests/modules/nf-core/vsearch/usearchglobal/nextflow.config b/tests/modules/nf-core/vsearch/usearchglobal/nextflow.config deleted file mode 100644 index 14f46dea7af..00000000000 --- a/tests/modules/nf-core/vsearch/usearchglobal/nextflow.config +++ /dev/null @@ -1,4 +0,0 @@ -process { - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } -} - diff --git a/tests/modules/nf-core/vsearch/usearchglobal/test.yml b/tests/modules/nf-core/vsearch/usearchglobal/test.yml deleted file mode 100644 index 9dcc8db45df..00000000000 --- a/tests/modules/nf-core/vsearch/usearchglobal/test.yml +++ /dev/null @@ -1,26 +0,0 @@ -- name: vsearch usearchglobal test_vsearch_usearchglobal - command: nextflow run ./tests/modules/nf-core/vsearch/usearchglobal -entry test_vsearch_usearchglobal -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/vsearch/usearchglobal/nextflow.config - tags: - - vsearch/usearchglobal - - vsearch - files: - - path: output/vsearch/test.aln - contains: - - "vsearch --usearch_global transcriptome.fasta --db genome.fasta --id 0.985 --threads 2 --alnout test.aln" - - "Query >lcl|MT192765.1_cds_QIK50427.1_2" - - "%Id TLen Target" - - "100% 29829 MT192765.1" - - "Query 3822nt >lcl|MT192765.1_cds_QIK50427.1_2" - - "Target 29829nt >MT192765.1" - - "Qry 21249 + CAACAGAGTTGTTATTTCTAGTGATGTTCTTGTTAACAACTAA 21291" - - "Tgt 21506 + CAACAGAGTTGTTATTTCTAGTGATGTTCTTGTTAACAACTAA 21548" - - "21291 cols, 21290 ids (100.0%), 1 gaps (0.0%)" - -- name: vsearch usearchglobal test_vsearch_usearchglobal_userout - command: nextflow run ./tests/modules/nf-core/vsearch/usearchglobal -entry test_vsearch_usearchglobal_userout -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/vsearch/usearchglobal/nextflow.config - tags: - - vsearch/usearchglobal - - vsearch - files: - - path: output/vsearch/test.tsv - md5sum: b6cc50f7c8d18cb82e74dab70ed4baab From 6a737fe3d29de48437d783c8e3eb2d059efee9a4 Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Thu, 22 Aug 2024 17:14:28 +1200 Subject: [PATCH 2/2] Updated power assertion --- .../vsearch/usearchglobal/tests/main.nf.test | 7 +- .../usearchglobal/tests/main.nf.test.snap | 78 ++----------------- 2 files changed, 11 insertions(+), 74 deletions(-) diff --git a/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test b/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test index 4e8ec93bc60..756895b41a0 100644 --- a/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test +++ b/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test @@ -28,7 +28,12 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot(process.out).match() } + { assert file(process.out.aln[0][1]).text.contains('Query >lcl|MT192765.1_cds_QIK50427.1_2') }, + { assert snapshot( + file(process.out.aln[0][1]).name, + process.out.versions + ).match() + } ) } } diff --git a/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test.snap b/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test.snap index 165de0ee4eb..5b1b348a12b 100644 --- a/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test.snap +++ b/modules/nf-core/vsearch/usearchglobal/tests/main.nf.test.snap @@ -1,84 +1,16 @@ { "test-vsearch-usearchglobal": { "content": [ - { - "0": [ - [ - { - "id": "test" - }, - "test.aln:md5,8d06b92689ddf08ecafecea883f656d6" - ] - ], - "1": [ - - ], - "2": [ - - ], - "3": [ - - ], - "4": [ - - ], - "5": [ - - ], - "6": [ - - ], - "7": [ - - ], - "8": [ - - ], - "9": [ - "versions.yml:md5,12310613a8f7129bab978fdfb8ac8bc4" - ], - "aln": [ - [ - { - "id": "test" - }, - "test.aln:md5,8d06b92689ddf08ecafecea883f656d6" - ] - ], - "biom": [ - - ], - "lca": [ - - ], - "mothur": [ - - ], - "otu": [ - - ], - "sam": [ - - ], - "tsv": [ - - ], - "txt": [ - - ], - "uc": [ - - ], - "versions": [ - "versions.yml:md5,12310613a8f7129bab978fdfb8ac8bc4" - ] - } + "test.aln", + [ + "versions.yml:md5,12310613a8f7129bab978fdfb8ac8bc4" + ] ], "meta": { "nf-test": "0.8.4", "nextflow": "24.04.4" }, - "timestamp": "2024-08-22T16:33:12.271626" + "timestamp": "2024-08-22T17:11:19.035984" }, "test-vsearch-usearchglobal-userout": { "content": [