From 096f97d628dd22a16bc67b2a6ab44cdae55b3e51 Mon Sep 17 00:00:00 2001 From: MaxUlysse Date: Sun, 20 Feb 2022 13:22:50 +0100 Subject: [PATCH] code polishing --- subworkflows/nf-core/gatk4_mapping/main.nf | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/subworkflows/nf-core/gatk4_mapping/main.nf b/subworkflows/nf-core/gatk4_mapping/main.nf index 731c693a8a..e1c2432c84 100644 --- a/subworkflows/nf-core/gatk4_mapping/main.nf +++ b/subworkflows/nf-core/gatk4_mapping/main.nf @@ -17,19 +17,12 @@ workflow GATK4_MAPPING { fasta_fai // channel: [mandatory] fasta_fai main: - - reads.view() - ch_versions = Channel.empty() // Only one of the following will be run - BWAMEM1_MEM(reads, bwa, true) // If aligner is bwa-mem BWAMEM2_MEM(reads, bwa, true) // If aligner is bwa-mem2 - ch_versions = ch_versions.mix(BWAMEM1_MEM.out.versions.first()) - ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) - // Grouping the bams from the same samples not to stall the workflow // Removing unneeded fields in the new_meta map bam_mapped = BWAMEM1_MEM.out.bam.mix(BWAMEM2_MEM.out.bam).map{ meta, bam -> @@ -39,17 +32,15 @@ workflow GATK4_MAPPING { new_meta.id = meta.sample // groupKey is to makes sure that the correct group can advance as soon as it is complete - // and not stall the workflow until all pieces are mapped + // and not stall the workflow until all reads from all channels are mapped def groupKey = groupKey(meta, meta.numLanes * meta.size) //Returns the values we need tuple(groupKey, new_meta, bam) }.groupTuple(by:[0,1]).map{ groupKey, new_meta, bam -> [new_meta, bam] } - // gatk4 markduplicates can handle multiple bams as input - // So no merging/indexing at this step - // Except if and only if skipping markduplicates - // Or saving mapped bams + // gatk4 markduplicates can handle multiple bams as input, so no need to merge/index here + // Except if and only if skipping markduplicates or saving mapped bams // Figuring out if there is one or more bam(s) from the same sample // Is done for all, but not blocking @@ -62,6 +53,12 @@ workflow GATK4_MAPPING { MERGE_MAPPING(bam_to_merge.multiple, []) INDEX_MAPPING(bam_to_merge.single.mix(MERGE_MAPPING.out.bam)) + // Gather versions of all tools used + ch_versions = ch_versions.mix(BWAMEM1_MEM.out.versions.first()) + ch_versions = ch_versions.mix(BWAMEM2_MEM.out.versions.first()) + ch_versions = ch_versions.mix(INDEX_MAPPING.out.versions.first()) + ch_versions = ch_versions.mix(MERGE_MAPPING.out.versions.first()) + emit: bam = bam_mapped bam_indexed = INDEX_MAPPING.out.bam_bai