Skip to content

Commit

Permalink
refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxulysse committed Oct 11, 2024
1 parent 4464c16 commit ed913a7
Show file tree
Hide file tree
Showing 26 changed files with 627 additions and 401 deletions.
15 changes: 9 additions & 6 deletions nf-test.config
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
config {
// location for all nf-tests
testsDir "tests/pipeline"
testsDir "."

// nf-test directory including temporary files for each test
workDir ".nf-test"

// location of library folder that is added automatically to the classpath
libDir "tests/lib/"

// location of an optional nextflow.config file specific for executing tests
configFile "nextflow.config"
configFile "conf/test.config"

// run all test with defined profile(s) from the main nextflow.config
profile ""
profile "test"

// Include plugins
plugins {
load "[email protected]"
load "[email protected]"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
include { GATK4_COLLECTREADCOUNTS } from '../../modules/nf-core/gatk4/collectreadcounts/main'
include { GATK4_CREATEREADCOUNTPANELOFNORMALS } from '../../modules/nf-core/gatk4/createreadcountpanelofnormals/main'
include { GATK4_PREPROCESSINTERVALS } from '../../modules/nf-core/gatk4/preprocessintervals/main'
include { PICARD_CREATESEQUENCEDICTIONARY } from '../../modules/nf-core/picard/createsequencedictionary/main'
include { SAMTOOLS_FAIDX } from '../../modules/nf-core/samtools/faidx/main'
include { SAMTOOLS_INDEX } from '../../modules/nf-core/samtools/index/main'
include { GATK4_COLLECTREADCOUNTS } from '../../../modules/nf-core/gatk4/collectreadcounts/main'
include { GATK4_CREATEREADCOUNTPANELOFNORMALS } from '../../../modules/nf-core/gatk4/createreadcountpanelofnormals/main'
include { GATK4_PREPROCESSINTERVALS } from '../../../modules/nf-core/gatk4/preprocessintervals/main'
include { PICARD_CREATESEQUENCEDICTIONARY } from '../../../modules/nf-core/picard/createsequencedictionary/main'
include { SAMTOOLS_FAIDX } from '../../../modules/nf-core/samtools/faidx/main'
include { SAMTOOLS_INDEX } from '../../../modules/nf-core/samtools/index/main'

workflow GENS_PON {
take:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
include { GATK4_ANNOTATEINTERVALS } from '../../modules/nf-core/gatk4/annotateintervals/main'
include { GATK4_BEDTOINTERVALLIST as GATK4_BEDTOINTERVALLIST_TARGETS } from '../../modules/nf-core/gatk4/bedtointervallist/main'
include { GATK4_BEDTOINTERVALLIST as GATK4_BEDTOINTERVALLIST_EXCLUDE } from '../../modules/nf-core/gatk4/bedtointervallist/main'
include { GATK4_COLLECTREADCOUNTS } from '../../modules/nf-core/gatk4/collectreadcounts/main'
include { GATK4_DETERMINEGERMLINECONTIGPLOIDY } from '../../modules/nf-core/gatk4/determinegermlinecontigploidy/main'
include { GATK4_FILTERINTERVALS } from '../../modules/nf-core/gatk4/filterintervals/main'
include { GATK4_GERMLINECNVCALLER } from '../../modules/nf-core/gatk4/germlinecnvcaller/main'
include { GATK4_INDEXFEATUREFILE as GATK4_INDEXFEATUREFILE_MAPPABILITY } from '../../modules/nf-core/gatk4/indexfeaturefile/main'
include { GATK4_INDEXFEATUREFILE as GATK4_INDEXFEATUREFILE_SEGDUP } from '../../modules/nf-core/gatk4/indexfeaturefile/main'
include { GATK4_INTERVALLISTTOOLS } from '../../modules/nf-core/gatk4/intervallisttools/main'
include { GATK4_PREPROCESSINTERVALS } from '../../modules/nf-core/gatk4/preprocessintervals/main'
include { PICARD_CREATESEQUENCEDICTIONARY } from '../../modules/nf-core/picard/createsequencedictionary/main'
include { SAMTOOLS_FAIDX } from '../../modules/nf-core/samtools/faidx/main'
include { SAMTOOLS_INDEX } from '../../modules/nf-core/samtools/index/main'
include { GATK4_ANNOTATEINTERVALS } from '../../../modules/nf-core/gatk4/annotateintervals/main'
include { GATK4_BEDTOINTERVALLIST as GATK4_BEDTOINTERVALLIST_TARGETS } from '../../../modules/nf-core/gatk4/bedtointervallist/main'
include { GATK4_BEDTOINTERVALLIST as GATK4_BEDTOINTERVALLIST_EXCLUDE } from '../../../modules/nf-core/gatk4/bedtointervallist/main'
include { GATK4_COLLECTREADCOUNTS } from '../../../modules/nf-core/gatk4/collectreadcounts/main'
include { GATK4_DETERMINEGERMLINECONTIGPLOIDY } from '../../../modules/nf-core/gatk4/determinegermlinecontigploidy/main'
include { GATK4_FILTERINTERVALS } from '../../../modules/nf-core/gatk4/filterintervals/main'
include { GATK4_GERMLINECNVCALLER } from '../../../modules/nf-core/gatk4/germlinecnvcaller/main'
include { GATK4_INDEXFEATUREFILE as GATK4_INDEXFEATUREFILE_MAPPABILITY } from '../../../modules/nf-core/gatk4/indexfeaturefile/main'
include { GATK4_INDEXFEATUREFILE as GATK4_INDEXFEATUREFILE_SEGDUP } from '../../../modules/nf-core/gatk4/indexfeaturefile/main'
include { GATK4_INTERVALLISTTOOLS } from '../../../modules/nf-core/gatk4/intervallisttools/main'
include { GATK4_PREPROCESSINTERVALS } from '../../../modules/nf-core/gatk4/preprocessintervals/main'
include { PICARD_CREATESEQUENCEDICTIONARY } from '../../../modules/nf-core/picard/createsequencedictionary/main'
include { SAMTOOLS_FAIDX } from '../../../modules/nf-core/samtools/faidx/main'
include { SAMTOOLS_INDEX } from '../../../modules/nf-core/samtools/index/main'

workflow GERMLINECNVCALLER_COHORT {
take:
Expand Down
15 changes: 0 additions & 15 deletions subworkflows/local/utils_nfcore_createpanelrefs_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ workflow PIPELINE_INITIALISATION {

ch_samplesheet = Channel
.fromList(samplesheetToList(params.input, "${projectDir}/assets/schema_input.json"))
.map { samplesheet -> validateInputSamplesheet(samplesheet)}

emit:
samplesheet = ch_samplesheet
Expand Down Expand Up @@ -142,20 +141,6 @@ def validateInputParameters() {
genomeExistsError()
}

//
// Validate channels from input samplesheet
//
def validateInputSamplesheet(input) {
def (metas, fastqs) = input[1..2]

// Check that multiple runs of the same sample are of the same datatype i.e. single-end / paired-end
def endedness_ok = metas.collect{ meta -> meta.single_end }.unique().size == 1
if (!endedness_ok) {
error("Please check input samplesheet -> Multiple runs of a sample must be of the same datatype i.e. single-end or paired-end: ${metas[0].id}")
}

return [ metas[0], fastqs ]
}
//
// Get attribute from genome config file e.g. fasta
//
Expand Down
8 changes: 8 additions & 0 deletions tests/.nftignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
multiqc/multiqc_data/multiqc.log
multiqc/multiqc_data/multiqc_data.json
multiqc/multiqc_data/multiqc_general_stats.txt
multiqc/multiqc_data/multiqc_software_versions.txt
multiqc/multiqc_data/multiqc_sources.txt
multiqc/multiqc_plots/{svg,pdf,png}/*.{svg,pdf,png}
multiqc/multiqc_report.html
pipeline_info/*.{html,json,txt,yml}
53 changes: 0 additions & 53 deletions tests/config/tags.yml

This file was deleted.

36 changes: 36 additions & 0 deletions tests/default.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
nextflow_pipeline {

name "Test pipeline"
script "../main.nf"
tag "pipeline"
tag "pipeline_createpanelrefs"

test("Run with profile test | default aka cnvkit") {

when {
params {
outdir = "$outputDir"
}
}

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')
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_ceatepanelrefs_software_mqc_versions.yml"),
// All stable path name, with a relative path
stable_name,
// All files with stable contents
stable_path
).match() }
)
}
}
}
47 changes: 47 additions & 0 deletions tests/default.nf.test.snap

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

File renamed without changes.
42 changes: 42 additions & 0 deletions tests/gens_pon.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
nextflow_pipeline {

name "Test pipeline | gens"
script "../main.nf"
tag "pipeline"
tag "pipeline_createpanelrefs"
config "./gens_pon.config"

test("Run gens test") {

when {
params {
fasta = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/genome.fasta"
gens_bin_length = 100
gens_pon_name = 'gens_pon'
gens_readcount_format = "TSV"
outdir = "$outputDir"
tools = 'gens'
}
}

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')
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_ceatepanelrefs_software_mqc_versions.yml"),
// All stable path name, with a relative path
stable_name,
// All files with stable contents
stable_path
).match() }
)
}
}
}
File renamed without changes.
42 changes: 42 additions & 0 deletions tests/germlinecnvcaller_cohort.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
nextflow_pipeline {

name "Test pipeline | germlinecnvcaller"
script "../main.nf"
tag "pipeline"
tag "pipeline_createpanelrefs"
config "./germlinecnvcaller_cohort.config"

test("Run germlinecnvcaller test") {

when {
params {
fasta = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/genome.fasta"
gcnv_model_name = 'cohort'
gcnv_ploidy_priors = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/illumina/gatk/contig_ploidy_priors_table.tsv"
gcnv_scatter_content = 2
outdir = "$outputDir"
tools = 'germlinecnvcaller'
}
}

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')
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_ceatepanelrefs_software_mqc_versions.yml"),
// All stable path name, with a relative path
stable_name,
// All files with stable contents
stable_path
).match() }
)
}
}
}
11 changes: 0 additions & 11 deletions tests/lib/UTILS.groovy

This file was deleted.

37 changes: 37 additions & 0 deletions tests/mutect2.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
nextflow_pipeline {

name "Test MUTECT2_PON"
script "main.nf"
tag "MUTECT2"

test("Run MUTECT2 test") {

when {
params {
outdir = "$outputDir"
tools = 'mutect2'
mutect2_pon_name = 'test'
}
}

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')
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_ceatepanelrefs_software_mqc_versions.yml"),
// All stable path name, with a relative path
stable_name,
// All files with stable contents
stable_path
).match() }
)
}
}
}
Loading

0 comments on commit ed913a7

Please sign in to comment.