Skip to content

Commit

Permalink
Convert ngscheckmate/vafncm to nf-test (nf-core#5696)
Browse files Browse the repository at this point in the history
* Add tests for vafncm

* Fix linting
  • Loading branch information
SPPearce committed May 26, 2024
1 parent 84718c5 commit 0b94aea
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 119 deletions.
1 change: 1 addition & 0 deletions modules/nf-core/ngscheckmate/vafncm/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ process NGSCHECKMATE_VAFNCM {

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

"""
touch ${prefix}_corr_matrix.txt
Expand Down
155 changes: 155 additions & 0 deletions modules/nf-core/ngscheckmate/vafncm/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
nextflow_process {

name "Test Process NGSCHECKMATE_VAFNCM"
script "../main.nf"
config "./nextflow.config"
process "NGSCHECKMATE_VAFNCM"

tag "modules"
tag "modules_nfcore"
tag "ngscheckmate"
tag "ngscheckmate/vafncm"
tag "gawk"
tag "bedtools/makewindows"
tag "bowtie/build"
tag "ngscheckmate/patterngenerator"
tag "ngscheckmate/fastq"

setup {

run("GAWK" , alias: "GAWK_FAI") {
script "../../../gawk/main.nf"
process {
"""
input[0] = [
[ id: 'sarscov2' ],
file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true)
]
input[1] = []
"""
}
}

run("BEDTOOLS_MAKEWINDOWS") {
script "../../../bedtools/makewindows/main.nf"
process {
"""
input[0] = GAWK_FAI.out.output
"""
}
}

run("GAWK" , alias: "GAWK_BED") {
script "../../../gawk/main.nf"
process {
"""
input[0] = BEDTOOLS_MAKEWINDOWS.out.bed
input[1] = []
"""
}
}

run("BOWTIE_BUILD") {
script "../../../bowtie/build/main.nf"
process {
"""
input[0] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
"""
}
}

run("NGSCHECKMATE_PATTERNGENERATOR") {
script "../../patterngenerator/main.nf"
process {
"""
input[0] = GAWK_BED.out.output
input[1] = [
[ id: 'sarscov2' ],
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
input[2] = BOWTIE_BUILD.out.index
"""
}
}

run("NGSCHECKMATE_FASTQ") {
script "../../fastq/main.nf"
process {
"""
input[0] = channel.fromList(
[
[
[ id:'test1', single_end:false ], // meta map
[
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true)
]
],
[
[ id:'test2', single_end:false ], // meta map
[
file(params.test_data['sarscov2']['illumina']['test2_1_fastq_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test2_2_fastq_gz'], checkIfExists: true)
]
],
[
[ id:'test3', single_end:false ], // meta map
[
file(params.test_data['sarscov2']['illumina']['test_methylated_1_fastq_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_methylated_2_fastq_gz'], checkIfExists: true)
]
],
]
)
input[1] = NGSCHECKMATE_PATTERNGENERATOR.out.pt
"""
}
}

}

test("sarscov2 - fastq") {

when {
process {
"""
input[0] = NGSCHECKMATE_FASTQ.out.vaf.map{it[1]}.collect().map{files -> [[id:"combined"], files]}
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.corr_matrix,
process.out.matched,
process.out.all,
process.out.versions).match() }
)
}

}

test("sarscov2 - fastq - stub") {

options "-stub"

when {
process {
"""
input[0] = NGSCHECKMATE_FASTQ.out.vaf.map{it[1]}.collect().map{files -> [[id:"combined"], files]}
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
119 changes: 119 additions & 0 deletions modules/nf-core/ngscheckmate/vafncm/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"sarscov2 - fastq - stub": {
"content": [
{
"0": [
[
{
"id": "combined"
},
"combined.pdf:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
[
{
"id": "combined"
},
"combined_corr_matrix.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"2": [
[
{
"id": "combined"
},
"combined_all.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"3": [
[
{
"id": "combined"
},
"combined_matched.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"4": [
"versions.yml:md5,e8fcb7ac4528e05b40b58825c13220f0"
],
"all": [
[
{
"id": "combined"
},
"combined_all.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"corr_matrix": [
[
{
"id": "combined"
},
"combined_corr_matrix.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"matched": [
[
{
"id": "combined"
},
"combined_matched.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"pdf": [
[
{
"id": "combined"
},
"combined.pdf:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,e8fcb7ac4528e05b40b58825c13220f0"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.1"
},
"timestamp": "2024-05-26T08:37:18.164420662"
},
"sarscov2 - fastq": {
"content": [
[
[
{
"id": "combined"
},
"output_corr_matrix.txt:md5,fe8139cc3dffb7df41d17aa24c599dba"
]
],
[
[
{
"id": "combined"
},
"combined_matched.txt:md5,60d6159595026c2365acce3dbaa9677e"
]
],
[
[
{
"id": "combined"
},
"combined_all.txt:md5,6e7c7446bb308af84ee9b1689e1e60ee"
]
],
[
"versions.yml:md5,e8fcb7ac4528e05b40b58825c13220f0"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.1"
},
"timestamp": "2024-05-26T08:42:46.60890226"
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
process {

publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }

withName: BEDTOOLS_MAKEWINDOWS {
ext.args = '-w 1'
ext.prefix = 'test_split'
}

withName: GAWK_BED {
ext.args2 = '\'NR > 20 && NR < 20000 && FS = OFS = "\t" { print $0 FS "rs1" FS "G" FS "C" }\''
ext.prefix = 'snp'
ext.suffix = "bed"
}

withName: GAWK_FAI {
ext.args2 = '\'BEGIN { FS = OFS = "\t" } { print \$1 FS "0" FS \$2 }\''
ext.prefix = 'fasta'
ext.suffix = "bed"
}

}
2 changes: 2 additions & 0 deletions modules/nf-core/ngscheckmate/vafncm/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ngscheckmate/vafncm:
- "modules/nf-core/ngscheckmate/vafncm/**"
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1205,9 +1205,6 @@ ngscheckmate/fastq:
ngscheckmate/patterngenerator:
- modules/nf-core/ngscheckmate/patterngenerator/**
- tests/modules/nf-core/ngscheckmate/patterngenerator/**
ngscheckmate/vafncm:
- modules/nf-core/ngscheckmate/vafncm/**
- tests/modules/nf-core/ngscheckmate/vafncm/**
nucmer:
- modules/nf-core/nucmer/**
- tests/modules/nf-core/nucmer/**
Expand Down
68 changes: 0 additions & 68 deletions tests/modules/nf-core/ngscheckmate/vafncm/main.nf

This file was deleted.

Loading

0 comments on commit 0b94aea

Please sign in to comment.