英文:
Nextflow: Use a variable defined in the `exec` block as process' output (Groovy)
问题
在我的Nextflow流水线中,我有一个用Groovy编写的进程。因此,我想在exec
块中执行后者(参见文档)并将其中一个变量作为该进程的输出返回。
以下是一个示例:
process my_process {
output:
val(myList), emit: my_process_output
exec:
def myList = []
myList.append(1)
myList.append(2)
myList.append(3)
}
workflow {
my_process()
my_process.out.my_process_output.view()
}
然而,这个在Tower上运行的流水线返回了以下错误:
下载插件nf-google@1.4.5
N E X T F L O W ~ 版本 22.10.6
Pulling <repo> ...
从 https://github.com/<repo>.git 下载
启动 `https://github.com/<repo>` [<run_name>] DSL2 - 修订版本: <commit SHA>
警告: 进程 'my_process' 无法由 'google-lifesciences' 执行器执行 -- 改用 'local' 执行器
警告: 除非启用了Fusion,否则本地执行器只支持默认文件系统 -- 检查工作目录: gs://<org>/scratch/<uid>
警告: Tower请求字段`workflow.revision`超出了预期的大小 | 冒犯值:`<git branch>`,大小:42(最大:40)
使用此URL在Nextflow Tower中监视执行:https://tower.<my_org>/orgs/<URL>
[01/31785c] 已提交进程 > my_process
[01/31785c] 注意: 进程 `my_process` 失败 -- 错误被忽略
警告: Tower请求字段`workflow.revision`超出了预期的大小 | 冒犯值:`ss-3597/compare-basespace-and-gcp-filesize`,大小:42(最大:40)
保存缓存:.nextflow/cache/<sha> => gs://<org>
**问题:**如何将在exec
块中定义/计算的变量作为process
的输出返回?
英文:
In my Nextflow pipeline, I have a process written in Groovy. So I want to execute the latter in an exec
block (cf. docs) and return one of its variables as the process' output.
Here's an example:
process my_process {
output:
val(myList), emit: my_process_output
exec:
def myList = []
myList.append(1)
myList.append(2)
myList.append(3)
}
workflow {
my_process()
my_process.out.my_process_output.view()
}
However, this pipeline run on Tower returns the following error:
Downloading plugin nf-google@1.4.5
N E X T F L O W ~ version 22.10.6
Pulling <repo> ...
downloaded from https://github.com/<repo>.git
Launching `https://github.com/<repo>` [<run_name>] DSL2 - revision: <commit SHA>
WARN: Process 'my_process' cannot be executed by 'google-lifesciences' executor -- Using 'local' executor instead
WARN: Local executor only supports default file system (unless Fusion is enabled) -- Check work directory: gs://<org>/scratch/<uid>
WARN: Tower request field `workflow.revision` exceeds expected size | offending value: `<git branch>`, size: 42 (max: 40)
Monitor the execution with Nextflow Tower using this URL: https://tower.<my_org>/orgs/<URL>
[01/31785c] Submitted process > my_process
[01/31785c] NOTE: Process `my_process` failed -- Error is ignored
WARN: Tower request field `workflow.revision` exceeds expected size | offending value: `ss-3597/compare-basespace-and-gcp-filesize`, size: 42 (max: 40)
Saving cache: .nextflow/cache/<sha> => gs://<org>
Question: How to return a variable defined/computed in the exec
block as the process
' output?
答案1
得分: 1
以下语法可用:
process my_process {
output:
val(myList), emit: my_process_output
exec:
myList = []
myList.add(1)
myList.add(2)
myList.add(3)
}
workflow {
my_process()
my_process.out.my_process_output.view()
}
除了 <strike>append</strike>
→ add
的拼写错误外,关键是在创建 myList
变量时 不 使用 def
。
英文:
The following syntax works:
process my_process {
output:
val(myList), emit: my_process_output
exec:
myList = []
myList.add(1)
myList.add(2)
myList.add(3)
}
workflow {
my_process()
my_process.out.my_process_output.view()
}
In addition to the <strike>append
</strike> → add
typo, the key is to not use def
when creating the myList
variable.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论