Skip to content

Commit

Permalink
added stub to bcftools mpileup (nf-core#5514)
Browse files Browse the repository at this point in the history
* added stub

* updated test

* Update modules/nf-core/bcftools/mpileup/main.nf

Co-authored-by: Nicolas Vannieuwkerke <101190534+nvnieuwk@users.noreply.github.com>

* fix tests

* added file names

* Retrigger test

* Retrigger test

---------

Co-authored-by: lucia.pena.perez@scilifelab.se <lucia.penaperez@hasta-login.local>
Co-authored-by: Nicolas Vannieuwkerke <101190534+nvnieuwk@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 22, 2024
1 parent 6159e87 commit e7df38a
Show file tree
Hide file tree
Showing 3 changed files with 378 additions and 110 deletions.
14 changes: 14 additions & 0 deletions modules/nf-core/bcftools/mpileup/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,18 @@ process BCFTOOLS_MPILEUP {
bcftools: \$(bcftools --version 2>&1 | head -n1 | sed 's/^.*bcftools //; s/ .*\$//')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.bcftools_stats.txt
echo "" | gzip > ${prefix}.vcf.gz
touch ${prefix}.vcf.gz.tbi
echo "" | gzip > ${prefix}.mpileup.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bcftools: \$(bcftools --version 2>&1 | head -n1 | sed 's/^.*bcftools //; s/ .*\$//')
END_VERSIONS
"""
}
134 changes: 113 additions & 21 deletions modules/nf-core/bcftools/mpileup/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,43 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.vcf,
process.out.tbi,
process.out.stats,
process.out.mpileup,
process.out.versions
).match() }
{ assert snapshot(file(process.out.vcf[0][1]).name).match("bam_fasta_false.vcf.gz") },
{ assert snapshot(file(process.out.tbi[0][1]).name).match("bam_fasta_false.vcf.gz.tbi") },
{ assert snapshot(file(process.out.stats[0][1]).name).match("bam_fasta_false.bcftools_stats.txt") },
{ assert snapshot(process.out.versions).match("bam_fasta_false_versions") }
)
}

}

test("sarscov2 - [bam, []], fasta, false stub") {

options "-stub"

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

then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.vcf[0][1]).name).match("bam_fasta_false_stub.vcf.gz") },
{ assert snapshot(file(process.out.tbi[0][1]).name).match("bam_fasta_false_stub.vcf.gz.tbi") },
{ assert snapshot(file(process.out.stats[0][1]).name).match("bam_fasta_false_stub.bcftools_stats.txt") },
{ assert snapshot(process.out.versions).match("bam_fasta_false_stub_versions") }
)
}

Expand Down Expand Up @@ -67,13 +97,45 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.vcf,
process.out.tbi,
process.out.stats,
process.out.mpileup,
process.out.versions
).match() }
{ assert snapshot(file(process.out.vcf[0][1]).name).match("bam_bed_fasta_true_stub.vcf.gz") },
{ assert snapshot(file(process.out.tbi[0][1]).name).match("bam_bed_fasta_true_stub.vcf.gz.tbi") },
{ assert snapshot(file(process.out.stats[0][1]).name).match("bam_bed_fasta_true_stub.bcftools_stats.txt") },
{ assert snapshot(file(process.out.mpileup[0][1]).name).match("bam_bed_fasta_true_stub.mpileup.gz") },
{ assert snapshot(process.out.versions).match("bam_bed_fasta_true_stub_versions") }
)
}

}

test("sarscov2 - [bam, []], fasta, true stub") {

options "-stub"

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

then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.vcf[0][1]).name).match("bam_bed_fasta_true.vcf.gz") },
{ assert snapshot(file(process.out.tbi[0][1]).name).match("bam_bed_fasta_true.vcf.gz.tbi") },
{ assert snapshot(file(process.out.stats[0][1]).name).match("bam_bed_fasta_true.bcftools_stats.txt") },
{ assert snapshot(file(process.out.mpileup[0][1]).name).match("bam_bed_fasta_true.mpileup.gz") },
{ assert snapshot(process.out.versions).match("bam_bed_fasta_true_versions") }
)
}

Expand Down Expand Up @@ -101,13 +163,43 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.vcf,
process.out.tbi,
process.out.stats,
process.out.mpileup,
process.out.versions
).match() }
{ assert snapshot(file(process.out.vcf[0][1]).name).match("bam_bed_fasta_false.vcf.gz") },
{ assert snapshot(file(process.out.tbi[0][1]).name).match("bam_bed_fasta_false.vcf.gz.tbi") },
{ assert snapshot(file(process.out.stats[0][1]).name).match("bam_bed_fasta_false.bcftools_stats.txt") },
{ assert snapshot(process.out.versions).match("bam_bed_fasta_false_versions") }
)
}

}

test("sarscov2 - [bam, bed], fasta, false stub") {

options "-stub"

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

then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.vcf[0][1]).name).match("bam_bed_fasta_false_stub.vcf.gz") },
{ assert snapshot(file(process.out.tbi[0][1]).name).match("bam_bed_fasta_false_stub.vcf.gz.tbi") },
{ assert snapshot(file(process.out.stats[0][1]).name).match("bam_bed_fasta_false_stub.bcftools_stats.txt") },
{ assert snapshot(process.out.versions).match("bam_bed_fasta_false_stub_versions") }
)
}

Expand Down
Loading

0 comments on commit e7df38a

Please sign in to comment.