The other day, I installed workflow manager, nextflow on my computer. I installed using conda package manager with bioconda channel, that was quite easy way to install nextflow on my system.
Installation of nextflow - T.Y. Blog
There is a nice tutorial for nextflow (https://www.nextflow.io/docs/latest/index.html). In get started page, there is a simple sample script of workflow that convert a string.
On the Nextflow scripting page, the language used as nextflow scripting language was introduced (https://www.nextflow.io/docs/latest/script.html). It is an extension of the Groovy programming language.
- https://en.wikipedia.org/wiki/Apache_Groovy
- https://groovy-lang.org/documentation.html
- https://koji-k.github.io/groovy-tutorial/what-is-groovy.html (in Japanese)
params.str = 'Hello world!'
process splitLetters {
output:
path 'chunk_*'
"""
printf '${params.str}' | split -b 6 - chunk_
"""
}
process convertToUpper {
input:
path x
output:
stdout
"""
cat $x | tr '[a-z]' '[A-Z]'
"""
}
workflow {
splitLetters | flatten | convertToUpper | view { it.trim() }
}
params.str = 'Hello world!'
process splitLetters {
output:
path 'chunk_*'
"""
printf '${params.str}' | split -b 6 - chunk_
"""
}
Theoutput
block allows you to define the output channels of a process, similar to function outputs. A process may have at most one output block, and it must contain at least one output.
process convertToUpper {
input:
path x
output:
stdout
"""
cat $x | tr '[a-z]' '[A-Z]'
"""
}
input
block because it receive the output of splitLetters. This process transforms the str received by input block to uppercase letters "tr '[a-z]' '[A-Z]'"(base) tk$ nextflow run tutorial.nf
N E X T F L O W ~ version 22.10.5
Launching `tutorial.nf` [mad_mcclintock] DSL2 - revision: 5af7f346f0
executor > local (3)
[f5/563a73] process > splitLetters [100%] 1 of 1 ✔
[63/7f8425] process > convertToUpper (2) [100%] 2 of 2 ✔
HELLO
WORLD!
[f5/563a73] process > splitLetters [100%] 1 of 1 ✔
[63/7f8425] process > convertToUpper (2) [100%] 2 of 2 ✔
N E X T F L O W ~ version 22.10.5
Launching `tutorial.nf` [curious_einstein] DSL2 - revision: 72afad773e
executor > local (2)
[f5/b5207d] process > splitLetters [100%] 1 of 1 ✔
[ab/b1650f] process > convertToUpper (1) [100%] 1 of 1 ✔
HELLO
(base) tk$ nextflow run tutorial.nf --str 'Bonjour le monde'
N E X T F L O W ~ version 22.10.5
Launching `tutorial.nf` [special_wright] DSL2 - revision: 3f2cae5687
executor > local (4)
[55/9358d8] process > splitLetters [100%] 1 of 1 ✔
[55/6d93c7] process > convertToUpper (2) [100%] 3 of 3 ✔
BONJOU
ONDE
R LE M
As of version 20.11.0-edge, any.
(dot) character in a parameter name is interpreted as the delimiter of a nested scope. For example,--foo.bar Hello
will be interpreted as params.foo.bar. If you want to have a parameter name that contains a.
(dot) character, escape it using the back-slash character, e.g.--foo\.bar Hello
.
params.str1 = 'Hello world!'
process splitLetters {
output:
path 'chunk_*'
"""
printf '${params.str1}' | split -b 6 - chunk_
"""
}
(base) tk$ nextflow run tutorial2.nf --str1 'Bonjour le monde'
N E X T F L O W ~ version 22.10.5
Launching `tutorial.nf` [grave_gilbert] DSL2 - revision: 421400f9e3
executor > local (4)
[2d/b9e426] process > splitLetters [100%] 1 of 1 ✔
[d7/1053d8] process > convertToUpper (2) [100%] 3 of 3 ✔
BONJOU
ONDE
R LE M
(base) tk$ nextflow run tutorial2.nf --str 'Bonjour le monde'
N E X T F L O W ~ version 22.10.5
Launching `tutorial.nf` [gloomy_lamport] DSL2 - revision: 421400f9e3
executor > local (3)
[25/dbde42] process > splitLetters [100%] 1 of 1 ✔
[00/93720f] process > convertToUpper (2) [100%] 2 of 2 ✔
HELLO1
2
params.1 = 'Hello world!'
process splitLetters {
output:
path 'chunk_*'
"""
printf '${params.1}' | split -b 6 - chunk_
"""
}
The output was,
(base) tk$ nextflow run tutorial3.nf
N E X T F L O W ~ version 22.10.5
Launching `tutorial3.nf` [tiny_joliot] DSL2 - revision: 7f88a4f3a1
Script compilation error
- file : /XXX/YYY/ZZZ/tutorial3.nf
- cause: The LHS of an assignment should be a variable or a field accessing expression @ line 1, column 7.
params.1 = 'Hello12'
^
1 error