Skip to content

Commit 0ceda2c

Browse files
authored
Merge pull request #1080 from nf-core/fix_bam_filtering
Fix bam filtering
2 parents 0e0fe5e + 7765f16 commit 0ceda2c

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

conf/modules.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ process {
578578
}
579579

580580
withName: ".*BAM_SPLIT_BY_REGION:SAMTOOLS_INDEX" {
581+
// The BAM_SPLIT_BY_REGION SWF only works with bais, so `params.fasta_largeref` should not be passed to it.
581582
tag = { "${meta.reference}:${meta.genomic_region}|${meta.sample_id}_${meta.library_id}" }
582-
ext.args = { params.fasta_largeref ? "-c" : "" }
583583
ext.prefix = { "${meta.sample_id}_${meta.library_id}_${meta.reference}_${meta.genomic_region}_dedupped" }
584584
publishDir = [
585585
enabled: false

subworkflows/local/bamfiltering.nf

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ include { CAT_FASTQ as CAT_FASTQ_MAPPED } from '../../modules/
1616
workflow FILTER_BAM {
1717

1818
take:
19-
bam // [ [meta], [bam], [bai] ]
19+
bam // [ [meta], [bam], [bai/csi] ]
2020

2121
main:
2222
ch_versions = Channel.empty()
@@ -37,9 +37,10 @@ workflow FILTER_BAM {
3737
ch_versions = ch_versions.mix( FILTER_BAM_FRAGMENT_LENGTH.out.versions.first() )
3838

3939
SAMTOOLS_LENGTH_FILTER_INDEX ( FILTER_BAM_FRAGMENT_LENGTH.out.bam )
40+
ch_length_filtered_index = params.fasta_largeref ? SAMTOOLS_LENGTH_FILTER_INDEX.out.csi : SAMTOOLS_LENGTH_FILTER_INDEX.out.bai
4041
ch_versions = ch_versions.mix( SAMTOOLS_LENGTH_FILTER_INDEX.out.versions.first() )
4142

42-
ch_bam_for_qualityfilter = FILTER_BAM_FRAGMENT_LENGTH.out.bam.join( SAMTOOLS_LENGTH_FILTER_INDEX.out.bai )
43+
ch_bam_for_qualityfilter = FILTER_BAM_FRAGMENT_LENGTH.out.bam.join( ch_length_filtered_index )
4344

4445
} else {
4546
ch_bam_for_qualityfilter = bam
@@ -52,9 +53,10 @@ workflow FILTER_BAM {
5253
ch_versions = ch_versions.mix( SAMTOOLS_VIEW_BAM_FILTERING.out.versions.first() )
5354

5455
SAMTOOLS_FILTER_INDEX ( SAMTOOLS_VIEW_BAM_FILTERING.out.bam )
56+
ch_filtered_bam_index = params.fasta_largeref ? SAMTOOLS_FILTER_INDEX.out.csi : SAMTOOLS_FILTER_INDEX.out.bai
5557
ch_versions = ch_versions.mix( SAMTOOLS_FILTER_INDEX.out.versions.first() )
5658

57-
ch_bam_for_genomics = SAMTOOLS_VIEW_BAM_FILTERING.out.bam.join( SAMTOOLS_FILTER_INDEX.out.bai )
59+
ch_bam_for_genomics = SAMTOOLS_VIEW_BAM_FILTERING.out.bam.join( ch_filtered_bam_index )
5860

5961
// Only run if we actually remove mapped reads
6062
if ( params.bamfiltering_mappingquality != 0 || params.bamfiltering_minreadlength != 0 ) {

workflows/eager.nf

+1-4
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,7 @@ workflow EAGER {
207207
//
208208
// MODULE: flagstats of user supplied input BAMs
209209
//
210-
ch_bam_bai_input = ch_samplesheet_bams
211-
.join(SAMTOOLS_INDEX_BAM_INPUT.out.bai)
212-
213-
SAMTOOLS_FLAGSTATS_BAM_INPUT ( ch_bam_bai_input )
210+
SAMTOOLS_FLAGSTATS_BAM_INPUT ( ch_bams_from_input )
214211
ch_versions = ch_versions.mix( SAMTOOLS_FLAGSTATS_BAM_INPUT.out.versions )
215212
ch_flagstat_input_bam = SAMTOOLS_FLAGSTATS_BAM_INPUT.out.flagstat // For endorspy
216213

0 commit comments

Comments
 (0)