Skip to content

Commit

Permalink
add stub tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FriederikeHanssen committed Dec 10, 2024
1 parent 20ce551 commit 01a4915
Show file tree
Hide file tree
Showing 5 changed files with 502 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
},
"samtools/mpileup": {
"branch": "master",
"git_sha": "b13f07be4c508d6ff6312d354d09f2493243e208",
"git_sha": "13e7d1046922381df90cd8fe9bee8c3e57ae8457",
"installed_by": ["modules"]
},
"samtools/stats": {
Expand Down
2 changes: 1 addition & 1 deletion modules/local/create_intervals_bed/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ process CREATE_INTERVALS_BED {
// def prefix_basename = prefix.substring(0, prefix.lastIndexOf("."))

"""
touch ${prefix}.bed
touch ${prefix}.stub.bed
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
21 changes: 18 additions & 3 deletions modules/nf-core/samtools/mpileup/main.nf

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

90 changes: 90 additions & 0 deletions tests/variant_calling_controlfreec.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,94 @@ nextflow_pipeline {
)
}
}

test("Run with profile test | --tools controlfreec --no_intervals | somatic | stub") {
options "-stub"
when {
params {
modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/'
chr_dir = params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/chromosomes.tar.gz'
dbsnp = params.modules_testdata_base_path + '/genomics/homo_sapiens/genome/chr21/germlineresources/dbsnp_138.hg38.vcf.gz'
dbsnp_tbi = params.modules_testdata_base_path + '/genomics/homo_sapiens/genome/chr21/germlineresources/dbsnp_138.hg38.vcf.gz.tbi'
fasta = params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta'
fasta_fai = params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai'
input = "${projectDir}/tests/csv/3.0/recalibrated_somatic.csv"
no_intervals = true
outdir = "$outputDir"
step = "variant_calling"
tools = 'controlfreec'
wes = true
}
}

then {
// stable_name: All files + folders in ${params.outdir}/ with a stable name
def stable_name = getAllFilesFromDir(params.outdir, relative: true, includeDir: true, ignore: ['pipeline_info/*.{html,json,txt}'])
// stable_path: All files in ${params.outdir}/ with stable content
def stable_path = getAllFilesFromDir(params.outdir, ignoreFile: 'tests/.nftignore')
// cram_files: All cram files
def cram_files = getAllFilesFromDir(params.outdir, include: ['**/*.cram'])
def fasta = params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta'
assertAll(
{ assert workflow.success},
{ assert snapshot(
// Number of successful tasks
workflow.trace.succeeded().size(),
// pipeline versions.yml file for multiqc from which Nextflow version is removed because we tests pipelines on multiple Nextflow versions
removeNextflowVersion("$outputDir/pipeline_info/nf_core_sarek_software_mqc_versions.yml"),
// All stable path name, with a relative path
stable_name,
// All files with stable contents
stable_path,
// All cram files
cram_files.collect{ file -> [ file.getName(), cram(file.toString(), fasta).getReadsMD5() ] }
).match() }
)
}
}

test("Run with profile test | --tools controlfreec | tumoronly | stub") {
options "-stub"
when {
params {
modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/'
chr_dir = params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/chromosomes.tar.gz'
dbsnp = params.modules_testdata_base_path + '/genomics/homo_sapiens/genome/chr21/germlineresources/dbsnp_138.hg38.vcf.gz'
dbsnp_tbi = params.modules_testdata_base_path + '/genomics/homo_sapiens/genome/chr21/germlineresources/dbsnp_138.hg38.vcf.gz.tbi'
fasta = params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta'
fasta_fai = params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai'
input = "${projectDir}/tests/csv/3.0/recalibrated_tumoronly.csv"
intervals = params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed'
outdir = "$outputDir"
step = "variant_calling"
tools = 'controlfreec'
wes = true
}
}

then {
// stable_name: All files + folders in ${params.outdir}/ with a stable name
def stable_name = getAllFilesFromDir(params.outdir, relative: true, includeDir: true, ignore: ['pipeline_info/*.{html,json,txt}'])
// stable_path: All files in ${params.outdir}/ with stable content
def stable_path = getAllFilesFromDir(params.outdir, ignoreFile: 'tests/.nftignore')
// cram_files: All cram files
def cram_files = getAllFilesFromDir(params.outdir, include: ['**/*.cram'])
def fasta = params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta'
assertAll(
{ assert workflow.success},
{ assert snapshot(
// Number of successful tasks
workflow.trace.succeeded().size(),
// pipeline versions.yml file for multiqc from which Nextflow version is removed because we tests pipelines on multiple Nextflow versions
removeNextflowVersion("$outputDir/pipeline_info/nf_core_sarek_software_mqc_versions.yml"),
// All stable path name, with a relative path
stable_name,
// All files with stable contents
stable_path,
// All cram files
cram_files.collect{ file -> [ file.getName(), cram(file.toString(), fasta).getReadsMD5() ] }
).match() }
)
}
}
}
Loading

0 comments on commit 01a4915

Please sign in to comment.