Skip to content
Snippets Groups Projects
Commit 3861d9ad authored by David Trudgian's avatar David Trudgian
Browse files

Fix routing for PE/SE channels

parent 0a261ff0
No related merge requests found
......@@ -21,6 +21,9 @@ index_name = "genome"
// which is covered by the GNU General Public License v3
// https://github.com/nextflow-io/rnatoy/blob/master/main.nf
read_pe = Channel.empty()
read_se = Channel.empty()
if (params.pairs == 'pe') {
Channel
.fromPath( fastqs )
......@@ -31,20 +34,21 @@ Channel
}
.groupTuple(sort: true)
.map { id, files -> tuple(id, files[0],files[1])}
.set { read_pe }
}
.into { read_pe }
}
if (params.pairs == 'se') {
Channel
.fromPath( fastqs )
.ifEmpty { error "Cannot find any files matching: ${fastqs}" }
.map { path ->
def prefix = readPrefix(path, '*{1,2}.{fastq,fq}{,.gz}')
def prefix = readPrefix(path, '*.{fastq,fq}{,.gz}')
tuple(prefix, path)
}
.groupTuple(sort: true)
.map { id, files -> tuple(id, files[0])}
.set { read_se }
}
.into { read_se }
}
/*
* Helper function, given a file Path
......@@ -133,9 +137,8 @@ process alignpe {
input:
set pair_id, file(fq1), file(fq2) from trimpe
output:
set pair_id, file("${pair_id}.bam") into aligned
set pair_id, file("${pair_id}.bam") into aligned2
file("${pair_id}.flagstat.txt") into alignstats
set pair_id, file("${pair_id}.bam") into aligned_pe
file("${pair_id}.flagstat.txt") into alignstats_pe
"""
module load hisat2/2.0.1-beta-intel samtools/intel/1.3 fastqc/0.11.2 picard/1.127
hisat2 -p 4 --no-unal --dta -x ${index_path}/${index_name} -1 ${fq1} -2 ${fq2} -S out.sam 2> ${pair_id}.hisatout.txt
......@@ -155,9 +158,8 @@ process alignse {
input:
set pair_id, file(fq1) from trimse
output:
set pair_id, file("${pair_id}.bam") into aligned
set pair_id, file("${pair_id}.bam") into aligned2
file("${pair_id}.flagstat.txt") into alignstats
set pair_id, file("${pair_id}.bam") into aligned_se
file("${pair_id}.flagstat.txt") into alignstats_se
"""
module load hisat2/2.0.1-beta-intel samtools/intel/1.3 fastqc/0.11.2 picard/1.127
hisat2 -p 4 --no-unal --dta -x ${index_path}/${index_name} -U ${fq1} -S out.sam 2> ${pair_id}.hisatout.txt
......@@ -170,6 +172,20 @@ process alignse {
"""
}
// From here on we are the same for PE and SE, so merge channels and carry on
Channel
.empty()
.mix(aligned_se, aligned_pe)
.tap { aligned2 }
.set { aligned }
Channel
.empty()
.mix(alignstats_se, alignstats_pe)
.set { alignstats }
//
// Summarize all flagstat output
//
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment