Skip to content

Commit

Permalink
port controlfreec-freec to nf-test (#5398)
Browse files Browse the repository at this point in the history
* feat: add nf-test files and snapshot

* remove pytest files

* modify test to comment single

* change snap

* fix tests and update snap

---------

Co-authored-by: Maxime U Garcia <[email protected]>
  • Loading branch information
famosab and maxulysse authored Mar 28, 2024
1 parent e6c5689 commit 7b5827a
Show file tree
Hide file tree
Showing 7 changed files with 379 additions and 114 deletions.
165 changes: 165 additions & 0 deletions modules/nf-core/controlfreec/freec/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "controlfreec"
tag "controlfreec/freec"
tag "untar"

setup {

run("UNTAR") {
script "../../../../nf-core/untar/main.nf"
process {
"""
input[0] = [ [],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/chromosomes.tar.gz', checkIfExists: true)
]
"""
}
}

}

test("human - mpileup") {

when {
process {
"""
input[0] = [ [ id:'test', single_end:false, sex:'XX' ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/mpileup/test.mpileup.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/mpileup/test2.mpileup.gz', checkIfExists: true),
[],[],[],[]
]
// fasta
input[1] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true)
// fai
input[2] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true)
// snp_position
input[3] = []
// known_snps
input[4] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/germlineresources/dbsnp_138.hg38.vcf.gz', checkIfExists: true)
// known_snps_tbi
input[5] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/germlineresources/dbsnp_138.hg38.vcf.gz.tbi', checkIfExists: true)
// chr_directory
input[6] = UNTAR.out.untar.map{ it[1] }
// mappability
input[7] = []
// target_bed
input[8] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed', checkIfExists: true)
// gccontent_profile
input[9] = []
"""
}
}

then {
assertAll(
{ assert process.success },
// not asserting optional outputs [bedgraph, control_cpn, gcprofile_cpn]
{ assert snapshot(
// match file names
file(process.out.sample_cpn.get(0).get(1)).name,
file(process.out.CNV.get(0).get(1)).name,
// match first line
path(process.out.BAF.get(0).get(1)).readLines()[0],
path(process.out.ratio.get(0).get(1)).readLines()[0],
path(process.out.config.get(0).get(1)).readLines()[0],
path(process.out.info.get(0).get(1)).readLines()[0]
).match() },
{ assert snapshot(process.out.versions).match("version") }
)
}

}

// test("human - mpileup - single") {

// when {
// process {
// """
// input[0] = [ [ id:'test', single_end:false, sex:'XX' ], // meta map
// [],
// file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/mpileup/test2.mpileup.gz', checkIfExists: true),
// [],[],[],[]
// ]
// // fasta
// input[1] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true)
// // fai
// input[2] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true)
// // snp_position
// input[3] = []
// // known_snps
// input[4] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/germlineresources/dbsnp_138.hg38.vcf.gz', checkIfExists: true)
// // known_snps_tbi
// input[5] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/germlineresources/dbsnp_138.hg38.vcf.gz.tbi', checkIfExists: true)
// // chr_directory
// input[6] = UNTAR.out.untar.map{ it[1] }
// // mappability
// input[7] = []
// // target_bed
// input[8] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed', checkIfExists: true)
// // gccontent_profile
// input[9] = []
// """
// }
// }

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

// }

test("human - mpileup - stub") {

options "-stub"

when {
process {
"""
input[0] = [ [ id:'test', single_end:false, sex:'XX' ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/mpileup/test.mpileup.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/mpileup/test2.mpileup.gz', checkIfExists: true),
[],[],[],[]
]
// fasta
input[1] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true)
// fai
input[2] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true)
// snp_position
input[3] = []
// known_snps
input[4] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/germlineresources/dbsnp_138.hg38.vcf.gz', checkIfExists: true)
// known_snps_tbi
input[5] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/germlineresources/dbsnp_138.hg38.vcf.gz.tbi', checkIfExists: true)
// chr_directory
input[6] = UNTAR.out.untar.map{ it[1] }
// mappability
input[7] = []
// target_bed
input[8] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed', checkIfExists: true)
// gccontent_profile
input[9] = []
"""
}
}

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

}

}
212 changes: 212 additions & 0 deletions modules/nf-core/controlfreec/freec/tests/main.nf.test.snap

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

Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
process {

publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }

withName:CONTROLFREEC_FREEC{
ext.args = { [
"sample":[
Expand Down
2 changes: 2 additions & 0 deletions modules/nf-core/controlfreec/freec/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
controlfreec/freec:
- "modules/nf-core/controlfreec/freec/**"
Loading

0 comments on commit 7b5827a

Please sign in to comment.