From cee8fe33d3ef1a220dee67dac75a32f7c872f63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Famke=20B=C3=A4uerle?= <45968370+famosab@users.noreply.github.com> Date: Wed, 15 May 2024 13:49:01 +0200 Subject: [PATCH] port `gatk4/applyvqsr` to nf-test (#5604) * port to nf-test update stub * add more assertions * update snap * update tbi test and snap * change to check for filename --- modules/nf-core/gatk4/applyvqsr/main.nf | 2 +- .../applyvqsr/tests/allelspecificity.config | 5 + .../gatk4/applyvqsr/tests/main.nf.test | 106 ++++++++++++++++++ .../gatk4/applyvqsr/tests/main.nf.test.snap | 95 ++++++++++++++++ .../tests/no-allelspecificity.config | 5 + .../nf-core/gatk4/applyvqsr/tests/tags.yml | 2 + tests/config/pytest_modules.yml | 3 - tests/modules/nf-core/gatk4/applyvqsr/main.nf | 36 ------ .../nf-core/gatk4/applyvqsr/nextflow.config | 11 -- .../modules/nf-core/gatk4/applyvqsr/test.yml | 19 ---- 10 files changed, 214 insertions(+), 70 deletions(-) create mode 100644 modules/nf-core/gatk4/applyvqsr/tests/allelspecificity.config create mode 100644 modules/nf-core/gatk4/applyvqsr/tests/main.nf.test create mode 100644 modules/nf-core/gatk4/applyvqsr/tests/main.nf.test.snap create mode 100644 modules/nf-core/gatk4/applyvqsr/tests/no-allelspecificity.config create mode 100644 modules/nf-core/gatk4/applyvqsr/tests/tags.yml delete mode 100644 tests/modules/nf-core/gatk4/applyvqsr/main.nf delete mode 100644 tests/modules/nf-core/gatk4/applyvqsr/nextflow.config delete mode 100644 tests/modules/nf-core/gatk4/applyvqsr/test.yml diff --git a/modules/nf-core/gatk4/applyvqsr/main.nf b/modules/nf-core/gatk4/applyvqsr/main.nf index 0506e28185c..047321b8e9e 100644 --- a/modules/nf-core/gatk4/applyvqsr/main.nf +++ b/modules/nf-core/gatk4/applyvqsr/main.nf @@ -52,7 +52,7 @@ process GATK4_APPLYVQSR { stub: prefix = task.ext.prefix ?: "${meta.id}" """ - touch ${prefix}.vcf.gz + echo "" | gzip > ${prefix}.vcf.gz touch ${prefix}.vcf.gz.tbi cat <<-END_VERSIONS > versions.yml diff --git a/modules/nf-core/gatk4/applyvqsr/tests/allelspecificity.config b/modules/nf-core/gatk4/applyvqsr/tests/allelspecificity.config new file mode 100644 index 00000000000..ac368bd058b --- /dev/null +++ b/modules/nf-core/gatk4/applyvqsr/tests/allelspecificity.config @@ -0,0 +1,5 @@ +process { + withName: GATK4_APPLYVQSR { + ext.args = '--mode SNP --truth-sensitivity-filter-level 99.0 -AS' + } +} diff --git a/modules/nf-core/gatk4/applyvqsr/tests/main.nf.test b/modules/nf-core/gatk4/applyvqsr/tests/main.nf.test new file mode 100644 index 00000000000..104eb7f01b4 --- /dev/null +++ b/modules/nf-core/gatk4/applyvqsr/tests/main.nf.test @@ -0,0 +1,106 @@ +nextflow_process { + + name "Test Process GATK4_APPLYVQSR" + script "../main.nf" + process "GATK4_APPLYVQSR" + + tag "modules" + tag "modules_nfcore" + tag "gatk4" + tag "gatk4/applyvqsr" + + test("human - vcf") { + + config "./no-allelspecificity.config" + + when { + process { + """ + input[0] = [ [ id:'test'], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/haplotypecaller_calls/test2_haplotc.ann.vcf.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/haplotypecaller_calls/test2_haplotc.ann.vcf.gz.tbi', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/variantrecalibrator/test2.recal', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/variantrecalibrator/test2.recal.idx', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/variantrecalibrator/test2.tranches', checkIfExists: true) + ] + input[1] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true) + input[2] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true) + input[3] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.dict', checkIfExists: true) + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match("versions") }, + { assert path(process.out.vcf.get(0).get(1)).linesGzip.contains("##fileformat=VCFv4.2") }, + { assert snapshot(file(process.out.tbi.get(0).get(1)).name).match() } + ) + } + + } + + test("human - vcf - allele-specific") { + + config "./allelspecificity.config" + + when { + process { + """ + input[0] = [ [ id:'test'], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/haplotypecaller_calls/test2_haplotc.ann.vcf.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/haplotypecaller_calls/test2_haplotc.ann.vcf.gz.tbi', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/variantrecalibrator/test2_allele_specific.recal', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/variantrecalibrator/test2_allele_specific.recal.idx', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/variantrecalibrator/test2_allele_specific.tranches', checkIfExists: true) + ] + input[1] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true) + input[2] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true) + input[3] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.dict', checkIfExists: true) + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match("versions_allelspecific") }, + { assert path(process.out.vcf.get(0).get(1)).linesGzip.contains("##fileformat=VCFv4.2") }, + { assert snapshot(file(process.out.tbi.get(0).get(1)).name).match() } + ) + } + + } + + test("human - vcf - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ [ id:'test'], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/haplotypecaller_calls/test2_haplotc.ann.vcf.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/haplotypecaller_calls/test2_haplotc.ann.vcf.gz.tbi', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/variantrecalibrator/test2.recal', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/variantrecalibrator/test2.recal.idx', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/variantrecalibrator/test2.tranches', checkIfExists: true) + ] + input[1] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true) + input[2] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true) + input[3] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.dict', checkIfExists: true) + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/gatk4/applyvqsr/tests/main.nf.test.snap b/modules/nf-core/gatk4/applyvqsr/tests/main.nf.test.snap new file mode 100644 index 00000000000..ad2fe8be65a --- /dev/null +++ b/modules/nf-core/gatk4/applyvqsr/tests/main.nf.test.snap @@ -0,0 +1,95 @@ +{ + "human - vcf": { + "content": [ + "test.vcf.gz.tbi" + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.0" + }, + "timestamp": "2024-05-15T13:31:50.727658" + }, + "human - vcf - allele-specific": { + "content": [ + "test.vcf.gz.tbi" + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.0" + }, + "timestamp": "2024-05-15T13:29:42.331816" + }, + "versions": { + "content": [ + [ + "versions.yml:md5,4a6890d486a62ce6f2edfd2f8961da4f" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.0" + }, + "timestamp": "2024-05-15T13:00:49.353138" + }, + "human - vcf - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "1": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + "versions.yml:md5,4a6890d486a62ce6f2edfd2f8961da4f" + ], + "tbi": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "versions": [ + "versions.yml:md5,4a6890d486a62ce6f2edfd2f8961da4f" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.0" + }, + "timestamp": "2024-05-15T13:01:24.370421" + }, + "versions_allelspecific": { + "content": [ + [ + "versions.yml:md5,4a6890d486a62ce6f2edfd2f8961da4f" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.0" + }, + "timestamp": "2024-05-15T13:01:08.104194" + } +} \ No newline at end of file diff --git a/modules/nf-core/gatk4/applyvqsr/tests/no-allelspecificity.config b/modules/nf-core/gatk4/applyvqsr/tests/no-allelspecificity.config new file mode 100644 index 00000000000..c08c918e1a5 --- /dev/null +++ b/modules/nf-core/gatk4/applyvqsr/tests/no-allelspecificity.config @@ -0,0 +1,5 @@ +process { + withName: GATK4_APPLYVQSR { + ext.args = '--mode SNP --truth-sensitivity-filter-level 99.0' + } +} diff --git a/modules/nf-core/gatk4/applyvqsr/tests/tags.yml b/modules/nf-core/gatk4/applyvqsr/tests/tags.yml new file mode 100644 index 00000000000..c65706301ad --- /dev/null +++ b/modules/nf-core/gatk4/applyvqsr/tests/tags.yml @@ -0,0 +1,2 @@ +gatk4/applyvqsr: + - "modules/nf-core/gatk4/applyvqsr/**" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 28e277562f9..982956e9803 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -582,9 +582,6 @@ gatk/realignertargetcreator: gatk/unifiedgenotyper: - modules/nf-core/gatk/unifiedgenotyper/** - tests/modules/nf-core/gatk/unifiedgenotyper/** -gatk4/applyvqsr: - - modules/nf-core/gatk4/applyvqsr/** - - tests/modules/nf-core/gatk4/applyvqsr/** gatk4/calibratedragstrmodel: - modules/nf-core/gatk4/calibratedragstrmodel/** - tests/modules/nf-core/gatk4/calibratedragstrmodel/** diff --git a/tests/modules/nf-core/gatk4/applyvqsr/main.nf b/tests/modules/nf-core/gatk4/applyvqsr/main.nf deleted file mode 100644 index ea209478555..00000000000 --- a/tests/modules/nf-core/gatk4/applyvqsr/main.nf +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { GATK4_APPLYVQSR as GATK4_APPLYVQSR_NO_ALLELSPECIFICITY } from '../../../../../modules/nf-core/gatk4/applyvqsr/main.nf' -include { GATK4_APPLYVQSR as GATK4_APPLYVQSR_WITH_ALLELSPECIFICITY} from '../../../../../modules/nf-core/gatk4/applyvqsr/main.nf' - -workflow test_gatk4_applyvqsr { - input = [ [ id:'test'], // meta map - file(params.test_data['homo_sapiens']['illumina']['test2_haplotc_ann_vcf_gz'], checkIfExists: true), - file(params.test_data['homo_sapiens']['illumina']['test2_haplotc_ann_vcf_gz_tbi'], checkIfExists: true), - file(params.test_data['homo_sapiens']['illumina']['test2_recal'], checkIfExists: true), - file(params.test_data['homo_sapiens']['illumina']['test2_recal_idx'], checkIfExists: true), - file(params.test_data['homo_sapiens']['illumina']['test2_tranches'], checkIfExists: true) - ] - fasta = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) - fai = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta_fai'], checkIfExists: true) - dict = file(params.test_data['homo_sapiens']['genome']['genome_21_dict'], checkIfExists: true) - - GATK4_APPLYVQSR_NO_ALLELSPECIFICITY ( input, fasta, fai, dict ) -} - -workflow test_gatk4_applyvqsr_allele_specific { - input = [ [ id:'test'], // meta map - file(params.test_data['homo_sapiens']['illumina']['test2_haplotc_ann_vcf_gz'], checkIfExists: true), - file(params.test_data['homo_sapiens']['illumina']['test2_haplotc_ann_vcf_gz_tbi'], checkIfExists: true), - file(params.test_data['homo_sapiens']['illumina']['test2_allele_specific_recal'], checkIfExists: true), - file(params.test_data['homo_sapiens']['illumina']['test2_allele_specific_recal_idx'], checkIfExists: true), - file(params.test_data['homo_sapiens']['illumina']['test2_allele_specific_tranches'], checkIfExists: true) - ] - fasta = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) - fai = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta_fai'], checkIfExists: true) - dict = file(params.test_data['homo_sapiens']['genome']['genome_21_dict'], checkIfExists: true) - - GATK4_APPLYVQSR_WITH_ALLELSPECIFICITY ( input, fasta, fai, dict) -} diff --git a/tests/modules/nf-core/gatk4/applyvqsr/nextflow.config b/tests/modules/nf-core/gatk4/applyvqsr/nextflow.config deleted file mode 100644 index bf943c2337d..00000000000 --- a/tests/modules/nf-core/gatk4/applyvqsr/nextflow.config +++ /dev/null @@ -1,11 +0,0 @@ -process { - - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - withName: GATK4_APPLYVQSR_NO_ALLELSPECIFICITY { - ext.args = '--mode SNP --truth-sensitivity-filter-level 99.0' - } - - withName: GATK4_APPLYVQSR_WITH_ALLELSPECIFICITY { - ext.args = '--mode SNP --truth-sensitivity-filter-level 99.0 -AS' - } -} diff --git a/tests/modules/nf-core/gatk4/applyvqsr/test.yml b/tests/modules/nf-core/gatk4/applyvqsr/test.yml deleted file mode 100644 index 63e5ceba396..00000000000 --- a/tests/modules/nf-core/gatk4/applyvqsr/test.yml +++ /dev/null @@ -1,19 +0,0 @@ -- name: gatk4 applyvqsr test_gatk4_applyvqsr - command: nextflow run ./tests/modules/nf-core/gatk4/applyvqsr -entry test_gatk4_applyvqsr -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/gatk4/applyvqsr/nextflow.config - tags: - - gatk4/applyvqsr - - gatk4 - files: - - path: output/gatk4/test.vcf.gz - - path: output/gatk4/test.vcf.gz.tbi - - path: output/gatk4/versions.yml - -- name: gatk4 applyvqsr test_gatk4_applyvqsr_allele_specific - command: nextflow run ./tests/modules/nf-core/gatk4/applyvqsr -entry test_gatk4_applyvqsr_allele_specific -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/gatk4/applyvqsr/nextflow.config - tags: - - gatk4/applyvqsr - - gatk4 - files: - - path: output/gatk4/test.vcf.gz - - path: output/gatk4/test.vcf.gz.tbi - - path: output/gatk4/versions.yml