首页 > 解决方案 > 尝试通过 snakemake 配置文件设置命令行值时出错

问题描述

我试图让--profilesnakemake(在Ubuntu 20.04上运行的版本5.20.0)的论点起作用。我有一个配置文件目录,其中包含一个config.yaml文件。如果我把它放入config.yaml

verbose: 1

并运行snakemake --profile xxx target,一切顺利。但是,如果配置文件包含

set-threads: "trim=7 diamond_dna=5"

蛇制造抱怨:

MissingRuleException:
No rule to produce --set-threads=trim=7 diamond_dna=5 (if you use input functions make sure that they don't raise unexpected exceptions).

所以看起来一个=正在被放入--set-threads参数中,然后snakemake将其解释为我想要制作的目标。(如果我使用set-threads: "'trim=7 diamond_dna=5'"它以防万一有人想知道,我会得到同样的结果——即使我认为 Pythonargparse不会正确处理它,如果它走得那么远)。

如果我把它放到配置文件中:

verbose: 1
set-threads: "trim=7 diamond_dna=5"

我有时会得到

MissingRuleException:
No rule to produce --verbose (if you use input functions make sure that they don't raise unexpected exceptions).

但其他时候得到

MissingRuleException:
No rule to produce --set-threads=trim=7 diamond_dna=5 (if you use input functions make sure that they don't raise unexpected exceptions).

是的,对于完全相同的输入配置文件,错误会发生变化。我猜snakemake正在考虑这两种情况,--verbose--set-threads=trim=7 diamond_dna=5在这两种情况下都成为目标,并且(以某种方式)随机化它决定首先尝试制造的目标。

无论如何,我显然做错了什么或不理解--profile应该如何工作。任何帮助将非常感激!我已经看过https://github.com/snakemake-profiles/doc但它并没有对此有所了解。

标签: pythonsnakemake

解决方案


我在文件中使用以下内容解决了这个问题config.yaml

verbose: True
set-threads: ["trim=7", "diamond_dna=5"]

请注意,由于 Pythonargparse处理参数的方式,nargs='*'您可能需要按照您在命令行中放置--set-threads和的顺序来进行操作。--configsnakemake

此外,在给出要制作的目标之前不要用--信号结束选项:这样做会导致trim=7etc(如我的示例中)被解释为 snakemake 目标,因为argparse将它们附加到命令行和snakemake使用nargs='*'它的target命令行选项。


推荐阅读