process test {
input:
val myval
output:
path "${myval}.txt"
"""
touch "${myval}.txt"
"""
}
workflow {
def foobarbaz = ['foo': 1, 'bar': 2, 'baz': 3]
Channel.of('foo', 'bar', 'baz')
| test
| map { tuple( foobarbaz[ it.baseName ], it ) }
| view()
}
结果:
$ nextflow run main.nf
N E X T F L O W ~ version 22.10.0
Launching `main.nf` [high_faggin] DSL2 - revision: 43aaa56eee
executor > local (3)
[0e/0fd6dc] process > test (3) [100%] 3 of 3 ✔
[1, /path/to/work/a7/d501cb2a8426c5639117d14e8fb7fe/foo.txt]
[2, /path/to/work/22/df9cc4f1d34b9cca0d0331fac5c150/bar.txt]
[3, /path/to/work/0e/0fd6dc0519a34c52903b990755f450/baz.txt]
process foo {
input:
val myval
output:
path "${myval}.txt"
"""
echo "value: ${myval}" > "${myval}.txt"
"""
}
process bar {
input:
path myfile
output:
stdout
"""
echo "Contents of ${myfile}:"
cat "${myfile}"
"""
}
workflow {
Channel.of('foo', 'bar', 'baz')
| foo
| bar
| view()
}
结果:
$ nextflow run main.nf
N E X T F L O W ~ version 22.10.0
Launching `main.nf` [clever_lovelace] DSL2 - revision: c388bd26af
executor > local (6)
[ac/1be228] process > foo (2) [100%] 3 of 3 ✔
[11/7b3c6e] process > bar (1) [100%] 3 of 3 ✔
Contents of foo.txt:
value: foo
Contents of bar.txt:
value: bar
Contents of baz.txt:
value: baz
1条答案
按热度按时间lrpiutwd1#
我想知道如何提取Nextflow Channel的内容并使其成为字符串
最好不要尝试这样做。如果您只想根据流程的输出选择Map关键字,您可以在工作流块中声明Map并根据需要使用它。例如:
结果:
请注意,您不需要watchPath工厂方法来监视前一个进程的输出路径。只需在输出块中定义前一个进程的输出,并在下游进程的输入块中将它们声明为输入即可。例如:
结果: