-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcollectFile-numLines.nf
More file actions
executable file
·39 lines (28 loc) · 927 Bytes
/
collectFile-numLines.nf
File metadata and controls
executable file
·39 lines (28 loc) · 927 Bytes
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
34
35
36
37
#!/usr/bin/env nextflow
// Collect the full path names of all files in a channel and store these in a metafile,
// supply the metafile as input to a process, and pass the number of lines in the file.
// This is useful for merging processes where the number of input files may run
// to hundreds or thousands.
process star {
output: file('*.txt') into ch_input
script: 'for i in {00..09}; do echo "some F $i content" > f$i.txt; done'
}
ch_input
// _v_ pretty sure there is a better idiom than this (less byty).
.collectFile { file -> file.collect{ it.toString() }.join('\n') + '\n' }
.map { [it.countLines(), it] }
.view()
.set{ ch_merge }
process merge {
publishDir "$baseDir/results", mode: 'copy'
input:
set val(numlines), file(metafile) from ch_merge
output:
file('*.txt')
script:
"""
cat $metafile | while read f; do
cat \$f
done > ttt.txt
"""
}