-
Notifications
You must be signed in to change notification settings - Fork 196
/
Copy pathhello-modules.nf
88 lines (66 loc) · 1.65 KB
/
hello-modules.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env nextflow
/*
* Pipeline parameters
*/
params.greeting = 'greetings.csv'
params.batch = 'test-batch'
workflow {
// create a channel for inputs from a CSV file
greeting_ch = Channel
.fromPath(params.greeting)
.splitCsv()
.map { line -> line[0] }
// emit a greeting
sayHello(greeting_ch)
// convert the greeting to uppercase
convertToUpper(sayHello.out)
// collect all the greetings into one file
collectGreetings(convertToUpper.out.collect(), params.batch)
// emit a message about the size of the batch
collectGreetings.out.count.view { "There were ${it} greetings in this batch" }
}
/*
* Use echo to print 'Hello World!' to a file
*/
process sayHello {
publishDir 'results', mode: 'copy'
input:
val greeting
output:
path "${greeting}-output.txt"
script:
"""
echo '${greeting}' > '${greeting}-output.txt'
"""
}
/*
* Use a text replacement tool to convert the greeting to uppercase
*/
process convertToUpper {
publishDir 'results', mode: 'copy'
input:
path input_file
output:
path "UPPER-${input_file}"
script:
"""
cat '${input_file}' | tr '[a-z]' '[A-Z]' > 'UPPER-${input_file}'
"""
}
/*
* Collect uppercase greetings into a single output file
*/
process collectGreetings {
publishDir 'results', mode: 'copy'
input:
path input_files
val batch_name
output:
path "COLLECTED-${batch_name}-output.txt", emit: outfile
val count_greetings, emit: count
script:
count_greetings = input_files.size()
"""
cat ${input_files} > 'COLLECTED-${batch_name}-output.txt'
"""
}