From 606a549999ec6dac509ba112299d3b422faba359 Mon Sep 17 00:00:00 2001 From: karthikram-takara <77392523+karthikram-takara@users.noreply.github.com> Date: Tue, 7 May 2024 09:20:07 -0700 Subject: [PATCH] Add nf-test for biscuit/bsconv (#4493) * Add nf-test for biscuit/bsconv * Add stub and stub test --------- Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com> --- modules/nf-core/biscuit/bsconv/main.nf | 16 ++++ modules/nf-core/biscuit/bsconv/meta.yml | 2 +- .../nf-core/biscuit/bsconv/tests/main.nf.test | 75 +++++++++++++++++++ .../biscuit/bsconv/tests/main.nf.test.snap | 67 +++++++++++++++++ modules/nf-core/biscuit/bsconv/tests/tags.yml | 2 + tests/config/pytest_modules.yml | 4 - tests/modules/nf-core/biscuit/bsconv/main.nf | 19 ----- .../nf-core/biscuit/bsconv/nextflow.config | 10 --- tests/modules/nf-core/biscuit/bsconv/test.yml | 24 ------ 9 files changed, 161 insertions(+), 58 deletions(-) create mode 100644 modules/nf-core/biscuit/bsconv/tests/main.nf.test create mode 100644 modules/nf-core/biscuit/bsconv/tests/main.nf.test.snap create mode 100644 modules/nf-core/biscuit/bsconv/tests/tags.yml delete mode 100644 tests/modules/nf-core/biscuit/bsconv/main.nf delete mode 100644 tests/modules/nf-core/biscuit/bsconv/nextflow.config delete mode 100644 tests/modules/nf-core/biscuit/bsconv/test.yml diff --git a/modules/nf-core/biscuit/bsconv/main.nf b/modules/nf-core/biscuit/bsconv/main.nf index 1d7f1240a93..881fa0be813 100644 --- a/modules/nf-core/biscuit/bsconv/main.nf +++ b/modules/nf-core/biscuit/bsconv/main.nf @@ -37,4 +37,20 @@ process BISCUIT_BSCONV { biscuit: \$( biscuit version |& sed '1!d; s/^.*BISCUIT Version: //' ) END_VERSIONS """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + if ("$bam" == "${prefix}.bam") error "Input and output names are the same, set prefix in module configuration to disambiguate!" + + """ + touch ${prefix}.bam + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + biscuit: \$( biscuit version |& sed '1!d; s/^.*BISCUIT Version: //' ) + END_VERSIONS + """ + + } diff --git a/modules/nf-core/biscuit/bsconv/meta.yml b/modules/nf-core/biscuit/bsconv/meta.yml index e0919db3197..0db30255dfc 100644 --- a/modules/nf-core/biscuit/bsconv/meta.yml +++ b/modules/nf-core/biscuit/bsconv/meta.yml @@ -29,7 +29,7 @@ input: type: file description: BAM file index - index: - type: dir + type: directory description: Biscuit genome index directory (generated with 'biscuit index') pattern: "BiscuitIndex" output: diff --git a/modules/nf-core/biscuit/bsconv/tests/main.nf.test b/modules/nf-core/biscuit/bsconv/tests/main.nf.test new file mode 100644 index 00000000000..d62b9411df2 --- /dev/null +++ b/modules/nf-core/biscuit/bsconv/tests/main.nf.test @@ -0,0 +1,75 @@ +nextflow_process { + + name "Test Process BISCUIT_BSCONV" + script "../main.nf" + process "BISCUIT_BSCONV" + tag "modules" + tag "modules_nfcore" + tag "biscuit" + tag "biscuit/bsconv" + tag "biscuit/index" + + + setup { + run("BISCUIT_INDEX") { + script "../../index/main.nf" + process { + """ + input[0] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + """ + } + } + } + + test("sarscov2-pe - bam") { + + when { + process { + """ + input[0] = [ [id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam_bai'], checkIfExists: true) + ] + + input[1] = BISCUIT_INDEX.out.index + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.bsconv_bam).match("bsconv_bam") }, + { assert snapshot(process.out.versions).match("versions") } + ) + } + + } + + test("sarscov2-pe - bam - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ [id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam_bai'], checkIfExists: true) + ] + + input[1] = BISCUIT_INDEX.out.index + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/biscuit/bsconv/tests/main.nf.test.snap b/modules/nf-core/biscuit/bsconv/tests/main.nf.test.snap new file mode 100644 index 00000000000..96dc77c097b --- /dev/null +++ b/modules/nf-core/biscuit/bsconv/tests/main.nf.test.snap @@ -0,0 +1,67 @@ +{ + "versions": { + "content": [ + [ + "versions.yml:md5,45455cc9522a3235fa482ad065a242b3" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-05-07T15:28:04.601734997" + }, + "sarscov2-pe - bam - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "test.bam:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,45455cc9522a3235fa482ad065a242b3" + ], + "bsconv_bam": [ + [ + { + "id": "test", + "single_end": false + }, + "test.bam:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,45455cc9522a3235fa482ad065a242b3" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-05-07T15:28:14.729945289" + }, + "bsconv_bam": { + "content": [ + [ + [ + { + "id": "test", + "single_end": false + }, + "test.bam:md5,0d425851bd18963ebf1b6d727a7d02c7" + ] + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-05-07T15:28:04.580771449" + } +} \ No newline at end of file diff --git a/modules/nf-core/biscuit/bsconv/tests/tags.yml b/modules/nf-core/biscuit/bsconv/tests/tags.yml new file mode 100644 index 00000000000..5b890ac3597 --- /dev/null +++ b/modules/nf-core/biscuit/bsconv/tests/tags.yml @@ -0,0 +1,2 @@ +biscuit/bsconv: + - "modules/nf-core/biscuit/bsconv/**" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index ce5824b1d6c..129a20d44c6 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -195,10 +195,6 @@ biscuit/biscuitblaster: - modules/nf-core/biscuit/index/** - modules/nf-core/biscuit/biscuitblaster/** - tests/modules/nf-core/biscuit/biscuitblaster/** -biscuit/bsconv: - - modules/nf-core/biscuit/index/** - - modules/nf-core/biscuit/bsconv/** - - tests/modules/nf-core/biscuit/bsconv/** biscuit/epiread: - modules/nf-core/biscuit/index/** - modules/nf-core/biscuit/epiread/** diff --git a/tests/modules/nf-core/biscuit/bsconv/main.nf b/tests/modules/nf-core/biscuit/bsconv/main.nf deleted file mode 100644 index 14bc0e22439..00000000000 --- a/tests/modules/nf-core/biscuit/bsconv/main.nf +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { BISCUIT_INDEX } from '../../../../../modules/nf-core/biscuit/index/main.nf' -include { BISCUIT_BSCONV } from '../../../../../modules/nf-core/biscuit/bsconv/main.nf' - -workflow test_biscuit_bsconv { - - input = [ - [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam'], checkIfExists: true), - file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam_bai'], checkIfExists: true) - ] - fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - - BISCUIT_INDEX( fasta ) - BISCUIT_BSCONV ( input, BISCUIT_INDEX.out.index ) -} diff --git a/tests/modules/nf-core/biscuit/bsconv/nextflow.config b/tests/modules/nf-core/biscuit/bsconv/nextflow.config deleted file mode 100644 index 133905d0926..00000000000 --- a/tests/modules/nf-core/biscuit/bsconv/nextflow.config +++ /dev/null @@ -1,10 +0,0 @@ -process { - - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - - withName: '.*BISCUIT_BSCONV' { - ext.args = '-f 0.1' - } - -} - diff --git a/tests/modules/nf-core/biscuit/bsconv/test.yml b/tests/modules/nf-core/biscuit/bsconv/test.yml deleted file mode 100644 index 7d4a728f571..00000000000 --- a/tests/modules/nf-core/biscuit/bsconv/test.yml +++ /dev/null @@ -1,24 +0,0 @@ -- name: biscuit bsconv test_biscuit_bsconv - command: nextflow run ./tests/modules/nf-core/biscuit/bsconv -entry test_biscuit_bsconv -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/biscuit/bsconv/nextflow.config - tags: - - biscuit - - biscuit/bsconv - files: - - path: output/biscuit/BiscuitIndex/genome.fasta - md5sum: 6e9fe4042a72f2345f644f239272b7e6 - - path: output/biscuit/BiscuitIndex/genome.fasta.bis.amb - md5sum: 3a68b8b2287e07dd3f5f95f4344ba76e - - path: output/biscuit/BiscuitIndex/genome.fasta.bis.ann - md5sum: c32e11f6c859f166c7525a9c1d583567 - - path: output/biscuit/BiscuitIndex/genome.fasta.bis.pac - md5sum: 983e3d2cd6f36e2546e6d25a0da78d66 - - path: output/biscuit/BiscuitIndex/genome.fasta.dau.bwt - md5sum: a11bc31775f7b7a4f9cd3bc4f981661a - - path: output/biscuit/BiscuitIndex/genome.fasta.dau.sa - md5sum: 9c9e07fa1c75ef32d764274579c89b08 - - path: output/biscuit/BiscuitIndex/genome.fasta.par.bwt - md5sum: 62eb83cd557a47b59589713d98024fc2 - - path: output/biscuit/BiscuitIndex/genome.fasta.par.sa - md5sum: 55bcd97d7059bf73dc0d221e36e8e901 - - path: output/biscuit/test.bam - md5sum: e33e9498d00dd32222b90a6bd981226f