-
Notifications
You must be signed in to change notification settings - Fork 6
/
ab-abc-when.nf
35 lines (26 loc) · 1016 Bytes
/
ab-abc-when.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* Insert process B beween A and C or leave it out, depending on an on/off switch.
A -> B -> C
A -> C
This is a variant on http://nextflow-io.github.io/patterns/index.html#_problem_19
using `until` instead of Channel.empty().
This is my prefered solution.
*/
params.includeB = true
process processA { // Create a bunch of files, each with its ow sample ID.
output: file('*.txt') into ch_dummy
script: 'for i in {1..7}; do echo "sample_$i" > f$i.txt; done'
}
ch_dummy.flatMap().map { f -> [f.text.trim(), f] }.view().into { ch_AB; ch_AC }
process processB {
when: params.includeB
input: set val(sampleid), file(thefile) from ch_AB
output: set val(sampleid), file('out.txt') into ch_BC
script: "(cat $thefile; md5 $thefile) > out.txt"
}
ch_AC.until{params.includeB}.mix(ch_BC).set{ ch_C }
process processC {
publishDir "results"
input: set val(sampleid), file(a) from ch_C.view()
output: file('*.out')
script: "(echo 'C process'; cat $a) > ${sampleid}.out"
}