44
55include { SEQKIT_SPLIT2 } from ' ../../modules/nf-core/seqkit/split2/main'
66include { FASTQ_ALIGN_BWAALN } from ' ../../subworkflows/nf-core/fastq_align_bwaaln/main'
7- include { FASTQ_ALIGN_MAPAD } from ' ../../subworkflows /nf-core/fastq_align_mapad /main'
7+ include { MAPAD_MAP } from ' ../../modules /nf-core/mapad/map /main'
88include { BWA_MEM } from ' ../../modules/nf-core/bwa/mem/main'
99include { BOWTIE2_ALIGN } from ' ../../modules/nf-core/bowtie2/align/main'
1010include { SAMTOOLS_MERGE as SAMTOOLS_MERGE_LANES } from ' ../../modules/nf-core/samtools/merge/main'
1111include { SAMTOOLS_SORT as SAMTOOLS_SORT_MERGED_LANES } from ' ../../modules/nf-core/samtools/sort/main'
12+ include { SAMTOOLS_SORT as SAMTOOLS_SORT_MAPAD } from ' ../../modules/nf-core/samtools/sort/main'
1213include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_MEM } from ' ../../modules/nf-core/samtools/index/main'
1314include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_BT2 } from ' ../../modules/nf-core/samtools/index/main'
15+ include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_MAPAD } from ' ../../modules/nf-core/samtools/index/main'
1416include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_MERGED_LANES } from ' ../../modules/nf-core/samtools/index/main'
1517include { SAMTOOLS_FLAGSTAT as SAMTOOLS_FLAGSTAT_MAPPED } from ' ../../modules/nf-core/samtools/flagstat/main'
1618
1719workflow MAP {
1820 take :
1921 reads // [ [meta], [read1, reads2] ] or [ [meta], [read1] ]
20- index // [ [meta], [ index ], [ fasta ] ]
22+ index // [ [meta], [ index ] ]
2123
2224 main :
2325 ch_versions = Channel . empty()
@@ -41,7 +43,7 @@ workflow MAP {
4143 .groupTuple()
4244
4345 ch_input_for_mapping = sharded_reads
44- .combine(index. map{ meta , index , fasta -> [ meta, index ] } )
46+ .combine(index)
4547 .multiMap {
4648 meta, reads, meta2, index ->
4749 new_meta = meta. clone()
@@ -52,7 +54,7 @@ workflow MAP {
5254
5355 } else {
5456 ch_input_for_mapping = reads
55- .combine(index. map{ meta , index , fasta -> [ meta, index ] } )
57+ .combine(index)
5658 .multiMap {
5759 meta, reads, meta2, index ->
5860 new_meta = meta. clone()
@@ -63,7 +65,7 @@ workflow MAP {
6365 }
6466
6567 if ( params. mapping_tool == ' bwaaln' ) {
66- ch_index_for_mapping = index. map{ meta, index, fasta -> [ meta, index ] }
68+ ch_index_for_mapping = index
6769 ch_reads_for_mapping = reads
6870
6971 FASTQ_ALIGN_BWAALN ( ch_reads_for_mapping, ch_index_for_mapping )
@@ -80,7 +82,7 @@ workflow MAP {
8082
8183 } else if ( params. mapping_tool == ' bwamem' ) {
8284 ch_input_for_mapping = reads
83- .combine( index. map{ meta , index , fasta -> [ meta, index ] } )
85+ .combine( index )
8486 .multiMap {
8587 meta, reads, meta2, index ->
8688 new_meta = meta + [ reference : meta2. id ]
@@ -98,7 +100,7 @@ workflow MAP {
98100
99101 } else if ( params. mapping_tool == ' bowtie2' ) {
100102 ch_input_for_mapping = reads
101- .combine( index. map{ meta , index , fasta -> [ meta, index ] } )
103+ .combine( index )
102104 .multiMap {
103105 meta, reads, meta2, index ->
104106 new_meta = meta + [ reference : meta2. id ]
@@ -118,18 +120,16 @@ workflow MAP {
118120 ch_input_for_mapping = reads
119121 .combine( index )
120122 .multiMap {
121- meta, reads, meta2, index, fasta ->
123+ meta, reads, meta2, index ->
122124 new_meta = meta + [ reference : meta2. id ]
123125 reads : [ new_meta, reads ]
124126 index : [ meta2, index ]
125- fasta : [ meta2, fasta ]
126127 strandedness : meta. strandedness== " double"
127128 }
128129
129- FASTQ_ALIGN_MAPAD (
130+ MAPAD_MAP (
130131 ch_input_for_mapping. reads,
131132 ch_input_for_mapping. index,
132- ch_input_for_mapping. fasta,
133133 params. mapping_mapad_p,
134134 ch_input_for_mapping. strandedness,
135135 params. mapping_mapad_f,
@@ -138,16 +138,15 @@ workflow MAP {
138138 params. mapping_mapad_s,
139139 params. mapping_mapad_i
140140 )
141- ch_versions = ch_versions. mix ( FASTQ_ALIGN_MAPAD . out. versions. first() )
142- ch_mapped_lane_bam = FASTQ_ALIGN_MAPAD . out. bam
143- .map{
144- // create meta consistent with rest of workflow
145- meta, bam ->
146- new_meta = meta + [ reference : meta. id_index ]
147- [ new_meta, bam ]
148- }
141+ ch_versions = ch_versions. mix ( MAPAD_MAP . out. versions. first() )
142+
143+ SAMTOOLS_SORT_MAPAD ( MAPAD_MAP . out. bam )
144+ ch_mapped_lane_bam = SAMTOOLS_SORT_MAPAD . out. bam
145+ ch_versions = ch_versions. mix( SAMTOOLS_SORT_MAPAD . out. versions. first() )
149146
150- ch_mapped_lane_bai = params. fasta_largeref ? FASTQ_ALIGN_MAPAD . out. csi : FASTQ_ALIGN_MAPAD . out. bai
147+ SAMTOOLS_INDEX_MAPAD ( ch_mapped_lane_bam )
148+ ch_versions = ch_versions. mix( SAMTOOLS_INDEX_MAPAD . out. versions. first() )
149+ ch_mapped_lane_bai = params. fasta_largeref ? SAMTOOLS_INDEX_MAPAD . out. csi : SAMTOOLS_INDEX_MAPAD . out. bai
151150 }
152151
153152 // Only run merge lanes if we have more than one BAM to merge!
0 commit comments