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

Swap ngscheckmate/ncm to nftest #5679

Merged
merged 2 commits into from
May 23, 2024
Merged
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
1 change: 1 addition & 0 deletions modules/nf-core/ngscheckmate/ncm/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ process NGSCHECKMATE_NCM {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "$meta.id"
"""
touch ${prefix}_output_corr_matrix.txt
Expand Down
5 changes: 5 additions & 0 deletions modules/nf-core/ngscheckmate/ncm/tests/bam.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: NGSCHECKMATE_NCM {
ext.args = '-B'
}
}
184 changes: 184 additions & 0 deletions modules/nf-core/ngscheckmate/ncm/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
nextflow_process {

name "Test Process NGSCHECKMATE_NCM"
script "../main.nf"
process "NGSCHECKMATE_NCM"
config "./nextflow.config"

tag "modules"
tag "modules_nfcore"
tag "ngscheckmate"
tag "ngscheckmate/ncm"
tag "bedtools/makewindows"
tag "bcftools/mpileup"

setup {

run("BEDTOOLS_MAKEWINDOWS") {
script "../../../bedtools/makewindows/main.nf"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SPPearce @nvnieuwk : Will that work in a pipeline where bedtools isn't installed? I'm having problems running this nf-test in Sarek where we don't have bedtools installed. The nf-test ran better after I installed bedtools in Sarek, but that doesn't seem like the right solution to me 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point! Maybe this is something that can be handled by nf-core tools (@mirpedrol)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm.
The alternative would be to add files to test_data instead, but there are quite a few modules that do this kind of setup block. This is essentially taking a bed file and splitting it into individual bases.
I guess BCFTOOLS_MPILEUP exists in sarek already, so you didn't have an issue with that part.

Copy link
Contributor

@asp8200 asp8200 Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BCFTOOLS_MPILEUP is installed in Sarek, so that didn't cause any issues. However, I guess the nf-test should be kind of self-contained, and not rely on what other modules might or might not be installed in the particular pipeline that is trying to use the module.

I also had to change all params.test_data... to params.modules_testdata_base_path... to get the test kind of work, that is, I managed to get 3 out of 4 "subtests" working:

maxulysse/nf-core_sarek#7

process {
"""
input[0] = [ [ id:'test' ],
file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)
]
"""
}
}

run("BCFTOOLS_MPILEUP", alias: "BCFTOOLS_MPILEUP1") {
script "../../../bcftools/mpileup/main.nf"
process {
"""
input[0] = [
[ id:'test1' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)
]
input[1] = [ [ id:'sarscov2' ],
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
input[2] = false
"""
}
}

run("BCFTOOLS_MPILEUP", alias: "BCFTOOLS_MPILEUP2") {
script "../../../bcftools/mpileup/main.nf"
process {
"""
input[0] = [
[ id:'test2' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)
]
input[1] = [ [ id:'sarscov2' ],
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
input[2] = false
"""
}
}

}


test("sarscov2 - bam") {
config "./bam.config"
when {
process {
"""
input[0] = [ [ id: 'combined_bams' ],
[file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'] , checkIfExists: true ),
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'] , checkIfExists: true ),
file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam'] , checkIfExists: true ),
file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam_bai'], checkIfExists: true )
]
]
input[1] = BEDTOOLS_MAKEWINDOWS.out.bed
input[2] = [ [ id:'sarscov2' ],
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.corr_matrix,
process.out.matched,
process.out.all,
process.out.versions
).match() }
)
}

}

test("sarscov2 - vcf") {
config "./vcf.config"
when {
process {
"""
input[0] = BCFTOOLS_MPILEUP1.out.vcf.combine(BCFTOOLS_MPILEUP2.out.vcf.map{it[1]}).map{meta, one, two -> [meta, [one, two]]}.map{meta, stuff -> [meta, stuff.flatten()]}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is horrific and could do with cleaning up...
I have two outputs that are both:
[meta, vcf]
and I want to make
[new_meta, [vcf1, vcf2]]

input[1] = BEDTOOLS_MAKEWINDOWS.out.bed
input[2] = [ [ id:'sarscov2' ],
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.corr_matrix,
process.out.matched,
process.out.all,
file(process.out.pdf[0][1]).name,
process.out.versions
).match() }
)
}

}

test("sarscov2 - bam - stub") {

options "-stub"
config "./bam.config"
when {
process {
"""
input[0] = [ [ id: 'combined_bams' ],
[file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'] , checkIfExists: true ),
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'] , checkIfExists: true ),
file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam'] , checkIfExists: true ),
file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam_bai'], checkIfExists: true )
]
]
input[1] = BEDTOOLS_MAKEWINDOWS.out.bed
input[2] = [ [ id:'sarscov2' ],
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("sarscov2 - vcf - stub") {

options "-stub"
config "./vcf.config"
when {
process {
"""
input[0] = BCFTOOLS_MPILEUP1.out.vcf.combine(BCFTOOLS_MPILEUP2.out.vcf.map{it[1]})
input[1] = BEDTOOLS_MAKEWINDOWS.out.bed
input[2] = [ [ id:'sarscov2' ],
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
Loading
Loading