【问题标题】:How to inlcude functions from another file in a awk script using nextflow如何使用 nextflow 在 awk 脚本中包含来自另一个文件的函数
【发布时间】:2019-11-16 02:11:57
【问题描述】:

根据 Nextflow 文档,我将 awk 脚本放在 bin/ 文件夹中。一些脚本共享相同的函数,所以我编写了一个文件,其中只包含我通常使用的 awk 函数:

@include "relative/path/to/lib.awk"

但是由于脚本在 nextflow 工作目录中运行,因此相对路径不再起作用。我也尝试将库文件放入bin/,但效果不佳。

我应该如何进行?我不想在脚本中复制/粘贴函数,也不想硬编码绝对路径。

【问题讨论】:

  • 可以使用 workflow.projectDir/path/to/awk 吗?
  • 感谢您的提示,我不知道workflow.projectDir
  • 很高兴为您提供帮助

标签: awk nextflow


【解决方案1】:

感谢@Pallie 提供有关workflow.projectDir 的提示。关于这个变量的文档是here(我以为我到处找,不清楚我能做到这一点),这个答案也有帮助:https://stackoverflow.com/a/28463193/2849598

awk 可以在AWKPATH 中加载库文件,我的文件在lib/ 中,所以,对于下一个流程:

process my_process {
  input:
  path input from input_channel

  output:
  path "output.txt"

  script:
  """
  export AWKPATH="$workflow.projectDir/lib"
  script.awk ${input} > output.txt
  """
}

在我的脚本顶部,我像这样调用库文件

@include "my_functions.awk"

【讨论】:

    猜你喜欢
    • 2010-12-15
    • 2011-08-01
    • 2019-11-05
    • 1970-01-01
    • 2019-01-06
    • 1970-01-01
    • 2011-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多