Skip to content

Commit

Permalink
Add/fix more stubs (#5563)
Browse files Browse the repository at this point in the history
* fix some stubs

* add more stubs!

* fix expansionhunter tests

* fix concat tests

* Update modules/nf-core/bcftools/sort/tests/main.nf.test

Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com>

* fix bcftools tests again

* fix expansionhunter versions

* fix concat again

* fix bgzip version for expansionhunter

* fix bgzip version for expansionhunter

---------

Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com>
  • Loading branch information
nvnieuwk and SPPearce authored May 3, 2024
1 parent cdcdd5e commit b42fec6
Show file tree
Hide file tree
Showing 15 changed files with 429 additions and 67 deletions.
2 changes: 1 addition & 1 deletion modules/nf-core/bcftools/concat/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ process BCFTOOLS_CONCAT {
stub:
prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.vcf.gz
echo "" | gzip > ${prefix}.vcf.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
15 changes: 3 additions & 12 deletions modules/nf-core/bcftools/concat/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.vcf,
process.out.versions
).match() }
{ assert snapshot(process.out).match() }
)
}

Expand All @@ -63,10 +60,7 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.vcf,
process.out.versions
).match() }
{ assert snapshot(process.out).match() }
)
}

Expand Down Expand Up @@ -96,10 +90,7 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(
file(process.out.vcf[0][1]).name,
process.out.versions
).match() }
{ assert snapshot(process.out).match() }
)
}

Expand Down
112 changes: 85 additions & 27 deletions modules/nf-core/bcftools/concat/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,43 +1,101 @@
{
"sarscov2 - [[vcf1, vcf2], []]": {
"content": [
[
[
{
"id": "test3"
},
"test3.vcf.gz:md5,4bcd0afd89f56c5d433f6b6abc44d0a6"
{
"0": [
[
{
"id": "test3"
},
"test3.vcf.gz:md5,5f6796c3ae109a1a5b87353954693f5a"
]
],
"1": [
"versions.yml:md5,24ae05eb858733b40fbd3f89743a6d09"
],
"vcf": [
[
{
"id": "test3"
},
"test3.vcf.gz:md5,5f6796c3ae109a1a5b87353954693f5a"
]
],
"versions": [
"versions.yml:md5,24ae05eb858733b40fbd3f89743a6d09"
]
],
[
"versions.yml:md5,24ae05eb858733b40fbd3f89743a6d09"
]
}
],
"timestamp": "2023-11-29T13:52:27.03724666"
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.03.0"
},
"timestamp": "2024-05-03T13:22:49.766749302"
},
"sarscov2 - [[vcf1, vcf2], [tbi1, tbi2]]": {
"content": [
[
[
{
"id": "test3"
},
"test3.vcf.gz:md5,4bcd0afd89f56c5d433f6b6abc44d0a6"
{
"0": [
[
{
"id": "test3"
},
"test3.vcf.gz:md5,5f6796c3ae109a1a5b87353954693f5a"
]
],
"1": [
"versions.yml:md5,24ae05eb858733b40fbd3f89743a6d09"
],
"vcf": [
[
{
"id": "test3"
},
"test3.vcf.gz:md5,5f6796c3ae109a1a5b87353954693f5a"
]
],
"versions": [
"versions.yml:md5,24ae05eb858733b40fbd3f89743a6d09"
]
],
[
"versions.yml:md5,24ae05eb858733b40fbd3f89743a6d09"
]
}
],
"timestamp": "2023-11-29T13:52:21.468988293"
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.03.0"
},
"timestamp": "2024-05-03T13:22:41.119912312"
},
"sarscov2 - [[vcf1, vcf2], [tbi1, tbi2]] - stub": {
"content": [
"test3.vcf.gz",
[
"versions.yml:md5,24ae05eb858733b40fbd3f89743a6d09"
]
{
"0": [
[
{
"id": "test3"
},
"test3.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"1": [
"versions.yml:md5,24ae05eb858733b40fbd3f89743a6d09"
],
"vcf": [
[
{
"id": "test3"
},
"test3.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"versions": [
"versions.yml:md5,24ae05eb858733b40fbd3f89743a6d09"
]
}
],
"timestamp": "2023-11-29T13:41:04.716017811"
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.03.0"
},
"timestamp": "2024-05-03T13:22:59.90466392"
}
}
4 changes: 2 additions & 2 deletions modules/nf-core/bcftools/sort/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ process BCFTOOLS_SORT {
args.contains("--output-type z") || args.contains("-Oz") ? "vcf.gz" :
args.contains("--output-type v") || args.contains("-Ov") ? "vcf" :
"vcf"

def create_cmd = extension.endsWith(".gz") ? "echo '' | gzip >" : "touch"
"""
touch ${prefix}.${extension}
${create_cmd} ${prefix}.${extension}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
24 changes: 23 additions & 1 deletion modules/nf-core/bcftools/sort/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,29 @@ nextflow_process {
tag "bcftools"
tag "bcftools/sort"

test("SarsCov2 VCF") {
test("sarscov2 - vcf") {
when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_vcf'], checkIfExists: true)
]
"""
}
}

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

}

test("sarscov2 - vcf - stub") {
options "-stub"
when {
process {
"""
Expand Down
39 changes: 36 additions & 3 deletions modules/nf-core/bcftools/sort/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"SarsCov2 VCF": {
"vcf": {
"content": [
{
"0": [
Expand Down Expand Up @@ -28,8 +28,41 @@
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.04.2"
"nextflow": "24.03.0"
},
"timestamp": "2024-03-18T12:50:10.340362246"
"timestamp": "2024-05-02T16:55:21.237927554"
},
"sarscov2 - vcf - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"1": [
"versions.yml:md5,622bd32d4ff0fac3360cd534ae0f0168"
],
"vcf": [
[
{
"id": "test"
},
"test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"versions": [
"versions.yml:md5,622bd32d4ff0fac3360cd534ae0f0168"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.03.0"
},
"timestamp": "2024-05-03T12:32:50.506309198"
}
}
6 changes: 3 additions & 3 deletions modules/nf-core/ensemblvep/vep/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ process ENSEMBLVEP_VEP {
stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.vcf.gz
touch ${prefix}.tab.gz
touch ${prefix}.json.gz
echo "" | gzip > ${prefix}.vcf.gz
echo "" | gzip > ${prefix}.tab.gz
echo "" | gzip > ${prefix}.json.gz
touch ${prefix}.summary.html
cat <<-END_VERSIONS > versions.yml
Expand Down
3 changes: 3 additions & 0 deletions modules/nf-core/expansionhunter/environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: expansionhunter

channels:
- conda-forge
- bioconda
- defaults

dependencies:
- bioconda::expansionhunter=5.0.0
- bioconda::htslib=1.18
8 changes: 4 additions & 4 deletions modules/nf-core/expansionhunter/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ process EXPANSIONHUNTER {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
expansionhunter: \$( echo \$(ExpansionHunter --version 2>&1) | sed 's/^.*ExpansionHunter v//')
expansionhunter: \$( echo \$(ExpansionHunter --version 2>&1) | head -1 | sed 's/^.*ExpansionHunter v//')
bgzip: \$(echo \$(bgzip -h 2>&1) | sed 's/^.*Version: //;s/Usage:.*//')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.vcf.gz
touch ${prefix}.json.gz
echo "" | gzip > ${prefix}.vcf.gz
echo "" | gzip > ${prefix}.json.gz
touch ${prefix}_realigned.bam
cat <<-END_VERSIONS > versions.yml
"${task.process}":
expansionhunter: \$( echo \$(ExpansionHunter --version 2>&1) | sed 's/^.*ExpansionHunter v//')
expansionhunter: \$( echo \$(ExpansionHunter --version 2>&1) | head -1 | sed 's/^.*ExpansionHunter v//')
bgzip: \$(echo \$(bgzip -h 2>&1) | sed 's/^.*Version: //;s/Usage:.*//')
END_VERSIONS
"""
Expand Down
35 changes: 30 additions & 5 deletions modules/nf-core/expansionhunter/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ nextflow_process {
tag "modules_nfcore"
tag "expansionhunter"

test("expansionhunter") {
test("homo_sapiens - [bam,bai], fasta, fai, cat") {

when {
process {
Expand All @@ -25,10 +25,35 @@ nextflow_process {

then {
assertAll(
{assert process.success},
{assert path(process.out.vcf.get(0).get(1)).linesGzip.size() == 8},
{assert path(process.out.json.get(0).get(1)).linesGzip.size() == 27},
{assert snapshot(process.out.bam).match()}
{assert process.success},
{assert snapshot(process.out).match("expansionhunter")}
)
}

}

test("homo_sapiens - [bam,bai], fasta, fai, cat - stub") {

options "-stub"

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true),
]
input[1] = [[id:'fasta'],file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)]
input[2] = [[id:'fasta_fai'],file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true)]
input[3] = [[id:'catalogue'],file(params.test_data['homo_sapiens']['genome']['repeat_expansions'], checkIfExists: true)]
"""
}
}

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

Expand Down
Loading

0 comments on commit b42fec6

Please sign in to comment.