|
| 1 | +nextflow_pipeline { |
| 2 | + |
| 3 | + name "Test pipeline: NFCORE_EAGER" |
| 4 | + script "main.nf" |
| 5 | + tag "pipeline" |
| 6 | + tag "nfcore_eager" |
| 7 | + tag "test_minimal" |
| 8 | + |
| 9 | + test("test_minimal_profile") { |
| 10 | + |
| 11 | + when { |
| 12 | + params { |
| 13 | + outdir = "$outputDir" |
| 14 | + } |
| 15 | + } |
| 16 | + |
| 17 | + then { |
| 18 | + |
| 19 | + /////////////////// |
| 20 | + // DOCUMENTATION // |
| 21 | + /////////////////// |
| 22 | + |
| 23 | + // The contents of each top level results directory should be tested with individually named snapshots. |
| 24 | + // Within each snapshot, there should be two to three distinct variables, that contain the files to be tested. |
| 25 | + // - stable_name_<dir> is for files with variable md5sums (i.e. content) so only names will be compared |
| 26 | + // - stable_content_<dir> is for files with stable md5sums (i.e. content) so md5sums will be compared |
| 27 | + // - bams_<dir> is for BAM files, where the headerMD5 is checked for stability (since the content can be unstable) |
| 28 | + // If a directory is fully stable, you can drop `stable_name_*` |
| 29 | + // If a directory contains no BAMs, you can drop `bams_*` |
| 30 | + |
| 31 | + // Generate with: nf-test test --tag test_minimal --profile docker,test_minimal --update-snapshot |
| 32 | + // Test with: nf-test test --tag test_minimal --profile docker,test_minimal |
| 33 | + // NOTE: BAMs are always only stable in name, because: |
| 34 | + // 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) |
| 35 | + // 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) |
| 36 | + // point b) also causes BAIs to be unstable. |
| 37 | + // c) Merging of multiple BAMs with duplicate @RG / @PG tags can cause the header to be unstable (particularly in the case of shards/lanes) |
| 38 | + |
| 39 | + ////////////////////// |
| 40 | + // DEFINE VARIABLES // |
| 41 | + ////////////////////// |
| 42 | + |
| 43 | + // Define exclusion patterns for files with unstable contents |
| 44 | + // NOTE: When a section needs more than a couple of small patterns, consider adding a variable to store the patterns here |
| 45 | + // This is particularly important if the patterns excluded in the stable content section should be included in the stable name section |
| 46 | + |
| 47 | + |
| 48 | + // Check that no files are missing/added |
| 49 | + // Command legend: Result directory to index , includeDir: include dirs?, ignore: exclude patterns , ignoreFile: exclude pattern list , include: include patterns |
| 50 | + def stable_name_all = getAllFilesFromDir("$outputDir/" , includeDir: false , ignore: ['pipeline_info/*'] , ignoreFile: null , include: ['*', '**/*'] ) |
| 51 | + |
| 52 | + // Authentication |
| 53 | + def stable_content_authentication = getAllFilesFromDir("$outputDir/authentication" , includeDir: false , ignore: null , ignoreFile: null , include: ['*', '**/*'] ) |
| 54 | + // def stable_name_authentication = getAllFilesFromDir("$outputDir/authentication" , includeDir: false , ignore: null , ignoreFile: null , include: unstable_patterns_auth) |
| 55 | + |
| 56 | + // Final_bams |
| 57 | + def stable_content_final_bams = getAllFilesFromDir("$outputDir/final_bams" , includeDir: false , ignore: null , ignoreFile: null , include: ['**/*.flagstat'] ) |
| 58 | + def stable_name_final_bams = getAllFilesFromDir("$outputDir/final_bams" , includeDir: false , ignore: null , ignoreFile: null , include: ['**/*.{bam,bai}'] ) |
| 59 | + |
| 60 | + // Mapping (incl. bam_input flasgstat) |
| 61 | + def stable_content_mapping = getAllFilesFromDir("$outputDir/mapping" , includeDir: false , ignore: null , ignoreFile: null , include: ['**/*.flagstat'] ) |
| 62 | + def stable_name_mapping = getAllFilesFromDir("$outputDir/mapping" , includeDir: false , ignore: null , ignoreFile: null , include: ['**/*.{bam,bai}'] ) |
| 63 | + |
| 64 | + // Preprocessing |
| 65 | + def stable_content_preprocessing = getAllFilesFromDir("$outputDir/preprocessing" , includeDir: false , ignore: ['**/*.{zip,html}'] , ignoreFile: null , include: ['**/*'] ) |
| 66 | + def stable_name_preprocessing = getAllFilesFromDir("$outputDir/preprocessing" , includeDir: false , ignore: null , ignoreFile: null , include: ['**/*.{zip,html}'] ) |
| 67 | + |
| 68 | + // MultiQC |
| 69 | + def stable_name_multiqc = getAllFilesFromDir("$outputDir/multiqc" , includeDir: false , ignore: null , ignoreFile: null , include: ['*', '**/*'] ) |
| 70 | + |
| 71 | + /////////////////////// |
| 72 | + // DEFINE ASSERTIONS // |
| 73 | + /////////////////////// |
| 74 | + |
| 75 | + assertAll( |
| 76 | + { assert workflow.success }, |
| 77 | + // This checks that there are no missing or additional output files. |
| 78 | + // Also a good starting point to look at all the files in the output folder than need to be checked in subsequent sections. |
| 79 | + { assert snapshot( stable_name_all*.name ).match("all_files") }, |
| 80 | + |
| 81 | + // Checking changes to contents of each section |
| 82 | + // NOTE: Keep the order of the sections in the alphanumeric order of the output directories. |
| 83 | + // Each section should first check stable_content, stable_name second (if applicable). |
| 84 | + { assert snapshot( stable_content_authentication ).match("authentication") }, |
| 85 | + { assert snapshot( stable_content_final_bams , stable_name_final_bams*.name ).match("final_bams") }, |
| 86 | + // NOTE: The snapshot section for mapping cannot be named 'mapping'. See https://github.com/askimed/nf-test/issues/279 |
| 87 | + { assert snapshot( stable_content_mapping , stable_name_mapping*.name ).match("mapping_output") }, |
| 88 | + { assert snapshot( stable_content_preprocessing , stable_name_preprocessing*.name ).match("preprocessing") }, |
| 89 | + |
| 90 | + // MultiQC |
| 91 | + { assert snapshot( stable_name_multiqc*.name ).match("multiqc") }, |
| 92 | + |
| 93 | + // Versions |
| 94 | + { assert new File("$outputDir/pipeline_info/nf_core_eager_software_mqc_versions.yml").exists() }, |
| 95 | + |
| 96 | + ) |
| 97 | + } |
| 98 | + } |
| 99 | +} |
0 commit comments