Skip to content

Commit

Permalink
trying to fix the concatenation of fastq files
Browse files Browse the repository at this point in the history
  • Loading branch information
jemten committed Oct 30, 2023
1 parent ac85767 commit 09628ac
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions subworkflows/local/alignment.nf
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ workflow ALIGNMENT {
main:
ch_versions = Channel.empty()

CAT_FASTQ(reads)
ch_fastq = branchFastqToSingleAndMulti(reads)

FASTP(CAT_FASTQ.out.reads,[],false,false)
CAT_FASTQ(ch_fastq.multiple_fq)
.reads.mix(ch_fastq.single_fq)
.set { ch_cat_fastq }

FASTP(ch_cat_fastq, [], false, false)

STAR_ALIGN(FASTP.out.reads, star_index, gtf, false, 'illumina', false)

Expand Down Expand Up @@ -86,3 +90,32 @@ workflow ALIGNMENT {
salmon_info = SALMON_QUANT.out.json_info
versions = ch_versions
}


// Custom functions

/**
* Branch the read channel into differnt channels,
* depending on whether the sample has multiple fastq files or not.
* The resulting channels gets the original sample id in meta.
*
* @param ch_reads Channel containing meta and fastq reads
* @return Channel containing meta with original id and branched on number of fastq files
*/
def branchFastqToSingleAndMulti(ch_reads) {

return ch_reads
.map {
meta, fastq ->
original_id = meta.id.split('_T')[0..-2].join('_')
[ meta + [id: original_id], fastq ]
}
.groupTuple()
.branch {
meta, fastq ->
single_fq: fastq.size() == 1
return [ meta, fastq.flatten() ]
multiple_fq: fastq.size() > 1
return [ meta, fastq.flatten() ]
}
}

0 comments on commit 09628ac

Please sign in to comment.