Skip to content

Commit

Permalink
Merge pull request #551 from nf-core/bwafallback
Browse files Browse the repository at this point in the history
Bwafallback
  • Loading branch information
ramprasadn authored May 20, 2024
2 parents ae1d495 + 2d5c918 commit 5e7b87e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions conf/modules/align_bwa_bwamem2.config
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ process {
ext.args = { "-M -K 100000000 -R ${meta.read_group}" }
ext.args2 = { "-T ./samtools_sort_tmp" }
ext.prefix = { "${meta.id}_sorted" }
ext.when = { params.aligner.equals("bwamem2") }
}

withName: '.*ALIGN:ALIGN_BWA_BWAMEM2:BWAMEM_FALLBACK' {
ext.args = { "-M -K 100000000 -R ${meta.read_group}" }
ext.args2 = { "-T ./samtools_sort_tmp" }
ext.prefix = { "${meta.id}_sorted" }
}

withName: '.*ALIGN:ALIGN_BWA_BWAMEM2:BWA_MEM' {
ext.args = { "-M -K 100000000 -R ${meta.read_group}" }
ext.args2 = { "-T ./samtools_sort_tmp" }
ext.prefix = { "${meta.id}_sorted" }
ext.when = { params.aligner.equals("bwa") }
}

withName: '.*ALIGN:ALIGN_BWA_BWAMEM2:SAMTOOLS_STATS' {
Expand Down
1 change: 1 addition & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,12 @@
"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.",
"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": {
"type": "string",
"default": "illumina",
Expand Down
20 changes: 19 additions & 1 deletion subworkflows/local/alignment/align_bwa_bwamem2.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -30,8 +31,25 @@ workflow ALIGN_BWA_BWAMEM2 {
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_align = BWAMEM2_MEM.out.bam
ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first())

if (params.bwa_as_fallback) {
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 )
Expand Down

0 comments on commit 5e7b87e

Please sign in to comment.