Skip to content

remove implicit params use in sub-wf #8625

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

Merged
merged 5 commits into from
Jun 17, 2025
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
89 changes: 53 additions & 36 deletions subworkflows/nf-core/fasta_index_bismark_bwameth/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ include { SAMTOOLS_FAIDX } from '../../../modules/nf-core/samtools/fa
workflow FASTA_INDEX_BISMARK_BWAMETH {

take:
fasta // channel: [ val(meta), [ fasta ] ]
fasta_index // channel: [ val(meta), [ fasta index ] ]
bismark_index // channel: [ val(meta), [ bismark index ] ]
bwameth_index // channel: [ val(meta), [ bwameth index ] ]
fasta // channel: [ val(meta), [ fasta ] ]
fasta_index // channel: [ val(meta), [ fasta index ] ]
bismark_index // channel: [ val(meta), [ bismark index ] ]
bwameth_index // channel: [ val(meta), [ bwameth index ] ]
aligner // string: bismark, bismark_hisat or bwameth
collecthsmetrics // boolean: whether to run picard collecthsmetrics

main:

Expand All @@ -20,31 +22,41 @@ workflow FASTA_INDEX_BISMARK_BWAMETH {
ch_bwameth_index = Channel.empty()
ch_versions = Channel.empty()

if (fasta.toString().endsWith('.gz')) {
GUNZIP (
[ [:], file(fasta, checkIfExists: true) ]
)
ch_fasta = GUNZIP.out.gunzip
ch_versions = ch_versions.mix(GUNZIP.out.versions)
} else {
ch_fasta = Channel.value([[:], file(fasta, checkIfExists: true)])
}
// Check if fasta file is gzipped and decompress if needed
fasta
.branch {
gzipped: it[1].toString().endsWith('.gz')
unzipped: true
}
.set { ch_fasta_branched }

GUNZIP (
ch_fasta_branched.gzipped.ifEmpty([])
)

ch_fasta = ch_fasta_branched.unzipped.mix(GUNZIP.out.gunzip)
ch_versions = ch_versions.mix(GUNZIP.out.versions)

// Aligner: bismark or bismark_hisat
if( params.aligner =~ /bismark/ ){
if( aligner =~ /bismark/ ){
/*
* Generate bismark index if not supplied
*/
if (bismark_index) {
if (bismark_index.toString().endsWith('.gz')) {
UNTAR (
[ [:], file(bismark_index, checkIfExists: true) ]
)
ch_bismark_index = UNTAR.out.untar
ch_versions = ch_versions.mix(UNTAR.out.versions)
} else {
ch_bismark_index = Channel.value([[:], file(bismark_index, checkIfExists: true)])
}
// Handle channel-based bismark index
bismark_index
.branch {
gzipped: it[1].toString().endsWith('.gz')
unzipped: true
}
.set { ch_bismark_index_branched }

UNTAR (
ch_bismark_index_branched.gzipped.ifEmpty([])
)

ch_bismark_index = ch_bismark_index_branched.unzipped.mix(UNTAR.out.untar)
ch_versions = ch_versions.mix(UNTAR.out.versions)
} else {
BISMARK_GENOMEPREPARATION (
ch_fasta
Expand All @@ -55,20 +67,25 @@ workflow FASTA_INDEX_BISMARK_BWAMETH {
}

// Aligner: bwameth
else if ( params.aligner == 'bwameth' ){
else if ( aligner == 'bwameth' ){
/*
* Generate bwameth index if not supplied
*/
if (bwameth_index) {
if (bwameth_index.toString().endsWith('.gz')) {
UNTAR (
[ [:], file(bwameth_index, checkIfExists: true) ]
)
ch_bwameth_index = UNTAR.out.untar
ch_versions = ch_versions.mix(UNTAR.out.versions)
} else {
ch_bwameth_index = Channel.value([[:], file(bwameth_index, checkIfExists: true)])
}
// Handle channel-based bwameth index
bwameth_index
.branch {
gzipped: it[1].toString().endsWith('.gz')
unzipped: true
}
.set { ch_bwameth_index_branched }

UNTAR (
ch_bwameth_index_branched.gzipped.ifEmpty([])
)

ch_bwameth_index = ch_bwameth_index_branched.unzipped.mix(UNTAR.out.untar)
ch_versions = ch_versions.mix(UNTAR.out.versions)
} else {
BWAMETH_INDEX (
ch_fasta
Expand All @@ -81,15 +98,15 @@ workflow FASTA_INDEX_BISMARK_BWAMETH {
/*
* Generate fasta index if not supplied for bwameth workflow or picard collecthsmetrics tool
*/
if (params.aligner == 'bwameth' | params.run_picard_collecthsmetrics) {
if (aligner == 'bwameth' | collecthsmetrics) {
// already exising fasta index
if (fasta_index) {
ch_fasta_index = Channel.value(file(fasta_index, checkIfExists: true))
ch_fasta_index = fasta_index
} else {
SAMTOOLS_FAIDX(
ch_fasta,
[[:], []],
false // No sizes generation
false
)
ch_fasta_index = SAMTOOLS_FAIDX.out.fai
ch_versions = ch_versions.mix(SAMTOOLS_FAIDX.out.versions)
Expand Down
10 changes: 10 additions & 0 deletions subworkflows/nf-core/fasta_index_bismark_bwameth/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ input:
description: |
Bwameth genome index files
Structure: [ val(meta), path(bwameth_index) ]
- aligner:
type: string
description: |
Aligner name (bismark, bismark_hisat, or bwameth)
- collecthsmetrics:
type: boolean
description: |
Whether to run picard collecthsmetrics tool
output:
- fasta:
type: file
Expand Down Expand Up @@ -68,5 +76,7 @@ output:
pattern: "versions.yml"
authors:
- "@sateeshperi"
- "dcarrillox"
maintainers:
- "@sateeshperi"
- "@dcarrillox"
104 changes: 32 additions & 72 deletions subworkflows/nf-core/fasta_index_bismark_bwameth/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ nextflow_workflow {
test("Params: bismark | download bismark index (bowtie2)") {

when {
params {
aligner = "bismark"
}
workflow {
"""
input[0] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true)
input[0] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[1] = [] // fasta_index
input[2] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Bowtie2_Index.tar.gz', checkIfExists: true)
input[2] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Bowtie2_Index.tar.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[3] = [] // bwameth_index
input[4] = "bismark" // aligner
input[5] = false // collecthsmetrics
"""
}
}
Expand All @@ -47,15 +46,14 @@ nextflow_workflow {
test("Params: bismark | generate bismark index (bowtie2)") {

when {
params {
aligner = "bismark"
}
workflow {
"""
input[0] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true)
input[0] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[1] = [] // fasta_index
input[2] = [] // bismark_index
input[3] = [] // bwameth_index
input[4] = "bismark" // aligner
input[5] = false // collecthsmetrics
"""
}
}
Expand All @@ -77,15 +75,14 @@ nextflow_workflow {
test("Params: bismark_hisat | download bismark index (hisat2)") {

when {
params {
aligner = "bismark_hisat"
}
workflow {
"""
input[0] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true)
input[0] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[1] = [] // fasta_index
input[2] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Hisat2_Index.tar.gz', checkIfExists: true)
input[2] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Hisat2_Index.tar.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[3] = [] // bwameth_index
input[4] = "bismark_hisat" // aligner
input[5] = false // collecthsmetrics
"""
}
}
Expand All @@ -107,46 +104,14 @@ nextflow_workflow {
test("Params: bismark_hisat | generate bismark index (hisat2)") {

when {
params {
aligner = "bismark_hisat"
}
workflow {
"""
input[0] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true)
input[0] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[1] = [] // fasta_index
input[2] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Hisat2_Index.tar.gz', checkIfExists: true)
input[3] = [] // bwameth_index
"""
}
}

then {
assertAll(
{ assert workflow.success},
{ assert snapshot(
workflow.out.fasta,
workflow.out.fasta_index,
workflow.out.bismark_index,
workflow.out.bwameth_index,
workflow.out.versions
).match() }
)
}
}

test("Params: bismark | download bismark index (bowtie2) | run_picard_collecthsmetrics") {

when {
params {
aligner = "bismark"
run_picard_collecthsmetrics = true
}
workflow {
"""
input[0] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true)
input[1] = [] // fasta_index
input[2] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Bowtie2_Index.tar.gz', checkIfExists: true)
input[2] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Hisat2_Index.tar.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[3] = [] // bwameth_index
input[4] = "bismark_hisat" // aligner
input[5] = false // collecthsmetrics
"""
}
}
Expand All @@ -168,15 +133,14 @@ nextflow_workflow {
test("Params: bwameth | download fasta index | download bwameth index") {

when {
params {
aligner = "bwameth"
}
workflow {
"""
input[0] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true)
input[1] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.fai', checkIfExists: true)
input[0] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[1] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.fai', checkIfExists: true).map { it -> [ [:], it ] }
input[2] = [] // bismark index
input[3] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Bwameth_Index.tar.gz', checkIfExists: true)
input[3] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Bwameth_Index.tar.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[4] = "bwameth" // aligner
input[5] = false // collecthsmetrics
"""
}
}
Expand All @@ -198,15 +162,14 @@ nextflow_workflow {
test("Params: bwameth | generate fasta index | download bwameth index") {

when {
params {
aligner = "bwameth"
}
workflow {
"""
input[0] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true)
input[0] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[1] = [] //fasta index
input[2] = [] // bismark index
input[3] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Bwameth_Index.tar.gz', checkIfExists: true)
input[3] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Bwameth_Index.tar.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[4] = "bwameth" // aligner
input[5] = false // collecthsmetrics
"""
}
}
Expand All @@ -228,15 +191,14 @@ nextflow_workflow {
test("Params: bwameth | generate fasta index | generate bwameth index") {

when {
params {
aligner = "bwameth"
}
workflow {
"""
input[0] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true)
input[0] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[1] = [] // fasta_index
input[2] = [] // bismark index
input[3] = [] // bwameth index
input[4] = "bwameth" // aligner
input[5] = false // collecthsmetrics
"""
}
}
Expand All @@ -255,19 +217,17 @@ nextflow_workflow {
}
}

test("Params: bwameth | generate fasta index | download bwameth index | run_picard_collecthsmetrics") {
test("Params: bwameth | generate fasta index | download bwameth index | collecthsmetrics") {

when {
params {
aligner = "bwameth"
run_picard_collecthsmetrics = true
}
workflow {
"""
input[0] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true)
input[0] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/genome.fa.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[1] = [] //fasta index
input[2] = [] // bismark index
input[3] = file('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Bwameth_Index.tar.gz', checkIfExists: true)
input[3] = Channel.fromPath('https://github.com/nf-core/test-datasets/raw/methylseq/reference/Bwameth_Index.tar.gz', checkIfExists: true).map { it -> [ [:], it ] }
input[4] = "bwameth" // aligner
input[5] = true // collecthsmetrics
"""
}
}
Expand Down
Loading
Loading