-
Notifications
You must be signed in to change notification settings - Fork 6
/
ab-abc-empty.nf
executable file
·33 lines (25 loc) · 1.02 KB
/
ab-abc-empty.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
/* Insert process B beween A and C or leave it out, depending on an on/off switch.
A -> B -> C
A -> C
This is roughly the same as http://nextflow-io.github.io/patterns/index.html#_problem_19
My prefered solution is ab-abc-when.nf
*/
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_doB; ch_skipB }
(ch_AC, ch_AB) = ( params.includeB ? [Channel.empty(), ch_doB] : [ch_skipB, Channel.empty()] )
process processB {
input: set val(sampleid), file(thefile) from ch_AB
output: set val(sampleid), file('out.txt') into ch_BC
script: "(cat $thefile; md5sum $thefile) > out.txt"
}
ch_BC.mix(ch_AC).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"
}