Skip to content
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

Migrate pytest aligner and pipeline default tests to nf-test #1678

Merged
merged 25 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5e7f6f5
migrate pytest aligner tests to nf-test
maxulysse Oct 7, 2024
e9f0fb9
update CHANGELOG
maxulysse Oct 7, 2024
1d9a18e
install pdiff
maxulysse Oct 7, 2024
b7417ec
properly install pdiff
maxulysse Oct 7, 2024
89507f8
update nftignore and snapshots
maxulysse Oct 7, 2024
7b7b9c1
update CHANGELOG
maxulysse Oct 8, 2024
1bfe04a
add tumor-normal-pair test
maxulysse Oct 8, 2024
c9b2f0d
update CHANGELOG
maxulysse Oct 8, 2024
0c5114f
add more tests, update to nft-utils 0.0.3, add nft-bam 0.4.0
maxulysse Oct 8, 2024
977389f
fix snapshots
maxulysse Oct 8, 2024
d31edb8
ignore bam files from snapshots
maxulysse Oct 8, 2024
1e82940
ignore bai files from snapshots
maxulysse Oct 8, 2024
4713bad
snapshot bam files
maxulysse Oct 8, 2024
56791a2
update nftignore - no files from multiqc_plots
maxulysse Oct 8, 2024
2c9d25b
update snapshots + snapshot bam files using nft-bam
maxulysse Oct 8, 2024
4db3c99
snapshot bam files
maxulysse Oct 8, 2024
5634713
properly update nftignore - no files from multiqc_plots
maxulysse Oct 8, 2024
6dd2fd6
snapshot cram files with nft-bam
maxulysse Oct 8, 2024
61f19fd
update snapshots
maxulysse Oct 8, 2024
ab16157
update nftignore
maxulysse Oct 8, 2024
752f66a
Merge branch 'dev' into nft-utils-0-0-3
maxulysse Oct 11, 2024
b3f9611
fix test
maxulysse Oct 11, 2024
496b146
Merge branch 'nft-utils-0-0-3' of github.com:maxulysse/nf-core_sarek …
maxulysse Oct 11, 2024
6420256
Update nf-test.config
maxulysse Oct 11, 2024
fb9b6ee
Update nf-test.config
maxulysse Oct 23, 2024
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
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
Loading