@@ -24,6 +24,7 @@ include { addNewMetaFromAttributes } from '../subwork
2424include { REFERENCE_INDEXING } from ' ../subworkflows/local/reference_indexing'
2525include { PREPROCESSING } from ' ../subworkflows/local/preprocessing'
2626include { MAP } from ' ../subworkflows/local/map'
27+ include { MERGE_LANES_INPUTBAM } from ' ../subworkflows/local/merge_lanes_inputbam'
2728include { FILTER_BAM } from ' ../subworkflows/local/bamfiltering.nf'
2829include { DEDUPLICATE } from ' ../subworkflows/local/deduplicate'
2930include { MANIPULATE_DAMAGE } from ' ../subworkflows/local/manipulate_damage'
@@ -55,7 +56,6 @@ include { FALCO } from '../modules
5556include { MTNUCRATIO } from ' ../modules/nf-core/mtnucratio/main'
5657include { HOST_REMOVAL } from ' ../modules/local/host_removal'
5758include { ENDORSPY } from ' ../modules/nf-core/endorspy/main'
58- include { SAMTOOLS_FLAGSTAT as SAMTOOLS_FLAGSTATS_BAM_INPUT } from ' ../modules/nf-core/samtools/flagstat/main'
5959include { BEDTOOLS_COVERAGE as BEDTOOLS_COVERAGE_DEPTH } from ' ../modules/nf-core/bedtools/coverage/main'
6060include { BEDTOOLS_COVERAGE as BEDTOOLS_COVERAGE_BREADTH } from ' ../modules/nf-core/bedtools/coverage/main'
6161include { SAMTOOLS_VIEW_GENOME } from ' ../modules/local/samtools_view_genome.nf'
@@ -198,31 +198,31 @@ workflow EAGER {
198198 ch_bams_from_input = ch_samplesheet_bams. join(SAMTOOLS_INDEX_BAM_INPUT . out. csi)
199199 }
200200 else {
201- ch_bams_from_input = ch_samplesheet_bams. join( SAMTOOLS_INDEX_BAM_INPUT . out . bai)
201+ ch_bams_from_input = ch_samplesheet_bams
202202 }
203203
204- //
205- // MODULE: flagstats of user supplied input BAMs
206- //
207- SAMTOOLS_FLAGSTATS_BAM_INPUT (ch_bams_from_input)
208- ch_versions = ch_versions . mix( SAMTOOLS_FLAGSTATS_BAM_INPUT . out. versions )
209- ch_flagstat_input_bam = SAMTOOLS_FLAGSTATS_BAM_INPUT . out. flagstat
210- }
211- else {
212- ch_bams_from_input = Channel . empty()
213- ch_flagstat_input_bam = Channel . empty()
204+ // SUBWORKFLOW: Merging lanes for ch_bams_from_input
205+
206+ MERGE_LANES_INPUTBAM (ch_bams_from_input)
207+ ch_bams_from_input_lanemerged = MERGE_LANES_INPUTBAM . out . bam
208+ .join( MERGE_LANES_INPUTBAM . out. bai )
209+ ch_flagstat_bams_from_input_lanemerged = MERGE_LANES_INPUTBAM . out. flagstat
210+
211+ } else {
212+ ch_bams_from_input_lanemerged = Channel . empty()
213+ ch_flagstat_bams_from_input_lanemerged = Channel . empty()
214214 }
215215
216+
216217 //
217218 // SUBWORKFLOW: bam filtering (length, mapped/unmapped, quality etc.)
218219 //
219220
220221 if (params. run_bamfiltering || params. run_metagenomics) {
221222
222223 ch_mapped_for_bamfilter = MAP . out. bam
223- .join(MAP . out. bai)
224- .mix(ch_bams_from_input)
225-
224+ .join(MAP . out. bai)
225+ .mix(ch_bams_from_input_lanemerged)
226226 FILTER_BAM (ch_mapped_for_bamfilter)
227227 ch_bamfiltered_for_deduplication = FILTER_BAM . out. genomics
228228 ch_bamfiltered_for_metagenomics = FILTER_BAM . out. metagenomics
@@ -232,8 +232,8 @@ workflow EAGER {
232232 else {
233233 // TODO: more intuitive name for this?, since here we don't have filtered reads :P
234234 ch_bamfiltered_for_deduplication = MAP . out. bam
235- .join(MAP . out. bai)
236- .mix(ch_bams_from_input )
235+ .join(MAP . out. bai)
236+ .mix(ch_bams_from_input_lanemerged )
237237 }
238238
239239 ch_reads_for_deduplication = ch_bamfiltered_for_deduplication
@@ -392,7 +392,8 @@ workflow EAGER {
392392 // MODULE: ENDORSPY (raw, filtered, deduplicated)
393393 //
394394
395- ch_flagstat_for_endorspy_raw = MAP . out. flagstat. mix(ch_flagstat_input_bam)
395+ ch_flagstat_for_endorspy_raw = MAP . out. flagstat
396+ .mix( ch_flagstat_bams_from_input_lanemerged )
396397
397398 if (params. run_bamfiltering & ! params. skip_deduplication) {
398399 ch_for_endorspy = ch_flagstat_for_endorspy_raw
0 commit comments