awk - How to inlcude functions from another file in a awk script using nextflow
问题描述
As per the Nextflow documentation I put my awk scripts in the bin/
folder. Some scripts share the same functions so I wrote a file with only awk functions that I usually include using:
@include "relative/path/to/lib.awk"
But because the script runs in the nextflow work directory the relative path doesn't work anymore. I tried to put the library file in bin/
too but it didn't work as well.
How should I proceed? I don't want to copy/paste functions in the scripts, I also don't want to hardcode an absolute path.
解决方案
感谢@Pallie 提供有关workflow.projectDir
. 关于这个变量的文档在这里(我想我到处找,不清楚我能做到这一点),这个答案也有帮助: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"
推荐阅读
- c++ - 使用用户定义的类 (C++) 将数据集写入 HDF5
- javascript - Django:在数据库中存储一个 CSS 类
- c# - C# - 搜索dataGridView后保存按钮
- javascript - Discord.js 禁止命令中的无效表单正文
- youtube-livestreaming-api - 自 2020 年 10 月 1 日以来,Youtube liveStreams 插入出现错误
- angularjs - 已完成 500 INTERNAL_SERVER_ERROR SpringBoot Angular:OneToMany 问题
- node.js - 使用 sequelize 删除父级时如何软删除关联子行
- flutter - 构建我的应用程序时出现不推荐使用的错误
- r - 用 1-10 标记 10 年的数据,而不是 1955-1966
- api - clearMarkers() 和 addMarker() 不起作用