Skip to content
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
72 changes: 40 additions & 32 deletions subworkflows/nf-core/fasta_index_methylseq/main.nf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include { UNTAR } from '../../../modules/nf-core/untar/main'
include { UNTAR as UNTAR_BISMARK } from '../../../modules/nf-core/untar/main'
include { UNTAR as UNTAR_BWAMETH } from '../../../modules/nf-core/untar/main'
include { GUNZIP } from '../../../modules/nf-core/gunzip/main'
include { BISMARK_GENOMEPREPARATION as BISMARK_GENOMEPREPARATION_BOWTIE } from '../../../modules/nf-core/bismark/genomepreparation/main'
include { BISMARK_GENOMEPREPARATION as BISMARK_GENOMEPREPARATION_HISAT } from '../../../modules/nf-core/bismark/genomepreparation/main'
Expand All @@ -14,18 +15,18 @@ workflow FASTA_INDEX_METHYLSEQ {
bismark_index // channel: [ val(meta), [ bismark index ] ]
bwameth_index // channel: [ val(meta), [ bwameth index ] ]
bwamem_index // channel: [ val(meta), [ bwamem index ] ]
aligner // string: bismark, bismark_hisat or bwameth
aligner // string: bismark, bismark_hisat, bwameth or bwamem
collecthsmetrics // boolean: whether to run picard collecthsmetrics
use_mem2 // boolean: generate mem2 index if no index provided, and bwameth is selected

main:

ch_fasta = Channel.empty()
ch_fasta_index = Channel.empty()
ch_bismark_index = Channel.empty()
ch_bwameth_index = Channel.empty()
ch_bwamem_index = Channel.empty()
ch_versions = Channel.empty()
ch_fasta = channel.empty()
ch_fasta_index = channel.empty()
ch_bismark_index = channel.empty()
ch_bwameth_index = channel.empty()
ch_bwamem_index = channel.empty()
ch_versions = channel.empty()

// Check if fasta file is gzipped and decompress if needed
fasta
Expand Down Expand Up @@ -56,17 +57,17 @@ workflow FASTA_INDEX_METHYLSEQ {
}
.set { ch_bismark_index_branched }

UNTAR (
UNTAR_BISMARK (
ch_bismark_index_branched.gzipped
)

ch_bismark_index = ch_bismark_index_branched.unzipped.mix(UNTAR.out.untar)
ch_versions = ch_versions.mix(UNTAR.out.versions)
ch_bismark_index = ch_bismark_index_branched.unzipped.mix(UNTAR_BISMARK.out.untar)
ch_versions = ch_versions.mix(UNTAR_BISMARK.out.versions)
} else {

if( aligner == "bismark_hisat") {
BISMARK_GENOMEPREPARATION_HISAT (
ch_fasta
ch_fasta
)
ch_bismark_index = BISMARK_GENOMEPREPARATION_HISAT.out.index
ch_versions = ch_versions.mix(BISMARK_GENOMEPREPARATION_HISAT.out.versions)
Expand Down Expand Up @@ -94,39 +95,45 @@ workflow FASTA_INDEX_METHYLSEQ {
}
.set { ch_bwameth_index_branched }

UNTAR (
UNTAR_BWAMETH (
ch_bwameth_index_branched.gzipped
)

ch_bwameth_index = ch_bwameth_index_branched.unzipped.mix(UNTAR.out.untar)
ch_versions = ch_versions.mix(UNTAR.out.versions)
ch_bwameth_index = ch_bwameth_index_branched.unzipped.mix(UNTAR_BWAMETH.out.untar)
ch_versions = ch_versions.mix(UNTAR_BWAMETH.out.versions)
} else {
if (use_mem2) {
BWAMETH_INDEX (
ch_fasta,
true
)
} else {
BWAMETH_INDEX (
ch_fasta,
false
)
}
BWAMETH_INDEX (
ch_fasta,
use_mem2
)
ch_bwameth_index = BWAMETH_INDEX.out.index
ch_versions = ch_versions.mix(BWAMETH_INDEX.out.versions)
}
}


else if ( aligner == 'bwamem' ){
log.info "BWA index not provided. Generating BWA index from FASTA file."
/*
* Generate BWA index from FASTA file
*/
if (bwamem_index) {
ch_bwamem_index = bwamem_index
// Handle channel-based bwamem index
bwamem_index
.branch {
gzipped: it[1].toString().endsWith('.gz')
unzipped: true
}
.set { ch_bwamem_index_branched }

UNTAR_BISMARK (
ch_bwamem_index_branched.gzipped
)

ch_bwamem_index = ch_bwamem_index_branched.unzipped.mix(UNTAR_BISMARK.out.untar)
ch_versions = ch_versions.mix(UNTAR_BISMARK.out.versions)
} else {
BWA_INDEX(
log.info "BWA index not provided. Generating BWA index from FASTA file."
BWA_INDEX (
ch_fasta
)
ch_bwamem_index = BWA_INDEX.out.index
Expand All @@ -138,11 +145,12 @@ workflow FASTA_INDEX_METHYLSEQ {
* Generate fasta index if not supplied for bwameth workflow or picard collecthsmetrics tool
*/
if (aligner == 'bwameth' || aligner == 'bwamem' || collecthsmetrics) {
// already exising fasta index
// already existing fasta index
if (fasta_index) {
ch_fasta_index = fasta_index
} else {
SAMTOOLS_FAIDX(
log.info "Fasta index not provided. Generating fasta index from FASTA file."
SAMTOOLS_FAIDX (
ch_fasta,
[[:], []],
false
Expand All @@ -157,6 +165,6 @@ workflow FASTA_INDEX_METHYLSEQ {
fasta_index = ch_fasta_index // channel: [ val(meta), [ fasta index ] ]
bismark_index = ch_bismark_index // channel: [ val(meta), [ bismark index ] ]
bwameth_index = ch_bwameth_index // channel: [ val(meta), [ bwameth index ] ]
bwamem_index = ch_bwamem_index // channel: [ val(meta), [ bwamem index ] ]
bwamem_index = ch_bwamem_index // channel: [ val(meta), [ bwamem index ] ]
versions = ch_versions // channel: [ versions.yml ]
}
2 changes: 1 addition & 1 deletion subworkflows/nf-core/fasta_index_methylseq/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ input:
- aligner:
type: string
description: |
Aligner name (bismark, bismark_hisat, or bwameth)
Aligner name (bismark, bismark_hisat, bwameth, or bwamem)
- collecthsmetrics:
type: boolean
description: |
Expand Down
78 changes: 39 additions & 39 deletions subworkflows/nf-core/fasta_index_methylseq/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@
],
[
"versions.yml:md5,1a7e59286a0e918ba2400750ddefd444",
"versions.yml:md5,80527e72159961c33cd9a6d4847e75e3",
"versions.yml:md5,51df3ff0a3067a7a676cdc4e4d237a69",
"versions.yml:md5,8afe74b43d9155c93e27ae1b36a7ae97"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.5"
"nf-test": "0.9.3",
"nextflow": "25.10.0"
},
"timestamp": "2025-09-30T10:54:41.408759009"
"timestamp": "2025-12-03T12:20:26.495603"
},
"Params: bwameth | generate fasta index | download bwameth index | collecthsmetrics": {
"content": [
Expand Down Expand Up @@ -142,15 +142,15 @@
],
[
"versions.yml:md5,1a7e59286a0e918ba2400750ddefd444",
"versions.yml:md5,80527e72159961c33cd9a6d4847e75e3",
"versions.yml:md5,51df3ff0a3067a7a676cdc4e4d237a69",
"versions.yml:md5,8afe74b43d9155c93e27ae1b36a7ae97"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.5"
"nf-test": "0.9.3",
"nextflow": "25.10.0"
},
"timestamp": "2025-09-30T10:55:10.001932564"
"timestamp": "2025-12-03T12:21:13.279634"
},
"Params: bwameth | generate fasta index | generate bwameth mem2 index": {
"content": [
Expand Down Expand Up @@ -253,15 +253,15 @@

],
[
"versions.yml:md5,80527e72159961c33cd9a6d4847e75e3",
"versions.yml:md5,8afe74b43d9155c93e27ae1b36a7ae97"
"versions.yml:md5,8afe74b43d9155c93e27ae1b36a7ae97",
"versions.yml:md5,d3ed85f31ec769229e17780530e235ee"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.5"
"nf-test": "0.9.3",
"nextflow": "25.10.0"
},
"timestamp": "2025-09-30T10:53:57.304989914"
"timestamp": "2025-12-03T12:19:16.006311"
},
"Params: bwameth | generate fasta index | download bwameth mem2 index | collecthsmetrics": {
"content": [
Expand Down Expand Up @@ -304,15 +304,15 @@
],
[
"versions.yml:md5,1a7e59286a0e918ba2400750ddefd444",
"versions.yml:md5,80527e72159961c33cd9a6d4847e75e3",
"versions.yml:md5,51df3ff0a3067a7a676cdc4e4d237a69",
"versions.yml:md5,8afe74b43d9155c93e27ae1b36a7ae97"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.5"
"nf-test": "0.9.3",
"nextflow": "25.10.0"
},
"timestamp": "2025-09-30T10:55:16.817726661"
"timestamp": "2025-12-03T12:21:24.368005"
},
"Params: bwameth | generate fasta index | download bwameth mem2 index": {
"content": [
Expand Down Expand Up @@ -355,15 +355,15 @@
],
[
"versions.yml:md5,1a7e59286a0e918ba2400750ddefd444",
"versions.yml:md5,80527e72159961c33cd9a6d4847e75e3",
"versions.yml:md5,51df3ff0a3067a7a676cdc4e4d237a69",
"versions.yml:md5,8afe74b43d9155c93e27ae1b36a7ae97"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.5"
"nf-test": "0.9.3",
"nextflow": "25.10.0"
},
"timestamp": "2025-09-30T10:54:48.244071885"
"timestamp": "2025-12-03T12:20:37.640088"
},
"Params: bwameth | generate fasta index | generate bwameth index": {
"content": [
Expand Down Expand Up @@ -470,15 +470,15 @@

],
[
"versions.yml:md5,80527e72159961c33cd9a6d4847e75e3",
"versions.yml:md5,8afe74b43d9155c93e27ae1b36a7ae97"
"versions.yml:md5,8afe74b43d9155c93e27ae1b36a7ae97",
"versions.yml:md5,d3ed85f31ec769229e17780530e235ee"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.5"
"nf-test": "0.9.3",
"nextflow": "25.10.0"
},
"timestamp": "2025-09-30T10:54:21.879254265"
"timestamp": "2025-12-03T12:19:53.905574"
},
"Params: bismark_hisat | download bismark index (hisat2)": {
"content": [
Expand Down Expand Up @@ -534,15 +534,15 @@

],
[
"versions.yml:md5,80527e72159961c33cd9a6d4847e75e3",
"versions.yml:md5,8afe74b43d9155c93e27ae1b36a7ae97"
"versions.yml:md5,8afe74b43d9155c93e27ae1b36a7ae97",
"versions.yml:md5,d3ed85f31ec769229e17780530e235ee"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.5"
"nf-test": "0.9.3",
"nextflow": "25.10.0"
},
"timestamp": "2025-09-30T10:54:15.523551748"
"timestamp": "2025-12-03T12:19:42.978899"
},
"Params: bwameth | download fasta index | download bwameth index": {
"content": [
Expand Down Expand Up @@ -585,15 +585,15 @@

],
[
"versions.yml:md5,80527e72159961c33cd9a6d4847e75e3",
"versions.yml:md5,51df3ff0a3067a7a676cdc4e4d237a69",
"versions.yml:md5,8afe74b43d9155c93e27ae1b36a7ae97"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.5"
"nf-test": "0.9.3",
"nextflow": "25.10.0"
},
"timestamp": "2025-09-30T10:54:28.152242843"
"timestamp": "2025-12-03T12:20:04.798139"
},
"Params: bwameth | download fasta index | download bwameth mem2 index": {
"content": [
Expand Down Expand Up @@ -635,15 +635,15 @@

],
[
"versions.yml:md5,80527e72159961c33cd9a6d4847e75e3",
"versions.yml:md5,51df3ff0a3067a7a676cdc4e4d237a69",
"versions.yml:md5,8afe74b43d9155c93e27ae1b36a7ae97"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.5"
"nf-test": "0.9.3",
"nextflow": "25.10.0"
},
"timestamp": "2025-09-30T10:54:34.434835743"
"timestamp": "2025-12-03T12:20:15.282566"
},
"Params: bwamem | generate fasta index | generate bwamem index": {
"content": [
Expand Down
Loading
Loading