Snakefile使用workflow.get_source()报错:Workflow对象无该属性
Snakemake中
workflow.get_source报错的解决办法 不需要额外导入模块,报错核心原因是Snakemake版本不支持
get_source方法。该方法是Snakemake 7.15.0版本之后新增的API,若本地版本低于此,就会触发'Workflow' object has no attribute 'get_source'错误。- 可执行
snakemake --version查看当前版本,若版本过低,运行pip install --upgrade snakemake升级到符合要求的版本即可正常使用该方法。
- 可执行
若无法升级版本,可使用兼容绝大多数Snakemake版本的替代方案:用
workflow.basedir拼接相对路径,示例代码如下:import os rule process_static_input: input: # 拼接Snakefile所在目录与静态文件的相对路径 os.path.join(workflow.basedir, "path/relative/to/snakefile") output: "output_dir/result.txt" shell: "your_command {input} > {output}"workflow.basedir会自动返回Snakefile所在的绝对路径,结合相对路径即可准确定位到静态输入文件。
内容的提问来源于stack exchange,提问作者newuser
相关产品推荐
相关产品推荐

