From ccb3cd002ea09e97c4895ee0b22edeba2394395f Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Thu, 29 Aug 2024 16:43:03 +1200 Subject: [PATCH 1/2] Added nf-test for paragraph/vcf2paragraph --- .../nf-core/paragraph/vcf2paragraph/main.nf | 2 +- .../nf-core/paragraph/vcf2paragraph/meta.yml | 2 +- .../vcf2paragraph/tests/main.nf.test | 59 +++++++++++++++ .../vcf2paragraph/tests/main.nf.test.snap | 72 +++++++++++++++++++ tests/config/pytest_modules.yml | 3 - .../nf-core/paragraph/vcf2paragraph/main.nf | 20 ------ .../paragraph/vcf2paragraph/nextflow.config | 5 -- .../nf-core/paragraph/vcf2paragraph/test.yml | 9 --- 8 files changed, 133 insertions(+), 39 deletions(-) create mode 100644 modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test create mode 100644 modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test.snap delete mode 100644 tests/modules/nf-core/paragraph/vcf2paragraph/main.nf delete mode 100644 tests/modules/nf-core/paragraph/vcf2paragraph/nextflow.config delete mode 100644 tests/modules/nf-core/paragraph/vcf2paragraph/test.yml diff --git a/modules/nf-core/paragraph/vcf2paragraph/main.nf b/modules/nf-core/paragraph/vcf2paragraph/main.nf index f8efd94ee29..f9f30ebb4e5 100644 --- a/modules/nf-core/paragraph/vcf2paragraph/main.nf +++ b/modules/nf-core/paragraph/vcf2paragraph/main.nf @@ -48,7 +48,7 @@ process PARAGRAPH_VCF2PARAGRAPH { def VERSION = '2.3' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. """ - touch ${prefix}.json.gz + echo | gzip > ${prefix}.json.gz cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-core/paragraph/vcf2paragraph/meta.yml b/modules/nf-core/paragraph/vcf2paragraph/meta.yml index ab40b5023e5..c60991218c9 100644 --- a/modules/nf-core/paragraph/vcf2paragraph/meta.yml +++ b/modules/nf-core/paragraph/vcf2paragraph/meta.yml @@ -11,7 +11,7 @@ tools: documentation: "https://github.com/Illumina/paragraph" tool_dev_url: "https://github.com/Illumina/paragraph" doi: "10.1101/635011" - licence: "['Apache License 2.0']" + licence: ["Apache License 2.0"] input: - meta: type: map diff --git a/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test b/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test new file mode 100644 index 00000000000..5ca6381dcab --- /dev/null +++ b/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test @@ -0,0 +1,59 @@ + +nextflow_process { + + name "Test Process PARAGRAPH_VCF2PARAGRAPH" + script "../main.nf" + process "PARAGRAPH_VCF2PARAGRAPH" + + tag "modules" + tag "modules_nfcore" + tag "paragraph" + tag "paragraph/vcf2paragraph" + + test("test-paragraph-vcf2paragraph") { + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/haplotypecaller_calls/test_haplotcaller.cnn.vcf.gz', checkIfExists: true) + ] + input[1] = [ [], file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true) ] + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("test-paragraph-vcf2paragraph-stub") { + options '-stub' + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/haplotypecaller_calls/test_haplotcaller.cnn.vcf.gz', checkIfExists: true) + ] + input[1] = [ [], file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true) ] + + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + +} diff --git a/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test.snap b/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test.snap new file mode 100644 index 00000000000..68dfbd80645 --- /dev/null +++ b/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test.snap @@ -0,0 +1,72 @@ +{ + "test-paragraph-vcf2paragraph": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "test.json.gz:md5,68dce3f3713b691f9ab45744500871bf" + ] + ], + "1": [ + "versions.yml:md5,a7024dd35463d16da31df17264fdad6d" + ], + "graph": [ + [ + { + "id": "test", + "single_end": false + }, + "test.json.gz:md5,68dce3f3713b691f9ab45744500871bf" + ] + ], + "versions": [ + "versions.yml:md5,a7024dd35463d16da31df17264fdad6d" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.4" + }, + "timestamp": "2024-08-29T16:41:11.786699" + }, + "test-paragraph-vcf2paragraph-stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "test.json.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "1": [ + "versions.yml:md5,a7024dd35463d16da31df17264fdad6d" + ], + "graph": [ + [ + { + "id": "test", + "single_end": false + }, + "test.json.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "versions": [ + "versions.yml:md5,a7024dd35463d16da31df17264fdad6d" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.4" + }, + "timestamp": "2024-08-29T16:42:34.344697" + } +} \ No newline at end of file diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index f2c97100e45..6bd8b61159a 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -776,9 +776,6 @@ paragraph/idxdepth: paragraph/multigrmpy: - modules/nf-core/paragraph/multigrmpy/** - tests/modules/nf-core/paragraph/multigrmpy/** -paragraph/vcf2paragraph: - - modules/nf-core/paragraph/vcf2paragraph/** - - tests/modules/nf-core/paragraph/vcf2paragraph/** pasty: - modules/nf-core/pasty/** - tests/modules/nf-core/pasty/** diff --git a/tests/modules/nf-core/paragraph/vcf2paragraph/main.nf b/tests/modules/nf-core/paragraph/vcf2paragraph/main.nf deleted file mode 100644 index 5af197460f4..00000000000 --- a/tests/modules/nf-core/paragraph/vcf2paragraph/main.nf +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { PARAGRAPH_VCF2PARAGRAPH } from '../../../../../modules/nf-core/paragraph/vcf2paragraph/main.nf' - -workflow test_paragraph_vcf2paragraph { - - input = [ - [ id:'test', single_end:false ], // meta map - file(params.test_data['homo_sapiens']['illumina']['test_haplotc_cnn_vcf_gz'], checkIfExists: true) - ] - - fasta = [[], file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)] - - PARAGRAPH_VCF2PARAGRAPH ( - input, - fasta - ) -} diff --git a/tests/modules/nf-core/paragraph/vcf2paragraph/nextflow.config b/tests/modules/nf-core/paragraph/vcf2paragraph/nextflow.config deleted file mode 100644 index 50f50a7a357..00000000000 --- a/tests/modules/nf-core/paragraph/vcf2paragraph/nextflow.config +++ /dev/null @@ -1,5 +0,0 @@ -process { - - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - -} \ No newline at end of file diff --git a/tests/modules/nf-core/paragraph/vcf2paragraph/test.yml b/tests/modules/nf-core/paragraph/vcf2paragraph/test.yml deleted file mode 100644 index a4460066f59..00000000000 --- a/tests/modules/nf-core/paragraph/vcf2paragraph/test.yml +++ /dev/null @@ -1,9 +0,0 @@ -- name: paragraph vcf2paragraph test_paragraph_vcf2paragraph - command: nextflow run ./tests/modules/nf-core/paragraph/vcf2paragraph -entry test_paragraph_vcf2paragraph -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/paragraph/vcf2paragraph/nextflow.config - tags: - - paragraph/vcf2paragraph - - paragraph - files: - - path: output/paragraph/test.json.gz - md5sum: 4c7e676cb114a03c290668163bdc886a - - path: output/paragraph/versions.yml From 6744b1d67d680686aa5047e4a9dfac3bbfc87b7b Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Fri, 30 Aug 2024 10:56:02 +1200 Subject: [PATCH 2/2] Added version lock and trap --- .../paragraph/vcf2paragraph/environment.yml | 3 ++ .../vcf2paragraph/tests/main.nf.test | 7 ++- .../vcf2paragraph/tests/main.nf.test.snap | 43 ++++++++----------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/modules/nf-core/paragraph/vcf2paragraph/environment.yml b/modules/nf-core/paragraph/vcf2paragraph/environment.yml index 407d53d9c9c..4071e82f9b3 100644 --- a/modules/nf-core/paragraph/vcf2paragraph/environment.yml +++ b/modules/nf-core/paragraph/vcf2paragraph/environment.yml @@ -1,7 +1,10 @@ name: paragraph_vcf2paragraph + channels: - conda-forge - bioconda - defaults + dependencies: + - bioconda::htslib=1.10.2 - bioconda::paragraph=2.3 diff --git a/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test b/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test index 5ca6381dcab..16741305401 100644 --- a/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test +++ b/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test @@ -28,7 +28,12 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot(process.out).match() } + { assert snapshot( + process.out.graph, + process.out.versions, + file(process.out.versions[0]).readLines().collect { it.trim() } // Trap to catch conda version mismatches + ).match() + } ) } } diff --git a/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test.snap b/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test.snap index 68dfbd80645..63c8f7f1d77 100644 --- a/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test.snap +++ b/modules/nf-core/paragraph/vcf2paragraph/tests/main.nf.test.snap @@ -1,38 +1,29 @@ { "test-paragraph-vcf2paragraph": { "content": [ - { - "0": [ - [ - { - "id": "test", - "single_end": false - }, - "test.json.gz:md5,68dce3f3713b691f9ab45744500871bf" - ] - ], - "1": [ - "versions.yml:md5,a7024dd35463d16da31df17264fdad6d" - ], - "graph": [ - [ - { - "id": "test", - "single_end": false - }, - "test.json.gz:md5,68dce3f3713b691f9ab45744500871bf" - ] - ], - "versions": [ - "versions.yml:md5,a7024dd35463d16da31df17264fdad6d" + [ + [ + { + "id": "test", + "single_end": false + }, + "test.json.gz:md5,68dce3f3713b691f9ab45744500871bf" ] - } + ], + [ + "versions.yml:md5,a7024dd35463d16da31df17264fdad6d" + ], + [ + "\"PARAGRAPH_VCF2PARAGRAPH\":", + "paragraph: 2.3", + "bgzip: 1.10.2" + ] ], "meta": { "nf-test": "0.8.4", "nextflow": "24.04.4" }, - "timestamp": "2024-08-29T16:41:11.786699" + "timestamp": "2024-08-30T10:55:01.125722" }, "test-paragraph-vcf2paragraph-stub": { "content": [