Snakemake:通配符不会在规则的脚本行中扩展
我正在运行管道,并试图通过在配置文件(config.yaml)中声明路径来对其进行优化。 config.yaml文件包含找到可以在管道内运行的脚本的路径,但是当我扩展路径的通配符时,管道不会运行脚本。脚本本身运行良好。 要解释我的问题:
rule with_script:
input: someinput
output: someoutput
script: expand("{script_path}/scriptfile", script_path = config[scriptpath])
输入,输出或规则都不包含脚本的路径通配符,因此这是我第一次宣布它。包含路径的config.yaml行看起来像:
scriptpath: /path/to/the/script
有没有一种方法可以维护通配符和配置文件路径(以使其他人更容易在需要时进行更改)并使脚本工作?就像这个snakemake甚至没有输入脚本文件。还是可以在规则之外宣布全球通配符?
感谢您的帮助!
PS:很抱歉,如果这个问题已经得到回答,但是我找不到任何帮助我的问题。
I am running a pipeline and was trying to optimize it by declaring the paths in a config file (config.yaml). The config.yaml file contains the path to find the scripts to run inside the pipeline, but when I expand the wildcard of the path, the pipeline does not run the script. The script itself runs fine.
To explain my problem:
rule with_script:
input: someinput
output: someoutput
script: expand("{script_path}/scriptfile", script_path = config[scriptpath])
input, output or rule all do not contain the script's path wildcard, so here is the first time I'm declaring it. The config.yaml line that contains the path looks like this:
scriptpath: /path/to/the/script
is there a way to maintain the wildcard and config file path (to make it easier for others to make changes if needed) and have the script work? Like this snakemake doesn't even enter the script file. Or maybe it is possible to declare global wildcards outside the rule all?
Thank you for your help!
P.S.: I'm sorry if this question has already been answered, but I couldn't find anything to help me with this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能在脚本部分中定义
expand()
的函数。 Snakemake期望您的脚本有一条途径。像 documentation>
如果您需要定义脚本的不同路径,则可以随时在规则之外的Python中进行操作。别忘了,在构建DAG之前,在规则之外执行了所有Python代码。因此,您可以定义所需的所有变量,并在规则中使用它们。
注意:
请勿混合 wildcards 和“变量”。 在
{script_path}
的扩展函数中,不是通配符,而只是占位符的占位符。
You cannot define a function like
expand()
in the script section. Snakemake expects a path to your script.Like the documentation states:
If you need to define different paths to your scripts, you can always do it in python outside of your rules. Don't forget, all python code outside of rules is executed before building the DAG. Thus, you can define all variables you want and use them in your rules.
Note:
Do not mix wildcards and "variables". In an expand function as
{script_path}
is not a wildcard but just a placeholder for the values given in the second parameter of the function.