@@ -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'
@@ -56,7 +57,6 @@ include { FALCO } from '../modules
5657include { MTNUCRATIO } from ' ../modules/nf-core/mtnucratio/main'
5758include { HOST_REMOVAL } from ' ../modules/local/host_removal'
5859include { ENDORSPY } from ' ../modules/nf-core/endorspy/main'
59- include { SAMTOOLS_FLAGSTAT as SAMTOOLS_FLAGSTATS_BAM_INPUT } from ' ../modules/nf-core/samtools/flagstat/main'
6060include { BEDTOOLS_COVERAGE as BEDTOOLS_COVERAGE_DEPTH } from ' ../modules/nf-core/bedtools/coverage/main'
6161include { BEDTOOLS_COVERAGE as BEDTOOLS_COVERAGE_BREADTH } from ' ../modules/nf-core/bedtools/coverage/main'
6262include { SAMTOOLS_VIEW_GENOME } from ' ../modules/local/samtools_view_genome.nf'
@@ -199,31 +199,31 @@ workflow EAGER {
199199 ch_bams_from_input = ch_samplesheet_bams. join(SAMTOOLS_INDEX_BAM_INPUT . out. csi)
200200 }
201201 else {
202- ch_bams_from_input = ch_samplesheet_bams. join( SAMTOOLS_INDEX_BAM_INPUT . out . bai)
202+ ch_bams_from_input = ch_samplesheet_bams
203203 }
204204
205- //
206- // MODULE: flagstats of user supplied input BAMs
207- //
208- SAMTOOLS_FLAGSTATS_BAM_INPUT (ch_bams_from_input)
209- ch_versions = ch_versions . mix( SAMTOOLS_FLAGSTATS_BAM_INPUT . out. versions )
210- ch_flagstat_input_bam = SAMTOOLS_FLAGSTATS_BAM_INPUT . out. flagstat
211- }
212- else {
213- ch_bams_from_input = Channel . empty()
214- ch_flagstat_input_bam = Channel . empty()
205+ // SUBWORKFLOW: Merging lanes for ch_bams_from_input
206+
207+ MERGE_LANES_INPUTBAM (ch_bams_from_input)
208+ ch_bams_from_input_lanemerged = MERGE_LANES_INPUTBAM . out . bam
209+ .join( MERGE_LANES_INPUTBAM . out. bai )
210+ ch_flagstat_bams_from_input_lanemerged = MERGE_LANES_INPUTBAM . out. flagstat
211+
212+ } else {
213+ ch_bams_from_input_lanemerged = Channel . empty()
214+ ch_flagstat_bams_from_input_lanemerged = Channel . empty()
215215 }
216216
217+
217218 //
218219 // SUBWORKFLOW: bam filtering (length, mapped/unmapped, quality etc.)
219220 //
220221
221222 if (params. run_bamfiltering || params. run_metagenomics) {
222223
223224 ch_mapped_for_bamfilter = MAP . out. bam
224- .join(MAP . out. bai)
225- .mix(ch_bams_from_input)
226-
225+ .join(MAP . out. bai)
226+ .mix(ch_bams_from_input_lanemerged)
227227 FILTER_BAM (ch_mapped_for_bamfilter)
228228 ch_bamfiltered_for_deduplication = FILTER_BAM . out. genomics
229229 ch_bamfiltered_for_metagenomics = FILTER_BAM . out. metagenomics
@@ -232,8 +232,8 @@ workflow EAGER {
232232 }
233233 else {
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
@@ -391,7 +391,8 @@ workflow EAGER {
391391 // MODULE: ENDORSPY (raw, filtered, deduplicated)
392392 //
393393
394- ch_flagstat_for_endorspy_raw = MAP . out. flagstat. mix(ch_flagstat_input_bam)
394+ ch_flagstat_for_endorspy_raw = MAP . out. flagstat
395+ .mix( ch_flagstat_bams_from_input_lanemerged )
395396
396397 if (params. run_bamfiltering & ! params. skip_deduplication) {
397398 ch_for_endorspy = ch_flagstat_for_endorspy_raw
0 commit comments