Skip to content

nf-test test-minimal #1145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions tests/test_minimal.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
nextflow_pipeline {

name "Test pipeline: NFCORE_EAGER"
script "main.nf"
tag "pipeline"
tag "nfcore_eager"
tag "test_minimal"

test("test_minimal_profile") {

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

then {

///////////////////
// DOCUMENTATION //
///////////////////

// The contents of each top level results directory should be tested with individually named snapshots.
// Within each snapshot, there should be two to three distinct variables, that contain the files to be tested.
// - stable_name_<dir> is for files with variable md5sums (i.e. content) so only names will be compared
// - stable_content_<dir> is for files with stable md5sums (i.e. content) so md5sums will be compared
// - bams_<dir> is for BAM files, where the headerMD5 is checked for stability (since the content can be unstable)
// If a directory is fully stable, you can drop `stable_name_*`
// If a directory contains no BAMs, you can drop `bams_*`

// Generate with: nf-test test --tag test_minimal --profile docker,test_minimal --update-snapshot
// Test with: nf-test test --tag test_minimal --profile docker,test_minimal
// NOTE: BAMs are always only stable in name, because:
// a) sharding breaks header since the shard that was first is named in the header (Fixed in https://github.com/nf-core/eager/pull/1112)
// b) the order of the reads in the BAMs is not stable (sorted, but reads that share a start position can be in any order)
// point b) also causes BAIs to be unstable.
// c) Merging of multiple BAMs with duplicate @RG / @PG tags can cause the header to be unstable (particularly in the case of shards/lanes)

//////////////////////
// DEFINE VARIABLES //
//////////////////////

// Define exclusion patterns for files with unstable contents
// NOTE: When a section needs more than a couple of small patterns, consider adding a variable to store the patterns here
// This is particularly important if the patterns excluded in the stable content section should be included in the stable name section


// Check that no files are missing/added
// Command legend: Result directory to index , includeDir: include dirs?, ignore: exclude patterns , ignoreFile: exclude pattern list , include: include patterns
def stable_name_all = getAllFilesFromDir("$outputDir/" , includeDir: false , ignore: ['pipeline_info/*'] , ignoreFile: null , include: ['*', '**/*'] )

// Authentication
def stable_content_authentication = getAllFilesFromDir("$outputDir/authentication" , includeDir: false , ignore: null , ignoreFile: null , include: ['*', '**/*'] )
// def stable_name_authentication = getAllFilesFromDir("$outputDir/authentication" , includeDir: false , ignore: null , ignoreFile: null , include: unstable_patterns_auth)

// Final_bams
def stable_content_final_bams = getAllFilesFromDir("$outputDir/final_bams" , includeDir: false , ignore: null , ignoreFile: null , include: ['**/*.flagstat'] )
def stable_name_final_bams = getAllFilesFromDir("$outputDir/final_bams" , includeDir: false , ignore: null , ignoreFile: null , include: ['**/*.{bam,bai}'] )

// Mapping (incl. bam_input flasgstat)
def stable_content_mapping = getAllFilesFromDir("$outputDir/mapping" , includeDir: false , ignore: null , ignoreFile: null , include: ['**/*.flagstat'] )
def stable_name_mapping = getAllFilesFromDir("$outputDir/mapping" , includeDir: false , ignore: null , ignoreFile: null , include: ['**/*.{bam,bai}'] )

// Preprocessing
def stable_content_preprocessing = getAllFilesFromDir("$outputDir/preprocessing" , includeDir: false , ignore: ['**/*.{zip,html}'] , ignoreFile: null , include: ['**/*'] )
def stable_name_preprocessing = getAllFilesFromDir("$outputDir/preprocessing" , includeDir: false , ignore: null , ignoreFile: null , include: ['**/*.{zip,html}'] )

// MultiQC
def stable_name_multiqc = getAllFilesFromDir("$outputDir/multiqc" , includeDir: false , ignore: null , ignoreFile: null , include: ['*', '**/*'] )

///////////////////////
// DEFINE ASSERTIONS //
///////////////////////

assertAll(
{ assert workflow.success },
// This checks that there are no missing or additional output files.
// Also a good starting point to look at all the files in the output folder than need to be checked in subsequent sections.
{ assert snapshot( stable_name_all*.name ).match("all_files") },

// Checking changes to contents of each section
// NOTE: Keep the order of the sections in the alphanumeric order of the output directories.
// Each section should first check stable_content, stable_name second (if applicable).
{ assert snapshot( stable_content_authentication ).match("authentication") },
{ assert snapshot( stable_content_final_bams , stable_name_final_bams*.name ).match("final_bams") },
// NOTE: The snapshot section for mapping cannot be named 'mapping'. See https://github.com/askimed/nf-test/issues/279
{ assert snapshot( stable_content_mapping , stable_name_mapping*.name ).match("mapping_output") },
{ assert snapshot( stable_content_preprocessing , stable_name_preprocessing*.name ).match("preprocessing") },

// MultiQC
{ assert snapshot( stable_name_multiqc*.name ).match("multiqc") },

// Versions
{ assert new File("$outputDir/pipeline_info/nf_core_eager_software_mqc_versions.yml").exists() },

)
}
}
}
249 changes: 249 additions & 0 deletions tests/test_minimal.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
{
"all_files": {
"content": [
[
"JK2782_JK2782_TGGCCGATCAACGA_BAM_Mammoth_MT_Krause_percent_on_target_mqc.json",
"JK2782_JK2782_TGGCCGATCAACGA_Mammoth_MT_Krause_percent_on_target_mqc.json",
"JK2802_JK2802_AGAATAACCTACCA_Mammoth_MT_Krause_percent_on_target_mqc.json",
"JK2782_Mammoth_MT_Krause.bam",
"JK2782_Mammoth_MT_Krause.bam.bai",
"JK2802_Mammoth_MT_Krause.bam",
"JK2802_Mammoth_MT_Krause.bam.bai",
"JK2782_Mammoth_MT_Krause.flagstat",
"JK2802_Mammoth_MT_Krause.flagstat",
"JK2782_JK2782_TGGCCGATCAACGA_BAM_Mammoth_MT_Krause_sorted.flagstat",
"JK2782_JK2782_TGGCCGATCAACGA_BAM_Mammoth_MT_Krause_sorted.bam",
"JK2782_JK2782_TGGCCGATCAACGA_BAM_Mammoth_MT_Krause_sorted.bam.bai",
"JK2782_JK2782_TGGCCGATCAACGA_Mammoth_MT_Krause_sorted.bam",
"JK2782_JK2782_TGGCCGATCAACGA_Mammoth_MT_Krause_sorted.bam.bai",
"JK2802_JK2802_AGAATAACCTACCA_Mammoth_MT_Krause_sorted.bam",
"JK2802_JK2802_AGAATAACCTACCA_Mammoth_MT_Krause_sorted.bam.bai",
"JK2782_JK2782_TGGCCGATCAACGA_Mammoth_MT_Krause_sorted.flagstat",
"JK2802_JK2802_AGAATAACCTACCA_Mammoth_MT_Krause_sorted.flagstat",
"fastqc-status-check-heatmap.txt",
"fastqc_adapter_content_plot.txt",
"fastqc_per_base_n_content_plot.txt",
"fastqc_per_base_sequence_quality_plot.txt",
"fastqc_per_sequence_gc_content_plot_Counts.txt",
"fastqc_per_sequence_gc_content_plot_Percentages.txt",
"fastqc_per_sequence_quality_scores_plot.txt",
"fastqc_sequence_counts_plot.txt",
"fastqc_sequence_duplication_levels_plot.txt",
"fastqc_top_overrepresented_sequences_table.txt",
"multiqc.log",
"multiqc_citations.txt",
"multiqc_data.json",
"multiqc_fastqc.txt",
"multiqc_general_stats.txt",
"multiqc_samtools_flagstat.txt",
"multiqc_software_versions.txt",
"multiqc_sources.txt",
"samtools-flagstat-dp_Percentage_of_total.txt",
"samtools-flagstat-dp_Read_counts.txt",
"fastqc-status-check-heatmap.pdf",
"fastqc_adapter_content_plot.pdf",
"fastqc_per_base_n_content_plot.pdf",
"fastqc_per_base_sequence_quality_plot.pdf",
"fastqc_per_sequence_gc_content_plot_Counts.pdf",
"fastqc_per_sequence_gc_content_plot_Percentages.pdf",
"fastqc_per_sequence_quality_scores_plot.pdf",
"fastqc_sequence_counts_plot-cnt.pdf",
"fastqc_sequence_counts_plot-pct.pdf",
"fastqc_sequence_duplication_levels_plot.pdf",
"fastqc_top_overrepresented_sequences_table.pdf",
"general_stats_table.pdf",
"samtools-flagstat-dp_Percentage_of_total.pdf",
"samtools-flagstat-dp_Read_counts.pdf",
"fastqc-status-check-heatmap.png",
"fastqc_adapter_content_plot.png",
"fastqc_per_base_n_content_plot.png",
"fastqc_per_base_sequence_quality_plot.png",
"fastqc_per_sequence_gc_content_plot_Counts.png",
"fastqc_per_sequence_gc_content_plot_Percentages.png",
"fastqc_per_sequence_quality_scores_plot.png",
"fastqc_sequence_counts_plot-cnt.png",
"fastqc_sequence_counts_plot-pct.png",
"fastqc_sequence_duplication_levels_plot.png",
"fastqc_top_overrepresented_sequences_table.png",
"general_stats_table.png",
"samtools-flagstat-dp_Percentage_of_total.png",
"samtools-flagstat-dp_Read_counts.png",
"fastqc-status-check-heatmap.svg",
"fastqc_adapter_content_plot.svg",
"fastqc_per_base_n_content_plot.svg",
"fastqc_per_base_sequence_quality_plot.svg",
"fastqc_per_sequence_gc_content_plot_Counts.svg",
"fastqc_per_sequence_gc_content_plot_Percentages.svg",
"fastqc_per_sequence_quality_scores_plot.svg",
"fastqc_sequence_counts_plot-cnt.svg",
"fastqc_sequence_counts_plot-pct.svg",
"fastqc_sequence_duplication_levels_plot.svg",
"fastqc_top_overrepresented_sequences_table.svg",
"general_stats_table.svg",
"samtools-flagstat-dp_Percentage_of_total.svg",
"samtools-flagstat-dp_Read_counts.svg",
"multiqc_report.html",
"JK2782_JK2782_TGGCCGATCAACGA_L1_1_fastqc.html",
"JK2782_JK2782_TGGCCGATCAACGA_L1_1_fastqc.zip",
"JK2782_JK2782_TGGCCGATCAACGA_L1_2_fastqc.html",
"JK2782_JK2782_TGGCCGATCAACGA_L1_2_fastqc.zip",
"JK2802_JK2802_AGAATAACCTACCA_L2_fastqc.html",
"JK2802_JK2802_AGAATAACCTACCA_L2_fastqc.zip"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.6"
},
"timestamp": "2025-05-23T10:36:48.672625"
},
"preprocessing": {
"content": [
[

],
[
"JK2782_JK2782_TGGCCGATCAACGA_L1_1_fastqc.html",
"JK2782_JK2782_TGGCCGATCAACGA_L1_1_fastqc.zip",
"JK2782_JK2782_TGGCCGATCAACGA_L1_2_fastqc.html",
"JK2782_JK2782_TGGCCGATCAACGA_L1_2_fastqc.zip",
"JK2802_JK2802_AGAATAACCTACCA_L2_fastqc.html",
"JK2802_JK2802_AGAATAACCTACCA_L2_fastqc.zip"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.6"
},
"timestamp": "2025-05-23T10:36:48.803481"
},
"final_bams": {
"content": [
[
"JK2782_Mammoth_MT_Krause.flagstat:md5,9ebb4b5e99894d2a87ac3b60a78e7142",
"JK2802_Mammoth_MT_Krause.flagstat:md5,51816d63f34b4818ed6f1ec968f05fc0"
],
[
"JK2782_Mammoth_MT_Krause.bam",
"JK2782_Mammoth_MT_Krause.bam.bai",
"JK2802_Mammoth_MT_Krause.bam",
"JK2802_Mammoth_MT_Krause.bam.bai"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.6"
},
"timestamp": "2025-05-23T10:36:48.749353"
},
"multiqc": {
"content": [
[
"fastqc-status-check-heatmap.txt",
"fastqc_adapter_content_plot.txt",
"fastqc_per_base_n_content_plot.txt",
"fastqc_per_base_sequence_quality_plot.txt",
"fastqc_per_sequence_gc_content_plot_Counts.txt",
"fastqc_per_sequence_gc_content_plot_Percentages.txt",
"fastqc_per_sequence_quality_scores_plot.txt",
"fastqc_sequence_counts_plot.txt",
"fastqc_sequence_duplication_levels_plot.txt",
"fastqc_top_overrepresented_sequences_table.txt",
"multiqc.log",
"multiqc_citations.txt",
"multiqc_data.json",
"multiqc_fastqc.txt",
"multiqc_general_stats.txt",
"multiqc_samtools_flagstat.txt",
"multiqc_software_versions.txt",
"multiqc_sources.txt",
"samtools-flagstat-dp_Percentage_of_total.txt",
"samtools-flagstat-dp_Read_counts.txt",
"fastqc-status-check-heatmap.pdf",
"fastqc_adapter_content_plot.pdf",
"fastqc_per_base_n_content_plot.pdf",
"fastqc_per_base_sequence_quality_plot.pdf",
"fastqc_per_sequence_gc_content_plot_Counts.pdf",
"fastqc_per_sequence_gc_content_plot_Percentages.pdf",
"fastqc_per_sequence_quality_scores_plot.pdf",
"fastqc_sequence_counts_plot-cnt.pdf",
"fastqc_sequence_counts_plot-pct.pdf",
"fastqc_sequence_duplication_levels_plot.pdf",
"fastqc_top_overrepresented_sequences_table.pdf",
"general_stats_table.pdf",
"samtools-flagstat-dp_Percentage_of_total.pdf",
"samtools-flagstat-dp_Read_counts.pdf",
"fastqc-status-check-heatmap.png",
"fastqc_adapter_content_plot.png",
"fastqc_per_base_n_content_plot.png",
"fastqc_per_base_sequence_quality_plot.png",
"fastqc_per_sequence_gc_content_plot_Counts.png",
"fastqc_per_sequence_gc_content_plot_Percentages.png",
"fastqc_per_sequence_quality_scores_plot.png",
"fastqc_sequence_counts_plot-cnt.png",
"fastqc_sequence_counts_plot-pct.png",
"fastqc_sequence_duplication_levels_plot.png",
"fastqc_top_overrepresented_sequences_table.png",
"general_stats_table.png",
"samtools-flagstat-dp_Percentage_of_total.png",
"samtools-flagstat-dp_Read_counts.png",
"fastqc-status-check-heatmap.svg",
"fastqc_adapter_content_plot.svg",
"fastqc_per_base_n_content_plot.svg",
"fastqc_per_base_sequence_quality_plot.svg",
"fastqc_per_sequence_gc_content_plot_Counts.svg",
"fastqc_per_sequence_gc_content_plot_Percentages.svg",
"fastqc_per_sequence_quality_scores_plot.svg",
"fastqc_sequence_counts_plot-cnt.svg",
"fastqc_sequence_counts_plot-pct.svg",
"fastqc_sequence_duplication_levels_plot.svg",
"fastqc_top_overrepresented_sequences_table.svg",
"general_stats_table.svg",
"samtools-flagstat-dp_Percentage_of_total.svg",
"samtools-flagstat-dp_Read_counts.svg",
"multiqc_report.html"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.6"
},
"timestamp": "2025-05-23T10:36:48.824552"
},
"mapping_output": {
"content": [
[
"JK2782_JK2782_TGGCCGATCAACGA_BAM_Mammoth_MT_Krause_sorted.flagstat:md5,9a10991f5670a52975a622a8b056e2bc",
"JK2782_JK2782_TGGCCGATCAACGA_Mammoth_MT_Krause_sorted.flagstat:md5,274942e6f459e1f85bffd0719ea24038",
"JK2802_JK2802_AGAATAACCTACCA_Mammoth_MT_Krause_sorted.flagstat:md5,51816d63f34b4818ed6f1ec968f05fc0"
],
[
"JK2782_JK2782_TGGCCGATCAACGA_BAM_Mammoth_MT_Krause_sorted.bam",
"JK2782_JK2782_TGGCCGATCAACGA_BAM_Mammoth_MT_Krause_sorted.bam.bai",
"JK2782_JK2782_TGGCCGATCAACGA_Mammoth_MT_Krause_sorted.bam",
"JK2782_JK2782_TGGCCGATCAACGA_Mammoth_MT_Krause_sorted.bam.bai",
"JK2802_JK2802_AGAATAACCTACCA_Mammoth_MT_Krause_sorted.bam",
"JK2802_JK2802_AGAATAACCTACCA_Mammoth_MT_Krause_sorted.bam.bai"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.6"
},
"timestamp": "2025-05-23T10:36:48.771636"
},
"authentication": {
"content": [
[
"JK2782_JK2782_TGGCCGATCAACGA_BAM_Mammoth_MT_Krause_percent_on_target_mqc.json:md5,13303511f19f618a524e30b3377497fb",
"JK2782_JK2782_TGGCCGATCAACGA_Mammoth_MT_Krause_percent_on_target_mqc.json:md5,90a8f1d5c1017f0000ac960b03767eba",
"JK2802_JK2802_AGAATAACCTACCA_Mammoth_MT_Krause_percent_on_target_mqc.json:md5,d26aac162887528fb3a3b2fa9b86954f"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.6"
},
"timestamp": "2025-05-23T10:36:48.717265"
}
}