Skip to content

Commit

Permalink
Merge pull request #1678 from maxulysse/nft-utils-0-0-3
Browse files Browse the repository at this point in the history
Migrate pytest aligner and pipeline default tests to nf-test
  • Loading branch information
maxulysse authored Oct 23, 2024
2 parents 96f6366 + fb9b6ee commit 100258d
Show file tree
Hide file tree
Showing 28 changed files with 1,280 additions and 802 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ jobs:
mkdir -p $NXF_SINGULARITY_CACHEDIR
mkdir -p $NXF_SINGULARITY_LIBRARYDIR
- name: Cache pdiff
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
id: cache-pip-pdiff
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-pdiff

- name: Install pdiff
run: python -m pip install --upgrade pip pdiff cryptography

- name: Set up miniconda
if: matrix.profile == 'conda'
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- [1669](https://github.com/nf-core/sarek/pull/1669) - Better nf-test pipeline level tests
- [1677](https://github.com/nf-core/sarek/pull/1677) - Migrate pytest aligner and pipeline default tests to nf-test
- [1680](https://github.com/nf-core/sarek/pull/1680) - Template update for nf-core/tools v3.0.0
- [1681](https://github.com/nf-core/sarek/pull/1681) - Template update for nf-core/tools v3.0.1

Expand Down
13 changes: 11 additions & 2 deletions nf-test.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
config {
// location for all nf-tests
testsDir "."
workDir ".nf-test"

// nf-test directory including temporary files for each test
workDir System.getenv("NFT_WORKDIR") ?: ".nf-test"

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

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

// Include plugins
plugins {
load "[email protected]"
load "[email protected]"
load "[email protected]"
}
}
9 changes: 5 additions & 4 deletions tests/.nftignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
csv/*.csv
multiqc/multiqc_data/gatk-base-recalibrator-reported-empirical-plot.txt
multiqc/multiqc_data/gatk_base_recalibrator.txt
multiqc/multiqc_data/multiqc.log
multiqc/multiqc_data/multiqc_data.json
Expand All @@ -7,12 +8,12 @@ multiqc/multiqc_data/multiqc_picard_dups.txt
multiqc/multiqc_data/multiqc_software_versions.txt
multiqc/multiqc_data/multiqc_sources.txt
multiqc/multiqc_data/picard_deduplication.txt
multiqc/multiqc_plots/pdf/*
multiqc/multiqc_plots/png/picard_deduplication*.png
multiqc/multiqc_plots/svg/*
multiqc/multiqc_plots/{svg,pdf,png}/*.{svg,pdf,png}
multiqc/multiqc_report.html
pipeline_info/*.{html,json,txt,yml}
preprocessing/**/*.{md,recal}.{cram,cram.crai,table}
preprocessing/**/*.{md,recal,sorted}.{bam,bam.bai,cram,cram.crai,table}
reference/dragmap/hash_table.{cfg,cfg.bin}
reference/dragmap/hash_table_stats.txt
reports/fastqc/**/*_fastqc.{html,zip}
reports/markduplicates/**/*.md.cram.metrics
variant_calling/**/*.vcf.{gz,gz.tbi}
81 changes: 81 additions & 0 deletions tests/aligner-bwa-mem.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
nextflow_pipeline {

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

test("Run with profile test | --aligner bwa-mem --save_reference | skip QC/recal/md") {

when {
params {
aligner = 'bwa-mem'
modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/'
outdir = "$outputDir"
save_reference = true
skip_tools = 'baserecalibrator,fastqc,markduplicates,mosdepth,multiqc,samtools'
tools = ''
}
}

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 | --aligner bwa-mem --save_reference --build_only_index") {

when {
params {
aligner = 'bwa-mem'
build_only_index = true
input = false
outdir = "$outputDir"
save_reference = true
skip_tools = 'multiqc'
tools = ''
}
}

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_sarek_software_mqc_versions.yml"),
// All stable path name, with a relative path
stable_name,
// All files with stable contents
stable_path
).match() }
)
}
}
}
113 changes: 113 additions & 0 deletions tests/aligner-bwa-mem.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"Run with profile test | --aligner bwa-mem --save_reference | skip QC/recal/md": {
"content": [
10,
{
"BAM_TO_CRAM_MAPPING": {
"samtools": 1.21
},
"BWAMEM1_MEM": {
"bwa": "0.7.18-r1243-dirty",
"samtools": 1.2
},
"INDEX_MERGE_BAM": {
"samtools": 1.21
},
"MERGE_BAM": {
"samtools": 1.21
},
"Workflow": {
"nf-core/sarek": "v3.5.0dev"
}
},
[
"csv",
"csv/mapped.csv",
"pipeline_info",
"pipeline_info/nf_core_sarek_software_mqc_versions.yml",
"preprocessing",
"preprocessing/mapped",
"preprocessing/mapped/test",
"preprocessing/mapped/test/test.sorted.cram",
"preprocessing/mapped/test/test.sorted.cram.crai",
"reference",
"reference/bwa",
"reference/bwa/genome.amb",
"reference/bwa/genome.ann",
"reference/bwa/genome.bwt",
"reference/bwa/genome.pac",
"reference/bwa/genome.sa",
"reference/intervals",
"reference/intervals/chr22_1-40001.bed",
"reference/intervals/chr22_1-40001.bed.gz",
"reference/intervals/genome.bed",
"reference/intervals/genome.bed.gz"
],
[
"genome.amb:md5,1891c1de381b3a96d4e72f590fde20c1",
"genome.ann:md5,2df4aa2d7580639fa0fcdbcad5e2e969",
"genome.bwt:md5,815eded87e4cb6b0f1daab5c4d6e30af",
"genome.pac:md5,8569fbdb2c98c6fb16dfa73d8eacb070",
"genome.sa:md5,e7cff62b919448a3a3d0fe4aaf427594",
"chr22_1-40001.bed:md5,87a15eb9c2ff20ccd5cd8735a28708f7",
"chr22_1-40001.bed.gz:md5,87a15eb9c2ff20ccd5cd8735a28708f7",
"genome.bed:md5,a87dc7d20ebca626f65cc16ff6c97a3e",
"genome.bed.gz:md5,a87dc7d20ebca626f65cc16ff6c97a3e"
],
[
[
"test.sorted.cram",
"5534c350547fd253f0f2b9450362bed"
]
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.09.0"
},
"timestamp": "2024-10-08T11:22:13.394114"
},
"Run with profile test | --aligner bwa-mem --save_reference --build_only_index": {
"content": [
5,
{
"Workflow": {
"nf-core/sarek": "v3.5.0dev"
}
},
[
"csv",
"pipeline_info",
"pipeline_info/nf_core_sarek_software_mqc_versions.yml",
"reference",
"reference/bwa",
"reference/bwa/genome.amb",
"reference/bwa/genome.ann",
"reference/bwa/genome.bwt",
"reference/bwa/genome.pac",
"reference/bwa/genome.sa",
"reference/intervals",
"reference/intervals/chr22_1-40001.bed",
"reference/intervals/chr22_1-40001.bed.gz",
"reference/intervals/genome.bed",
"reference/intervals/genome.bed.gz"
],
[
"genome.amb:md5,1891c1de381b3a96d4e72f590fde20c1",
"genome.ann:md5,2df4aa2d7580639fa0fcdbcad5e2e969",
"genome.bwt:md5,815eded87e4cb6b0f1daab5c4d6e30af",
"genome.pac:md5,8569fbdb2c98c6fb16dfa73d8eacb070",
"genome.sa:md5,e7cff62b919448a3a3d0fe4aaf427594",
"chr22_1-40001.bed:md5,87a15eb9c2ff20ccd5cd8735a28708f7",
"chr22_1-40001.bed.gz:md5,87a15eb9c2ff20ccd5cd8735a28708f7",
"genome.bed:md5,a87dc7d20ebca626f65cc16ff6c97a3e",
"genome.bed.gz:md5,a87dc7d20ebca626f65cc16ff6c97a3e"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.09.0"
},
"timestamp": "2024-10-08T11:23:05.203586"
}
}
81 changes: 81 additions & 0 deletions tests/aligner-bwa-mem2.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
nextflow_pipeline {

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

test("Run with profile test | --aligner bwa-mem2 --save_reference | skip QC/recal/md") {

when {
params {
aligner = 'bwa-mem2'
modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/'
outdir = "$outputDir"
save_reference = true
skip_tools = 'baserecalibrator,fastqc,markduplicates,mosdepth,multiqc,samtools'
tools = ''
}
}

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 | --aligner bwa-mem2 --save_reference --build_only_index") {

when {
params {
aligner = 'bwa-mem2'
build_only_index = true
input = false
outdir = "$outputDir"
save_reference = true
skip_tools = 'multiqc'
tools = ''
}
}

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_sarek_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 100258d

Please sign in to comment.