From 30128fc03a631571b16d935e88eacd02b98231d5 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:30:05 +0200 Subject: [PATCH 01/23] ignore error from bwa-mem2 and if output is missing, run bwa --- conf/modules/align_bwa_bwamem2.config | 1 + subworkflows/local/alignment/align_bwa_bwamem2.nf | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/conf/modules/align_bwa_bwamem2.config b/conf/modules/align_bwa_bwamem2.config index e91360fc..d82fb5d6 100644 --- a/conf/modules/align_bwa_bwamem2.config +++ b/conf/modules/align_bwa_bwamem2.config @@ -23,6 +23,7 @@ process { ext.args = { "-M -K 100000000 -R ${meta.read_group}" } ext.prefix = { "${meta.id}_sorted" } ext.when = { params.aligner.equals("bwamem2") } + label = 'error_ignore' } withName: '.*ALIGN:ALIGN_BWA_BWAMEM2:BWA_MEM' { diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 10537898..6d5847a7 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -24,14 +24,14 @@ workflow ALIGN_BWA_BWAMEM2 { ch_versions = Channel.empty() // Map, sort, and index - if (params.aligner.equals("bwa")) { - BWA_MEM ( ch_reads_input, ch_bwa_index, true ) - ch_align = BWA_MEM.out.bam - ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) - } else { + if (params.aligner.equals("bwamem2")) { BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) ch_align = BWAMEM2_MEM.out.bam ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) + else if (params.aligner.equals("bwa") || !BWAMEM2_MEM.out.bam.exists()) { + BWA_MEM ( ch_reads_input, ch_bwa_index, true ) + ch_align = BWA_MEM.out.bam + ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) } SAMTOOLS_INDEX_ALIGN ( ch_align ) From 5accab2506ea70661860f038631c0dedfc9f781f Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:30:41 +0200 Subject: [PATCH 02/23] change logical gate --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 6d5847a7..650c5fc6 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -28,7 +28,7 @@ workflow ALIGN_BWA_BWAMEM2 { BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) ch_align = BWAMEM2_MEM.out.bam ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) - else if (params.aligner.equals("bwa") || !BWAMEM2_MEM.out.bam.exists()) { + else if (params.aligner.equals("bwa") || (params.aligner.equals("bwamem2") && !BWAMEM2_MEM.out.bam.exists())) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_align = BWA_MEM.out.bam ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) From afeefc1a5c221ff174571d4878db92aea3e97e56 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:36:47 +0200 Subject: [PATCH 03/23] typo --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 1 + 1 file changed, 1 insertion(+) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 650c5fc6..e26d4bde 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -28,6 +28,7 @@ workflow ALIGN_BWA_BWAMEM2 { BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) ch_align = BWAMEM2_MEM.out.bam ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) + } else if (params.aligner.equals("bwa") || (params.aligner.equals("bwamem2") && !BWAMEM2_MEM.out.bam.exists())) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_align = BWA_MEM.out.bam From 2d2efd2382de6698786686b3572897b1a3e322fd Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:49:25 +0200 Subject: [PATCH 04/23] change syntax --- conf/modules/align_bwa_bwamem2.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/modules/align_bwa_bwamem2.config b/conf/modules/align_bwa_bwamem2.config index d82fb5d6..cf5e79f8 100644 --- a/conf/modules/align_bwa_bwamem2.config +++ b/conf/modules/align_bwa_bwamem2.config @@ -23,7 +23,7 @@ process { ext.args = { "-M -K 100000000 -R ${meta.read_group}" } ext.prefix = { "${meta.id}_sorted" } ext.when = { params.aligner.equals("bwamem2") } - label = 'error_ignore' + errorStrategy = 'ignore' } withName: '.*ALIGN:ALIGN_BWA_BWAMEM2:BWA_MEM' { From 52b7caa8411216e3f04e9633a2871851cea504c0 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:53:37 +0200 Subject: [PATCH 05/23] change logical gate --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index e26d4bde..6ee8dfc9 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -29,7 +29,7 @@ workflow ALIGN_BWA_BWAMEM2 { ch_align = BWAMEM2_MEM.out.bam ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) } - else if (params.aligner.equals("bwa") || (params.aligner.equals("bwamem2") && !BWAMEM2_MEM.out.bam.exists())) { + if (params.aligner.equals("bwa") || (params.aligner.equals("bwamem2") && !BWAMEM2_MEM.out.bam.exists())) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_align = BWA_MEM.out.bam ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) From 2c0bdb028434045076490960bc51c7ee53ec9dd1 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Tue, 30 Apr 2024 14:24:45 +0200 Subject: [PATCH 06/23] change logical gate --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 6ee8dfc9..acf684e0 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -22,14 +22,15 @@ workflow ALIGN_BWA_BWAMEM2 { main: ch_versions = Channel.empty() - + count = 0 // Map, sort, and index if (params.aligner.equals("bwamem2")) { BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) ch_align = BWAMEM2_MEM.out.bam ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) + count = BWAMEM2_MEM.out.bam.ifEmpty(1) } - if (params.aligner.equals("bwa") || (params.aligner.equals("bwamem2") && !BWAMEM2_MEM.out.bam.exists())) { + if (params.aligner.equals("bwa") || count == 1) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_align = BWA_MEM.out.bam ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) From ecd62865665c2026f85587607f9661726017ba02 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Thu, 2 May 2024 11:38:53 +0200 Subject: [PATCH 07/23] try a retry with more memory --- conf/modules/align_bwa_bwamem2.config | 2 +- subworkflows/local/alignment/align_bwa_bwamem2.nf | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/conf/modules/align_bwa_bwamem2.config b/conf/modules/align_bwa_bwamem2.config index cf5e79f8..ff53af13 100644 --- a/conf/modules/align_bwa_bwamem2.config +++ b/conf/modules/align_bwa_bwamem2.config @@ -23,7 +23,7 @@ process { ext.args = { "-M -K 100000000 -R ${meta.read_group}" } ext.prefix = { "${meta.id}_sorted" } ext.when = { params.aligner.equals("bwamem2") } - errorStrategy = 'ignore' + errorStrategy = { task.exitStatus in (1 + (130..145) + 104) ? 'retry' : 'finish' } } withName: '.*ALIGN:ALIGN_BWA_BWAMEM2:BWA_MEM' { diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index acf684e0..10537898 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -22,18 +22,16 @@ workflow ALIGN_BWA_BWAMEM2 { main: ch_versions = Channel.empty() - count = 0 + // Map, sort, and index - if (params.aligner.equals("bwamem2")) { - BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) - ch_align = BWAMEM2_MEM.out.bam - ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) - count = BWAMEM2_MEM.out.bam.ifEmpty(1) - } - if (params.aligner.equals("bwa") || count == 1) { + if (params.aligner.equals("bwa")) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_align = BWA_MEM.out.bam ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) + } else { + BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) + ch_align = BWAMEM2_MEM.out.bam + ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) } SAMTOOLS_INDEX_ALIGN ( ch_align ) From eee78184da59049ce512d1308aebf28a0ba8d2d3 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Thu, 2 May 2024 13:50:05 +0200 Subject: [PATCH 08/23] try a retry with more memory --- conf/modules/align_bwa_bwamem2.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/modules/align_bwa_bwamem2.config b/conf/modules/align_bwa_bwamem2.config index ff53af13..04739e9a 100644 --- a/conf/modules/align_bwa_bwamem2.config +++ b/conf/modules/align_bwa_bwamem2.config @@ -23,7 +23,7 @@ process { ext.args = { "-M -K 100000000 -R ${meta.read_group}" } ext.prefix = { "${meta.id}_sorted" } ext.when = { params.aligner.equals("bwamem2") } - errorStrategy = { task.exitStatus in (1 + (130..145) + 104) ? 'retry' : 'finish' } + errorStrategy = { task.exitStatus in (1, (130..145), 104) ? 'retry' : 'finish' } } withName: '.*ALIGN:ALIGN_BWA_BWAMEM2:BWA_MEM' { From 85fc2ea7fbcac4848899852ff81b3b9661b6dc28 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Thu, 2 May 2024 14:22:21 +0200 Subject: [PATCH 09/23] try a retry with more memory --- conf/modules/align_bwa_bwamem2.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/modules/align_bwa_bwamem2.config b/conf/modules/align_bwa_bwamem2.config index 04739e9a..30d961e7 100644 --- a/conf/modules/align_bwa_bwamem2.config +++ b/conf/modules/align_bwa_bwamem2.config @@ -23,7 +23,7 @@ process { ext.args = { "-M -K 100000000 -R ${meta.read_group}" } ext.prefix = { "${meta.id}_sorted" } ext.when = { params.aligner.equals("bwamem2") } - errorStrategy = { task.exitStatus in (1, (130..145), 104) ? 'retry' : 'finish' } + errorStrategy = { task.exitStatus in [1,104,130,131,132,133,134,135,135,136,137,138,139,140,141,142,143,144,145] ? 'retry' : 'finish' } } withName: '.*ALIGN:ALIGN_BWA_BWAMEM2:BWA_MEM' { From f6d99dcb548e8e4679842c4d0c862c57bbc2f4be Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Thu, 2 May 2024 16:32:11 +0200 Subject: [PATCH 10/23] change logic --- conf/modules/align_bwa_bwamem2.config | 2 +- .../local/alignment/align_bwa_bwamem2.nf | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/conf/modules/align_bwa_bwamem2.config b/conf/modules/align_bwa_bwamem2.config index 30d961e7..cf5e79f8 100644 --- a/conf/modules/align_bwa_bwamem2.config +++ b/conf/modules/align_bwa_bwamem2.config @@ -23,7 +23,7 @@ process { ext.args = { "-M -K 100000000 -R ${meta.read_group}" } ext.prefix = { "${meta.id}_sorted" } ext.when = { params.aligner.equals("bwamem2") } - errorStrategy = { task.exitStatus in [1,104,130,131,132,133,134,135,135,136,137,138,139,140,141,142,143,144,145] ? 'retry' : 'finish' } + errorStrategy = 'ignore' } withName: '.*ALIGN:ALIGN_BWA_BWAMEM2:BWA_MEM' { diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 10537898..3499551e 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -24,14 +24,19 @@ workflow ALIGN_BWA_BWAMEM2 { ch_versions = Channel.empty() // Map, sort, and index - if (params.aligner.equals("bwa")) { - BWA_MEM ( ch_reads_input, ch_bwa_index, true ) - ch_align = BWA_MEM.out.bam - ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) - } else { + if (params.aligner.equals("bwamem2")) { BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) - ch_align = BWAMEM2_MEM.out.bam ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) + + + if (BWA_MEM.out.bam.ifEmpty()) { + BWA_MEM ( ch_reads_input, ch_bwa_index, true ) + ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) + ch_align = BWA_MEM.out.bam + + else { + ch_align = BWAMEM2_MEM.out.bam + } } SAMTOOLS_INDEX_ALIGN ( ch_align ) From 17ed5d4900efc57fa0b0c4ad9d183c15056f1130 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Thu, 2 May 2024 16:44:17 +0200 Subject: [PATCH 11/23] change logic --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 3499551e..62fb99df 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -29,11 +29,11 @@ workflow ALIGN_BWA_BWAMEM2 { ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) - if (BWA_MEM.out.bam.ifEmpty()) { + if (BWAMEM2_MEM.out.bam.ifEmpty()) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) ch_align = BWA_MEM.out.bam - + } else { ch_align = BWAMEM2_MEM.out.bam } From 8adc86f77838dae0ed6580e85f3a87e9791f88aa Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Thu, 2 May 2024 17:00:33 +0200 Subject: [PATCH 12/23] change logic --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 62fb99df..8c7a189a 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -29,7 +29,7 @@ workflow ALIGN_BWA_BWAMEM2 { ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) - if (BWAMEM2_MEM.out.bam.ifEmpty()) { + if (BWAMEM2_MEM.out.bam.ifEmpty(False)) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) ch_align = BWA_MEM.out.bam From ad00cbc9474d2479c3c28f85ceb8a18bf5214847 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Fri, 3 May 2024 11:01:05 +0200 Subject: [PATCH 13/23] change if statement --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 8c7a189a..79ca1640 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -22,22 +22,26 @@ workflow ALIGN_BWA_BWAMEM2 { main: ch_versions = Channel.empty() + ch_align = Channel.empty() // Map, sort, and index if (params.aligner.equals("bwamem2")) { BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) + ch_align = BWAMEM2_MEM.out.bam - - if (BWAMEM2_MEM.out.bam.ifEmpty(False)) { + if (ch_align == Channel.empty) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) ch_align = BWA_MEM.out.bam } - else { - ch_align = BWAMEM2_MEM.out.bam - } } + else if (params.aligner.equals("bwamem2"){ + BWA_MEM ( ch_reads_input, ch_bwa_index, true ) + ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) + ch_align = BWA_MEM.out.bam + } + SAMTOOLS_INDEX_ALIGN ( ch_align ) From 7ba937f31556c80f6908270bcd3136829b78277a Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Fri, 3 May 2024 11:09:58 +0200 Subject: [PATCH 14/23] change if statement --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 79ca1640..78c4974c 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -30,13 +30,13 @@ workflow ALIGN_BWA_BWAMEM2 { ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) ch_align = BWAMEM2_MEM.out.bam - if (ch_align == Channel.empty) { + if (ch_align == Channel.empty()) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) ch_align = BWA_MEM.out.bam } } - else if (params.aligner.equals("bwamem2"){ + else if (params.aligner.equals("bwa")){ BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) ch_align = BWA_MEM.out.bam From b2c0eb1855f99060d252e4cc53fc0796e50a5288 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Fri, 3 May 2024 11:37:14 +0200 Subject: [PATCH 15/23] change if statement --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 78c4974c..acc1546e 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -22,26 +22,21 @@ workflow ALIGN_BWA_BWAMEM2 { main: ch_versions = Channel.empty() - ch_align = Channel.empty() // Map, sort, and index if (params.aligner.equals("bwamem2")) { BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) - ch_align = BWAMEM2_MEM.out.bam - if (ch_align == Channel.empty()) { + if (!file.exists(BWAMEM2_MEM.out.bam)) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) ch_align = BWA_MEM.out.bam } - } - else if (params.aligner.equals("bwa")){ - BWA_MEM ( ch_reads_input, ch_bwa_index, true ) - ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) - ch_align = BWA_MEM.out.bam + else { + ch_align = BWAMEM2_MEM.out.bam } - + } SAMTOOLS_INDEX_ALIGN ( ch_align ) From 98e202a017058d041a501186068d412ea385f088 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Fri, 3 May 2024 12:10:25 +0200 Subject: [PATCH 16/23] change if statement --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index acc1546e..0871b063 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -28,7 +28,7 @@ workflow ALIGN_BWA_BWAMEM2 { BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) - if (!file.exists(BWAMEM2_MEM.out.bam)) { + if (!(BWAMEM2_MEM.out.bam).exists()) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) ch_align = BWA_MEM.out.bam From e811efd82a5523ff38fe53d4b487bb5292504af1 Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Fri, 3 May 2024 12:53:41 +0200 Subject: [PATCH 17/23] change if statement --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 0871b063..730a95e4 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -28,7 +28,7 @@ workflow ALIGN_BWA_BWAMEM2 { BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) - if (!(BWAMEM2_MEM.out.bam).exists()) { + if ((BWAMEM2_MEM.out.bam).isEmpty()) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) ch_align = BWA_MEM.out.bam From 68f9bc892d7cc46c6f4fa1546891f2ba6b34631a Mon Sep 17 00:00:00 2001 From: Annick Renevey <47788523+rannick@users.noreply.github.com> Date: Fri, 3 May 2024 14:31:29 +0200 Subject: [PATCH 18/23] add tmp channel --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 730a95e4..f7e5cb19 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -22,13 +22,13 @@ workflow ALIGN_BWA_BWAMEM2 { main: ch_versions = Channel.empty() - + ch_align_tmp = Channel.empty() // Map, sort, and index if (params.aligner.equals("bwamem2")) { BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) - - if ((BWAMEM2_MEM.out.bam).isEmpty()) { + ch_align_tmp = BWAMEM2_MEM.out.bam + if (!ch_align_tmp) { BWA_MEM ( ch_reads_input, ch_bwa_index, true ) ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) ch_align = BWA_MEM.out.bam From e6b62b7a9504f4db4bd1af7bc38a7d852790a122 Mon Sep 17 00:00:00 2001 From: Ramprasad Neethiraj <20065894+ramprasadn@users.noreply.github.com> Date: Mon, 6 May 2024 16:09:41 +0200 Subject: [PATCH 19/23] update align --- .../local/alignment/align_bwa_bwamem2.nf | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index f7e5cb19..16fff1bc 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -3,6 +3,7 @@ // include { BWA_MEM } from '../../../modules/nf-core/bwa/mem/main' +include { BWA_MEM as BWAMEM_FALLBACK } from '../../../modules/nf-core/bwa/mem/main' include { BWAMEM2_MEM } from '../../../modules/nf-core/bwamem2/mem/main' include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_ALIGN } from '../../../modules/nf-core/samtools/index/main' include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_MARKDUP } from '../../../modules/nf-core/samtools/index/main' @@ -22,20 +23,33 @@ workflow ALIGN_BWA_BWAMEM2 { main: ch_versions = Channel.empty() - ch_align_tmp = Channel.empty() + // Map, sort, and index - if (params.aligner.equals("bwamem2")) { + if (params.aligner.equals("bwa")) { + BWA_MEM ( ch_reads_input, ch_bwa_index, true ) + ch_align = BWA_MEM.out.bam + ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) + } else { BWAMEM2_MEM ( ch_reads_input, ch_bwamem2_index, true ) + ch_align = BWAMEM2_MEM.out.bam ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) - ch_align_tmp = BWAMEM2_MEM.out.bam - if (!ch_align_tmp) { - BWA_MEM ( ch_reads_input, ch_bwa_index, true ) - ch_versions = ch_versions.mix(BWA_MEM.out.versions.first()) - ch_align = BWA_MEM.out.bam - } - else { - ch_align = BWAMEM2_MEM.out.bam + + if (params.align_fallback.equals(true)) { + ch_reads_input + .join(BWAMEM2_MEM.out.bam, remainder: true) + .branch { it -> + ERROR: it[2].equals(null) + return [it[0], it[1]] // return reads + SUCCESS: !it[2].equals(null) + return [it[0], it[2]] // return bam + } + .set { ch_fallback } + + BWAMEM_FALLBACK ( ch_fallback.ERROR, ch_bwa_index, true ) + ch_align = ch_fallback.SUCCESS.mix(BWAMEM_FALLBACK.out.bam) + ch_versions = ch_versions.mix(BWAMEM_FALLBACK.out.versions.first()) } + } SAMTOOLS_INDEX_ALIGN ( ch_align ) From cad7ce23becf08d7033f5621927f5bc4046a6eac Mon Sep 17 00:00:00 2001 From: Ramprasad Neethiraj <20065894+ramprasadn@users.noreply.github.com> Date: Tue, 7 May 2024 10:40:32 +0200 Subject: [PATCH 20/23] update param --- nextflow.config | 1 + nextflow_schema.json | 5 +++++ subworkflows/local/alignment/align_bwa_bwamem2.nf | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nextflow.config b/nextflow.config index 5065d2d9..fb385fa6 100644 --- a/nextflow.config +++ b/nextflow.config @@ -22,6 +22,7 @@ params { // Main options analysis_type = 'wgs' + bwa_as_fallback = false bait_padding = 100 run_rtgvcfeval = false save_mapped_as_cram = false diff --git a/nextflow_schema.json b/nextflow_schema.json index 6e2fbc81..1d1049bd 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -459,6 +459,11 @@ "fa_icon": "fas fa-user-cog", "description": "Options used to steer the direction of the pipeline.", "properties": { + "bwa_as_fallback": { + "type": "boolean", + "description": "Specifies whether or not to use bwa as a fallback aligner in case bwamem2 throws an error.", + "fa_icon": "fas fa-toggle-on" + }, "analysis_type": { "type": "string", "default": "wgs", diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 80bf3822..40e93196 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -34,7 +34,7 @@ workflow ALIGN_BWA_BWAMEM2 { ch_align = BWAMEM2_MEM.out.bam ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) - if (params.align_fallback.equals(true)) { + if (params.bwa_as_fallback.equals(true)) { ch_reads_input .join(BWAMEM2_MEM.out.bam, remainder: true) .branch { it -> From 7efe3b876169a97e9c03eb214efe703cdbd01e8a Mon Sep 17 00:00:00 2001 From: Ramprasad Neethiraj <20065894+ramprasadn@users.noreply.github.com> Date: Tue, 7 May 2024 15:04:19 +0200 Subject: [PATCH 21/23] arrange param --- nextflow_schema.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nextflow_schema.json b/nextflow_schema.json index 1d1049bd..d70f69ed 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -459,11 +459,6 @@ "fa_icon": "fas fa-user-cog", "description": "Options used to steer the direction of the pipeline.", "properties": { - "bwa_as_fallback": { - "type": "boolean", - "description": "Specifies whether or not to use bwa as a fallback aligner in case bwamem2 throws an error.", - "fa_icon": "fas fa-toggle-on" - }, "analysis_type": { "type": "string", "default": "wgs", @@ -471,6 +466,11 @@ "fa_icon": "fas fa-align-center", "enum": ["wgs", "wes", "mito"] }, + "bwa_as_fallback": { + "type": "boolean", + "description": "Specifies whether or not to use bwa as a fallback aligner in case bwamem2 throws an error.", + "fa_icon": "fas fa-toggle-on" + }, "platform": { "type": "string", "default": "illumina", From 91fc58e3a39ab8ff37eb9154f5ee48f155bef579 Mon Sep 17 00:00:00 2001 From: Ramprasad Neethiraj <20065894+ramprasadn@users.noreply.github.com> Date: Fri, 17 May 2024 13:14:52 +0200 Subject: [PATCH 22/23] update changelog --- CHANGELOG.md | 2 ++ nextflow_schema.json | 1 + 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e74f569..44e6f516 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Added` +- A new parameter `bwa_as_fallback` to switch aligner to bwa in case bwamem2 fails [#551](https://github.com/nf-core/raredisease/pull/551) + ### `Changed` - Refactored config files [#538](https://github.com/nf-core/raredisease/pull/538) diff --git a/nextflow_schema.json b/nextflow_schema.json index 0c26050c..674c19c8 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -468,6 +468,7 @@ "bwa_as_fallback": { "type": "boolean", "description": "Specifies whether or not to use bwa as a fallback aligner in case bwamem2 throws an error.", + "help_text": "errorStrategy needs to be set to ignore for the bwamem2 process for the fallback to work. Turned off by default.", "fa_icon": "fas fa-toggle-on" }, "platform": { From 2d5c9181d1cd8900b26bab78b37cd28151a85ee9 Mon Sep 17 00:00:00 2001 From: Ramprasad Neethiraj <20065894+ramprasadn@users.noreply.github.com> Date: Fri, 17 May 2024 22:19:00 +0200 Subject: [PATCH 23/23] Update align_bwa_bwamem2.nf --- subworkflows/local/alignment/align_bwa_bwamem2.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/local/alignment/align_bwa_bwamem2.nf b/subworkflows/local/alignment/align_bwa_bwamem2.nf index 40e93196..b846cad3 100644 --- a/subworkflows/local/alignment/align_bwa_bwamem2.nf +++ b/subworkflows/local/alignment/align_bwa_bwamem2.nf @@ -34,7 +34,7 @@ workflow ALIGN_BWA_BWAMEM2 { ch_align = BWAMEM2_MEM.out.bam ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) - if (params.bwa_as_fallback.equals(true)) { + if (params.bwa_as_fallback) { ch_reads_input .join(BWAMEM2_MEM.out.bam, remainder: true) .branch { it ->