Skip to content

Commit

Permalink
add stubs gatk4 (nf-core#6672)
Browse files Browse the repository at this point in the history
* add stubs

* run lint --fix

* fix formatting
  • Loading branch information
famosab authored and Helle Rus Povlsen committed Oct 2, 2024
1 parent e15510e commit 037b2a8
Show file tree
Hide file tree
Showing 10 changed files with 531 additions and 4 deletions.
13 changes: 13 additions & 0 deletions modules/nf-core/gatk4/applybqsr/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,17 @@ process GATK4_APPLYBQSR {
gatk4: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
def input_extension = input.getExtension()
def output_extension = input_extension == 'bam' ? 'bam' : 'cram'
"""
touch ${prefix}.${output_extension}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
gatk4: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//')
END_VERSIONS
"""
}
59 changes: 59 additions & 0 deletions modules/nf-core/gatk4/applybqsr/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,63 @@ nextflow_process {
}
}

test("sarscov2 - cram - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test' ],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram.crai', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/test.baserecalibrator.table', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.bed', checkIfExists: true)
]
input[1] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true)
input[2] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true)
input[3] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.dict', checkIfExists: true)
"""
}
}

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

test("sarscov2 - bam - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test' ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/gatk/test.baserecalibrator.table', checkIfExists: true),
[]
]
input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
input[2] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta.fai', checkIfExists: true)
input[3] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.dict', checkIfExists: true)
"""
}
}

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

}

}
78 changes: 78 additions & 0 deletions modules/nf-core/gatk4/applybqsr/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
{
"sarscov2 - bam - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.bam:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [

],
"2": [
"versions.yml:md5,bb2a060a0280c812fba3c74b1707b350"
],
"bam": [
[
{
"id": "test"
},
"test.bam:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"cram": [

],
"versions": [
"versions.yml:md5,bb2a060a0280c812fba3c74b1707b350"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-20T10:25:00.314573"
},
"sarscov2 - bam - intervals": {
"content": [
{
Expand Down Expand Up @@ -60,6 +99,45 @@
},
"timestamp": "2023-12-09T03:10:46.70859771"
},
"sarscov2 - cram - stub": {
"content": [
{
"0": [

],
"1": [
[
{
"id": "test"
},
"test.cram:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"2": [
"versions.yml:md5,bb2a060a0280c812fba3c74b1707b350"
],
"bam": [

],
"cram": [
[
{
"id": "test"
},
"test.cram:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,bb2a060a0280c812fba3c74b1707b350"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-20T10:24:52.761169"
},
"sarscov2 - bam": {
"content": [
{
Expand Down
18 changes: 18 additions & 0 deletions modules/nf-core/gatk4/collectsvevidence/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,22 @@ process GATK4_COLLECTSVEVIDENCE {
gatk4: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
def sd_vcf = site_depth_vcf ? "echo '' | gzip > ${prefix}.sd.txt.gz" : ""
def sd_vcf_tbi = site_depth_vcf_tbi ? "touch ${prefix}.sd.txt.gz.tbi" : ""
"""
echo "" | gzip > ${prefix}.sr.txt.gz
touch ${prefix}.sr.txt.gz.tbi
echo "" | gzip > ${prefix}.pe.txt.gz
touch ${prefix}.pe.txt.gz.tbi
${sd_vcf}
${sd_vcf_tbi}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
gatk4: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//')
END_VERSIONS
"""
}
4 changes: 2 additions & 2 deletions modules/nf-core/gatk4/collectsvevidence/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ input:
pattern: "*.vcf.gz"
- site_depth_vcf_tbi:
type: file
description: tbi index of the input VCF of SNPs marking loci for site
depths
description: Optional - input VCF TBI of SNPs marking loci for site depths, needed
for the site depths output
pattern: "*.vcf.gz.tbi"
- - fasta:
type: file
Expand Down
60 changes: 60 additions & 0 deletions modules/nf-core/gatk4/collectsvevidence/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,64 @@ nextflow_process {
}
}

test("test-gatk4-collectsvevidence-cram - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/cram/test.paired_end.sorted.cram.crai', checkIfExists: true),
[],
[]
]
input[1] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true)
input[2] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true)
input[3] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.dict', checkIfExists: true)
"""
}
}

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

test("test-gatk4-collectsvevidence-allele-count - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/haplotypecaller_calls/test_haplotcaller.cnn.vcf.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/haplotypecaller_calls/test_haplotcaller.cnn.vcf.gz.tbi', checkIfExists: true)
]
input[1] = []
input[2] = []
input[3] = []
"""
}
}

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

}
Loading

0 comments on commit 037b2a8

Please sign in to comment.