python - 尝试通过 snakemake 配置文件设置命令行值时出错
问题描述
我试图让--profile
snakemake(在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但它并没有对此有所了解。
解决方案
我在文件中使用以下内容解决了这个问题config.yaml
:
verbose: True
set-threads: ["trim=7", "diamond_dna=5"]
请注意,由于 Pythonargparse
处理参数的方式,nargs='*'
您可能需要按照您在命令行中放置--set-threads
和的顺序来进行操作。--config
snakemake
此外,在给出要制作的目标之前不要用--
信号结束选项:这样做会导致trim=7
etc(如我的示例中)被解释为 snakemake 目标,因为argparse
将它们附加到命令行和snakemake使用nargs='*'
它的target
命令行选项。
推荐阅读
- json - MarkLogic:列出目录中的所有 JSON,并使用元数据转换为另一种 JSON 格式
- xml - XSLT 变量不充当节点集
- c# - 路由事件只能应用于从定义类派生的类型
- excel - 为什么传递参数会产生错误argumenttype ByRef?
- javascript - 使用 Sequelize 从多个表中获取数据
- javascript - 为什么这个脚本只能在主 HTML 文件中工作?
- git - 如何在没有管理员权限的情况下检测 VSCode 上的 git
- google-bigquery - GitHub 数据中缺少 mediawiki 项目?
- bash - 仅对最新文件使用 wget 和 wput
- iccube-reporting - 解决小部件之间的顺序