Skip to content

Commit

Permalink
added stub section and tests for bcstools_consensus
Browse files Browse the repository at this point in the history
  • Loading branch information
TernovojD committed Aug 20, 2024
1 parent a16e02e commit 10b48f5
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/nf-core/bcftools/consensus/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ process BCFTOOLS_CONSENSUS {
'biocontainers/bcftools:1.20--h8b25389_0' }"

input:
tuple val(meta), path(vcf), path(tbi), path(fasta)
tuple val(meta), path(vcf), path(tbi), path(fasta), path(mask)

output:
tuple val(meta), path('*.fa'), emit: fasta
Expand All @@ -20,12 +20,14 @@ process BCFTOOLS_CONSENSUS {
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def masking = mask ? "-m $mask" : ""
"""
cat $fasta \\
| bcftools \\
consensus \\
$vcf \\
$args \\
$masking \\
> ${prefix}.fa
cat <<-END_VERSIONS > versions.yml
Expand Down
4 changes: 4 additions & 0 deletions modules/nf-core/bcftools/consensus/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ input:
type: file
description: FASTA reference file
pattern: "*.{fasta,fa}"
- mask:
type: file
description: BED file used for masking
pattern: "*.{bed}"
output:
- meta:
type: map
Expand Down
90 changes: 90 additions & 0 deletions modules/nf-core/bcftools/consensus/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
nextflow_process {

name "Test Process BCFTOOLS_CONSENSUS"
script "../main.nf"
process "BCFTOOLS_CONSENSUS"

tag "modules"
tag "modules_nfcore"
tag "bcftools"
tag "bcftools/consensus"

test("bcftools - test") {

tag "bcftools_consensus"

when {
process{
"""
input[0] = [
[ id:'test'],
file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)
]
"""
}
}

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

test("bcftools - test - no mask") {

tag "bcftools_consensus"

when {
process{
"""
input[0] = [
[ id:'test'],
file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true),
[]
]
"""
}
}

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

test("bcftools - stub - test") {

tag "stub"
options '-stub'

when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match()}
)
}
}
}
101 changes: 101 additions & 0 deletions modules/nf-core/bcftools/consensus/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"bcftools - stub - test": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.fa:md5,313f4a657187fdaf293c4ed69d98c112"
]
],
"1": [
"versions.yml:md5,b5e1ca5013c29fa37855fe929fb21a65"
],
"fasta": [
[
{
"id": "test"
},
"test.fa:md5,313f4a657187fdaf293c4ed69d98c112"
]
],
"versions": [
"versions.yml:md5,b5e1ca5013c29fa37855fe929fb21a65"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.04.1"
},
"timestamp": "2024-08-20T11:07:44.650952324"
},
"bcftools - test": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.fa:md5,313f4a657187fdaf293c4ed69d98c112"
]
],
"1": [
"versions.yml:md5,b5e1ca5013c29fa37855fe929fb21a65"
],
"fasta": [
[
{
"id": "test"
},
"test.fa:md5,313f4a657187fdaf293c4ed69d98c112"
]
],
"versions": [
"versions.yml:md5,b5e1ca5013c29fa37855fe929fb21a65"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.04.1"
},
"timestamp": "2024-08-20T11:07:31.213119374"
},
"bcftools - test - no mask": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.fa:md5,e57d3e4d113f989bc069c5fd61627091"
]
],
"1": [
"versions.yml:md5,b5e1ca5013c29fa37855fe929fb21a65"
],
"fasta": [
[
{
"id": "test"
},
"test.fa:md5,e57d3e4d113f989bc069c5fd61627091"
]
],
"versions": [
"versions.yml:md5,b5e1ca5013c29fa37855fe929fb21a65"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.04.1"
},
"timestamp": "2024-08-20T11:07:38.238225252"
}
}

0 comments on commit 10b48f5

Please sign in to comment.