Skip to content

Commit

Permalink
Update/gatk4spark applybqsr nftest (nf-core#4613)
Browse files Browse the repository at this point in the history
* remove pytests

* removed TODO statements

* add stub block

* add nf-tests

* remove pytests
  • Loading branch information
anoronh4 authored and lrauschning committed Jan 17, 2024
1 parent 6c8f32d commit 9f8cc1a
Show file tree
Hide file tree
Showing 15 changed files with 617 additions and 199 deletions.
10 changes: 10 additions & 0 deletions modules/nf-core/gatk4/baserecalibrator/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,14 @@ process GATK4_BASERECALIBRATOR {
gatk4: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//')
END_VERSIONS
"""

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

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

tag "modules"
tag "modules_nfcore"
tag "gatk4"
tag "gatk4/baserecalibrator"

test("sarscov2 - bam") {
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']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true),
[]
]
input[1] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
input[2] = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true)
input[3] = file(params.test_data['sarscov2']['genome']['genome_dict'], checkIfExists: true)
input[4] = file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true)
input[5] = file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true)
"""
}
}

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

}

test("sarscov2 - bam - intervals") {
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']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)
]
input[1] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
input[2] = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true)
input[3] = file(params.test_data['sarscov2']['genome']['genome_dict'], checkIfExists: true)
input[4] = file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true)
input[5] = file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true)
"""
}
}

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

}

test("sarscov2 - bam - multiple sites") {
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']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true),
[]
]
input[1] = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
input[2] = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true)
input[3] = file(params.test_data['sarscov2']['genome']['genome_dict'], checkIfExists: true)
input[4] = [
file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test2_vcf_gz'], checkIfExists: true)
]
input[5] = [
file(params.test_data['sarscov2']['illumina']['test_vcf_gz_tbi'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test2_vcf_gz_tbi'], checkIfExists: true)
]
"""
}
}

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

}

test("sarscov2 - bam - stub") {
options "-stub"

when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
[],
[],
[]
]
input[1] = []
input[2] = []
input[3] = []
input[4] = []
input[5] = []
"""
}
}

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

}

test("homo_sapiens - cram ") {

when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram_crai'], checkIfExists: true),
[]
]
input[1] = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
input[2] = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true)
input[3] = file(params.test_data['homo_sapiens']['genome']['genome_dict'], checkIfExists: true)
input[4] = file(params.test_data['homo_sapiens']['genome']['dbsnp_146_hg38_vcf_gz'], checkIfExists: true)
input[5] = file(params.test_data['homo_sapiens']['genome']['dbsnp_146_hg38_vcf_gz_tbi'], checkIfExists: true)
"""
}
}

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

}

}
147 changes: 147 additions & 0 deletions modules/nf-core/gatk4/baserecalibrator/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions modules/nf-core/gatk4/baserecalibrator/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gatk4/baserecalibrator:
- "modules/nf-core/gatk4/baserecalibrator/**"
12 changes: 12 additions & 0 deletions modules/nf-core/gatk4spark/applybqsr/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,16 @@ process GATK4SPARK_APPLYBQSR {
gatk4: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.bam
touch ${prefix}.cram
cat <<-END_VERSIONS > versions.yml
"${task.process}":
gatk4: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//')
END_VERSIONS
"""
}
Loading

0 comments on commit 9f8cc1a

Please sign in to comment.