From 5f1a2cd44af4ed36b55381017e53b6f501f991ed Mon Sep 17 00:00:00 2001 From: Sateesh Date: Sat, 7 Sep 2024 06:12:44 +0000 Subject: [PATCH] update tests organization --- conf/test.config | 2 - conf/test_data.config | 39 ---------- main.nf | 2 +- nf-test.config | 14 ++-- .../local/bismark/{bismark.nf => main.nf} | 0 subworkflows/local/bismark/tests/main.nf.test | 33 +++++++++ .../local/bwameth/{bwameth.nf => main.nf} | 0 subworkflows/local/bwameth/tests/main.nf.test | 34 +++++++++ .../{prepare_genome.nf => main.nf} | 0 .../local/prepare_genome/tests/main.nf.test | 33 +++++++++ tests/bismark.nf.test | 72 +++++++++++++++++++ tests/bismark_hisat.nf.test | 20 ++++++ tests/bwameth.nf.test | 20 ++++++ tests/config/tags.yml | 7 -- tests/nextflow.config | 38 ++++++++++ workflows/methylseq/methylseq.nf | 4 +- 16 files changed, 261 insertions(+), 57 deletions(-) delete mode 100644 conf/test_data.config rename subworkflows/local/bismark/{bismark.nf => main.nf} (100%) create mode 100644 subworkflows/local/bismark/tests/main.nf.test rename subworkflows/local/bwameth/{bwameth.nf => main.nf} (100%) create mode 100644 subworkflows/local/bwameth/tests/main.nf.test rename subworkflows/local/prepare_genome/{prepare_genome.nf => main.nf} (100%) create mode 100644 subworkflows/local/prepare_genome/tests/main.nf.test create mode 100644 tests/bismark.nf.test create mode 100644 tests/bismark_hisat.nf.test create mode 100644 tests/bwameth.nf.test delete mode 100644 tests/config/tags.yml create mode 100644 tests/nextflow.config diff --git a/conf/test.config b/conf/test.config index cf5b5e6c..1dff5f7a 100644 --- a/conf/test.config +++ b/conf/test.config @@ -25,8 +25,6 @@ params { validationSchemaIgnoreParams = 'genomes,igenomes_base,test_data' } -includeConfig './test_data.config' - process { withName: PRESEQ_LCEXTRAP { errorStrategy = 'ignore' diff --git a/conf/test_data.config b/conf/test_data.config deleted file mode 100644 index 6ac17a82..00000000 --- a/conf/test_data.config +++ /dev/null @@ -1,39 +0,0 @@ -params { - // Base directory for test data - pipelines_testdata_base_path = "https://raw.githubusercontent.com/nf-core/test-datasets/methylseq" - - max_cpus = 2 - max_memory = 6.GB - max_time = 6.h - - // TODO: Add all test data to test_data.config - test_data { - 'assets' { - test_samplesheet = "${params.pipelines_testdata_base_path}/samplesheet/samplesheet_test.csv" - } - 'workflows' { - 'methylseq' { - fasta = "${params.pipelines_testdata_base_path}/reference/genome.fa" - fasta_index = "${params.pipelines_testdata_base_path}/reference/genome.fa.fai" - } - } - 'sarscov2' { - 'illumina' { - test_1_fastq_gz = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_1.fastq.gz" - test_2_fastq_gz = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test_2.fastq.gz" - test2_1_fastq_gz = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test2_1.fastq.gz" - test2_2_fastq_gz = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastq/test2_2.fastq.gz" - contigs_fasta = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fasta/contigs.fasta" - scaffolds_fasta = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fasta/scaffolds.fasta" - test_single_end_bam = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/bam/test.single_end.bam" - test_paired_end_bam = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/bam/test.paired_end.bam" - test_1_fastq_gz_fastqc_zip = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/illumina/fastqc/test_fastqc.zip" - } - 'genome' { - genome_fasta_gz = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/genome/genome.fasta.gz" - genome_fasta = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/genome/genome.fasta" - kraken2_tar_gz = "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/sarscov2/genome/db/kraken2.tar.gz" - } - } - } -} diff --git a/main.nf b/main.nf index f68030c4..95117652 100644 --- a/main.nf +++ b/main.nf @@ -28,7 +28,7 @@ params.bwameth_index = getGenomeAttribute('bwameth') */ include { METHYLSEQ } from './workflows/methylseq/methylseq' -include { PREPARE_GENOME } from './subworkflows/local/prepare_genome/prepare_genome' +include { PREPARE_GENOME } from './subworkflows/local/prepare_genome/' include { PIPELINE_INITIALISATION } from './subworkflows/local/utils_nfcore_methylseq_pipeline' include { PIPELINE_COMPLETION } from './subworkflows/local/utils_nfcore_methylseq_pipeline' diff --git a/nf-test.config b/nf-test.config index 89243e51..b71e5fc3 100644 --- a/nf-test.config +++ b/nf-test.config @@ -3,14 +3,16 @@ config { testsDir "." // nf-test directory including temporary files for each test - workDir "/tmp" - - // location of library folder that is added automatically to the classpath - libDir "tests/lib/" + workDir System.getenv("NFT_WORKDIR") ?: ".nf-test" // location of an optional nextflow.config file specific for executing tests - configFile "nextflow.config" + configFile "tests/nextflow.config" // run all test with the defined docker profile from the main nextflow.config - profile "" + profile "test" + + // load the necessary plugins + plugins { + load "nft-bam@0.3.0" + } } diff --git a/subworkflows/local/bismark/bismark.nf b/subworkflows/local/bismark/main.nf similarity index 100% rename from subworkflows/local/bismark/bismark.nf rename to subworkflows/local/bismark/main.nf diff --git a/subworkflows/local/bismark/tests/main.nf.test b/subworkflows/local/bismark/tests/main.nf.test new file mode 100644 index 00000000..14e9d9f4 --- /dev/null +++ b/subworkflows/local/bismark/tests/main.nf.test @@ -0,0 +1,33 @@ +nextflow_workflow { + + name "Test Workflow BISMARK" + script "../main.nf" + workflow "BISMARK" + + test("Bismark Single-End") { + + when { + params { + // define parameters here. Example: + // outdir = "tests/results" + } + workflow { + """ + input[0] = file("test-file.txt") // reads + input[1] = file("test-file.txt") // bismark_index + input[2] = file("test-file.txt") // skip_deduplication + input[3] = file("test-file.txt") // cytosine_report + """ + } + } + + then { + assertAll( + { assert workflow.success }, + { assert snapshot(workflow.out).match() } + ) + } + + } + +} diff --git a/subworkflows/local/bwameth/bwameth.nf b/subworkflows/local/bwameth/main.nf similarity index 100% rename from subworkflows/local/bwameth/bwameth.nf rename to subworkflows/local/bwameth/main.nf diff --git a/subworkflows/local/bwameth/tests/main.nf.test b/subworkflows/local/bwameth/tests/main.nf.test new file mode 100644 index 00000000..c0b8e49b --- /dev/null +++ b/subworkflows/local/bwameth/tests/main.nf.test @@ -0,0 +1,34 @@ +nextflow_workflow { + + name "Test Workflow BWAMETH" + script "subworkflows/local/bwameth/main.nf" + workflow "BWAMETH" + + test("Should run without failures") { + + when { + params { + // define parameters here. Example: + // outdir = "tests/results" + } + workflow { + """ + input[0] = file("test-file.txt") // reads + input[1] = file("test-file.txt") // bwameth_index + input[2] = file("test-file.txt") // fasta + input[3] = file("test-file.txt") // fasta_index + input[4] = file("test-file.txt") // skip_deduplication + """ + } + } + + then { + assertAll( + { assert workflow.success }, + { assert snapshot(workflow.out).match() } + ) + } + + } + +} diff --git a/subworkflows/local/prepare_genome/prepare_genome.nf b/subworkflows/local/prepare_genome/main.nf similarity index 100% rename from subworkflows/local/prepare_genome/prepare_genome.nf rename to subworkflows/local/prepare_genome/main.nf diff --git a/subworkflows/local/prepare_genome/tests/main.nf.test b/subworkflows/local/prepare_genome/tests/main.nf.test new file mode 100644 index 00000000..ac2f5cdb --- /dev/null +++ b/subworkflows/local/prepare_genome/tests/main.nf.test @@ -0,0 +1,33 @@ +nextflow_workflow { + + name "Test Workflow PREPARE_GENOME" + script "subworkflows/local/prepare_genome/main.nf" + workflow "PREPARE_GENOME" + + test("Should run without failures") { + + when { + params { + // define parameters here. Example: + // outdir = "tests/results" + } + workflow { + """ + input[0] = file("test-file.txt") // fasta + input[1] = file("test-file.txt") // ch_fasta_index + input[2] = file("test-file.txt") // ch_bismark_index + input[3] = file("test-file.txt") // ch_bwameth_index + """ + } + } + + then { + assertAll( + { assert workflow.success }, + { assert snapshot(workflow.out).match() } + ) + } + + } + +} diff --git a/tests/bismark.nf.test b/tests/bismark.nf.test new file mode 100644 index 00000000..a863c977 --- /dev/null +++ b/tests/bismark.nf.test @@ -0,0 +1,72 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "../main.nf" + + test("Params: default") { + + when { + params { + aligner = "bismark" + save_reference = true + outdir = "$outputDir" + } + } + + then { + assertAll( + { assert workflow.success }, + { assert snapshot(path("$outputDir/bismark/deduplicated/Ecoli_1_val_1_bismark_bt2_pe.deduplicated.bam"), + path("$outputDir/bismark/deduplicated/SRR389222_sub1_trimmed_bismark_bt2.deduplicated.bam"), + path("$outputDir/bismark/deduplicated/SRR389222_sub2_trimmed_bismark_bt2.deduplicated.bam"), + path("$outputDir/bismark/deduplicated/SRR389222_sub3_trimmed_bismark_bt2.deduplicated.bam"), + path("$outputDir/bismark/methylation_calls/bedGraph/Ecoli_1_val_1_bismark_bt2_pe.deduplicated.bedGraph.gz"), + path("$outputDir/bismark/methylation_calls/bedGraph/SRR389222_sub1_trimmed_bismark_bt2.deduplicated.bedGraph.gz"), + path("$outputDir/bismark/methylation_calls/bedGraph/SRR389222_sub2_trimmed_bismark_bt2.deduplicated.bedGraph.gz"), + path("$outputDir/bismark/methylation_calls/bedGraph/SRR389222_sub3_trimmed_bismark_bt2.deduplicated.bedGraph.gz"), + path("$outputDir/bismark/methylation_calls/mbias/Ecoli_1_val_1_bismark_bt2_pe.deduplicated.M-bias.txt"), + path("$outputDir/bismark/methylation_calls/mbias/SRR389222_sub1_trimmed_bismark_bt2.deduplicated.M-bias.txt"), + path("$outputDir/bismark/methylation_calls/mbias/SRR389222_sub2_trimmed_bismark_bt2.deduplicated.M-bias.txt"), + path("$outputDir/bismark/methylation_calls/mbias/SRR389222_sub3_trimmed_bismark_bt2.deduplicated.M-bias.txt"), + path("$outputDir/bismark/methylation_calls/methylation_coverage/Ecoli_1_val_1_bismark_bt2_pe.deduplicated.bismark.cov.gz"), + path("$outputDir/bismark/methylation_calls/methylation_coverage/SRR389222_sub1_trimmed_bismark_bt2.deduplicated.bismark.cov.gz"), + path("$outputDir/bismark/methylation_calls/methylation_coverage/SRR389222_sub2_trimmed_bismark_bt2.deduplicated.bismark.cov.gz"), + path("$outputDir/bismark/methylation_calls/methylation_coverage/SRR389222_sub3_trimmed_bismark_bt2.deduplicated.bismark.cov.gz"), + path("$outputDir/bismark/methylation_calls/methylation_calls/").list(), + path("$outputDir/bismark/methylation_calls/splitting_report/Ecoli_1_val_1_bismark_bt2_pe.deduplicated_splitting_report.txt"), + path("$outputDir/bismark/methylation_calls/splitting_report/SRR389222_sub1_trimmed_bismark_bt2.deduplicated_splitting_report.txt"), + path("$outputDir/bismark/methylation_calls/splitting_report/SRR389222_sub2_trimmed_bismark_bt2.deduplicated_splitting_report.txt"), + path("$outputDir/bismark/methylation_calls/splitting_report/SRR389222_sub3_trimmed_bismark_bt2.deduplicated_splitting_report.txt"), + path("$outputDir/bismark/reference_genome/BismarkIndex/").list(), + path("$outputDir/qualimap/Ecoli/genome_results.txt"), + path("$outputDir/qualimap/SRR389222_sub1/genome_results.txt"), + path("$outputDir/qualimap/SRR389222_sub2/genome_results.txt"), + path("$outputDir/qualimap/SRR389222_sub3/genome_results.txt")).match("single_end") }, + { assert snapshot(UTILS.removeNextflowVersion("$outputDir")).match("single_end_software_versions") }, + { assert new File("$outputDir/bismark/alignments/logs/Ecoli_1_val_1_bismark_bt2_PE_report.txt").exists() }, + { assert new File("$outputDir/bismark/alignments/logs/SRR389222_sub1_trimmed_bismark_bt2_SE_report.txt").exists() }, + { assert new File("$outputDir/bismark/alignments/logs/SRR389222_sub2_trimmed_bismark_bt2_SE_report.txt").exists() }, + { assert new File("$outputDir/bismark/alignments/logs/SRR389222_sub3_trimmed_bismark_bt2_SE_report.txt").exists() }, + { assert new File("$outputDir/bismark/reports/Ecoli_1_val_1_bismark_bt2_PE_report.html").exists() }, + { assert new File("$outputDir/bismark/reports/SRR389222_sub1_trimmed_bismark_bt2_SE_report.html").exists() }, + { assert new File("$outputDir/bismark/reports/SRR389222_sub2_trimmed_bismark_bt2_SE_report.html").exists() }, + { assert new File("$outputDir/bismark/reports/SRR389222_sub3_trimmed_bismark_bt2_SE_report.html").exists() }, + { assert new File("$outputDir/bismark/summary/bismark_summary_report.html").exists() }, + { assert new File("$outputDir/bismark/summary/bismark_summary_report.txt").exists() }, + { assert new File("$outputDir/fastqc/Ecoli_1_fastqc.html").exists() }, + { assert new File("$outputDir/fastqc/Ecoli_2_fastqc.html").exists() }, + { assert new File("$outputDir/fastqc/SRR389222_sub1_fastqc.html").exists() }, + { assert new File("$outputDir/fastqc/SRR389222_sub2_fastqc.html").exists() }, + { assert new File("$outputDir/fastqc/SRR389222_sub3_fastqc.html").exists() }, + { assert new File("$outputDir/multiqc/bismark/multiqc_report.html").exists() }, + { assert new File("$outputDir/trimgalore/logs/Ecoli_1.fastq.gz_trimming_report.txt").exists() }, + { assert new File("$outputDir/trimgalore/logs/Ecoli_2.fastq.gz_trimming_report.txt").exists() }, + { assert new File("$outputDir/trimgalore/logs/SRR389222_sub1.fastq.gz_trimming_report.txt").exists() }, + { assert new File("$outputDir/trimgalore/logs/SRR389222_sub2.fastq.gz_trimming_report.txt").exists() }, + { assert new File("$outputDir/trimgalore/logs/SRR389222_sub3.fastq.gz_trimming_report.txt").exists() } + ) + } + + } + +} diff --git a/tests/bismark_hisat.nf.test b/tests/bismark_hisat.nf.test new file mode 100644 index 00000000..b4bfaa81 --- /dev/null +++ b/tests/bismark_hisat.nf.test @@ -0,0 +1,20 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "../main.nf" + + test("Should run without failures") { + + when { + params { + outdir = "$outputDir" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/bwameth.nf.test b/tests/bwameth.nf.test new file mode 100644 index 00000000..b4bfaa81 --- /dev/null +++ b/tests/bwameth.nf.test @@ -0,0 +1,20 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "../main.nf" + + test("Should run without failures") { + + when { + params { + outdir = "$outputDir" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/config/tags.yml b/tests/config/tags.yml deleted file mode 100644 index db5bda67..00000000 --- a/tests/config/tags.yml +++ /dev/null @@ -1,7 +0,0 @@ -# tags for tests - -bismark: - -bismark_hisat: - -bwameth: diff --git a/tests/nextflow.config b/tests/nextflow.config new file mode 100644 index 00000000..0d8397be --- /dev/null +++ b/tests/nextflow.config @@ -0,0 +1,38 @@ +/* +======================================================================================== + Nextflow config file for running tests +======================================================================================== +*/ + +params { + // Base directory for nf-core/modules test data + modules_testdata_base_path = 's3://ngi-igenomes/testdata/nf-core/modules/' + + // Base directory for nf-core/rnaseq test data + pipelines_testdata_base_path = 's3://ngi-igenomes/testdata/nf-core/pipelines/methylseq/2.7.0/' + + fasta = "${params.pipelines_testdata_base_path}/reference/genome.fa" + fasta_index = "${params.pipelines_testdata_base_path}/reference/genome.fa.fai" + + validationSchemaIgnoreParams = 'genomes,igenomes_base,modules_testdata_base_path,pipelines_testdata_base_path' +} + +// Impose sensible resource limits for testing +process { + withName: '.*' { + cpus = 2 + memory = 3.GB + time = 2.h + } +} + +// Impose same minimum Nextflow version as the pipeline for testing +manifest { + nextflowVersion = '!>=23.04.0' +} + +// Disable all Nextflow reporting options +timeline { enabled = false } +report { enabled = false } +trace { enabled = false } +dag { enabled = false } diff --git a/workflows/methylseq/methylseq.nf b/workflows/methylseq/methylseq.nf index 7730380c..0fe8b58b 100644 --- a/workflows/methylseq/methylseq.nf +++ b/workflows/methylseq/methylseq.nf @@ -19,11 +19,11 @@ include { validateInputSamplesheet } from '../../subworkflows/local/utils_nfcore // Aligner: bismark or bismark_hisat if( params.aligner =~ /bismark/ ){ - include { BISMARK } from '../../subworkflows/local/bismark/bismark' + include { BISMARK } from '../../subworkflows/local/bismark/' } // Aligner: bwameth else if ( params.aligner == 'bwameth' ){ - include { BWAMETH } from '../../subworkflows/local/bwameth/bwameth' + include { BWAMETH } from '../../subworkflows/local/bwameth/' } /*