Skip to content

Commit

Permalink
Port pytest to nftest for sentieon/haplotyper (#6069)
Browse files Browse the repository at this point in the history
* Port pytest to nftest for sentieon/haplotyper

* fix stub tests

* ditch conda
  • Loading branch information
FriederikeHanssen authored Jul 31, 2024
1 parent e5ac715 commit 409e81a
Show file tree
Hide file tree
Showing 10 changed files with 406 additions and 167 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ jobs:
path: modules/nf-core/sentieon/bwamem
- profile: conda
path: modules/nf-core/sentieon/dedup
- profile: conda
path: modules/nf-core/sentieon/haplotyper
- profile: conda
path: modules/nf-core/sentieon/qualcal
- profile: conda
Expand Down
12 changes: 6 additions & 6 deletions modules/nf-core/sentieon/haplotyper/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ process SENTIEON_HAPLOTYPER {

input:
tuple val(meta), path(input), path(input_index), path(intervals)
path fasta
path fai
path dbsnp
path dbsnp_tbi
tuple val(meta1), path(fasta)
tuple val(meta2), path(fai)
tuple val(meta3), path(dbsnp)
tuple val(meta4), path(dbsnp_tbi)
val(emit_vcf)
val(emit_gvcf)

Expand Down Expand Up @@ -63,9 +63,9 @@ process SENTIEON_HAPLOTYPER {
stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.unfiltered.vcf.gz
echo "" | gzip > ${prefix}.unfiltered.vcf.gz
touch ${prefix}.unfiltered.vcf.gz.tbi
touch ${prefix}.g.vcf.gz
echo "" | gzip > ${prefix}.g.vcf.gz
touch ${prefix}.g.vcf.gz.tbi
cat <<-END_VERSIONS > versions.yml
Expand Down
220 changes: 220 additions & 0 deletions modules/nf-core/sentieon/haplotyper/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
nextflow_process {

name "Test Process SENTIEON_HAPLOTYPER"
script "../main.nf"
process "SENTIEON_HAPLOTYPER"
config "./nextflow.config"

tag "modules"
tag "modules_nfcore"
tag "sentieon"
tag "sentieon/haplotyper"

test("Sentieon Haplotyper VCF") {

when {
process {
"""
input[0] = [ [ id:'test' ], // 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),
[] // no intervals
]
input[1] = [[id: 'test'],file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true)]
input[2] = [[id: 'test'],file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true)]
input[3] = [[:],[]]
input[4] = [[:],[]]
input[5] = 'variant'
input[6] = false
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.versions,
file(process.out.vcf_tbi.get(0).get(1)).name,
path(process.out.vcf[0][1]).vcf.variantsMD5
).match()
}
)
}

}

test("Sentieon Haplotyper GVCF") {

when {
process {
"""
input[0] = [ [ id:'test' ], // 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),
[] // no intervals
]
input[1] = [[id: 'test'],file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true)]
input[2] = [[id: 'test'],file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true)]
input[3] = [[:],[]]
input[4] = [[:],[]]
input[5] = ''
input[6] = true
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.versions,
file(process.out.gvcf_tbi.get(0).get(1)).name,
path(process.out.gvcf[0][1]).vcf.variantsMD5
).match()
}
)
}

}

test("Sentieon Haplotyper BOTH") {

when {
process {
"""
input[0] = [ [ id:'test' ], // 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),
[] // no intervals
]
input[1] = [[id: 'test'],file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true)]
input[2] = [[id: 'test'],file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true)]
input[3] = [[:],[]]
input[4] = [[:],[]]
input[5] = 'variant'
input[6] = true
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.versions,
file(process.out.gvcf_tbi.get(0).get(1)).name,
path(process.out.gvcf[0][1]).vcf.variantsMD5,
file(process.out.vcf_tbi.get(0).get(1)).name,
path(process.out.vcf[0][1]).vcf.variantsMD5
).match()
}
)
}

}

test("Sentieon Haplotyper Intervals BOTH") {

when {
process {
"""
input[0] = [ [ id:'test' ], // 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),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.bed', checkIfExists: true)
]
input[1] = [[id: 'test'],file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true)]
input[2] = [[id: 'test'],file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true)]
input[3] = [[:],[]]
input[4] = [[:],[]]
input[5] = 'variant'
input[6] = true
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.versions,
file(process.out.gvcf_tbi.get(0).get(1)).name,
path(process.out.gvcf[0][1]).vcf.variantsMD5,
file(process.out.vcf_tbi.get(0).get(1)).name,
path(process.out.vcf[0][1]).vcf.variantsMD5
).match()
}
)
}

}

test("Sentieon Haplotyper DBSNP BOTH") {

when {
process {
"""
input[0] = [ [ id:'test' ], // 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),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.bed', checkIfExists: true)
]
input[1] = [[id: 'test'], file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true)]
input[2] = [[id: 'test'], file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true)]
input[3] = [[id: 'test'], file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/vcf/dbsnp_146.hg38.vcf.gz', checkIfExists: true)]
input[4] = [[id: 'test'], file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/vcf/dbsnp_146.hg38.vcf.gz.tbi', checkIfExists: true)]
input[5] = 'variant'
input[6] = true
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.versions,
file(process.out.gvcf_tbi.get(0).get(1)).name,
path(process.out.gvcf[0][1]).vcf.variantsMD5,
file(process.out.vcf_tbi.get(0).get(1)).name,
path(process.out.vcf[0][1]).vcf.variantsMD5
).match()
}
)
}
}


test("Sentieon Haplotyper - stub") {

options "-stub"
when {
process {
"""
input[0] = [ [ id:'test' ], // 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),
[] // no intervals
]
input[1] = [[id: 'test'],file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true)]
input[2] = [[id: 'test'],file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true)]
input[3] = [[:],[]]
input[4] = [[:],[]]
input[5] = ''
input[6] = false
"""
}
}

then {

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

}
}

}
Loading

0 comments on commit 409e81a

Please sign in to comment.