我有两条工作管道。第一个管道从配置文件获取输入,然后创建 .csv 输出文件。第二个管道接收前一个管道的 .csv 输出。当我独立运行这些管道时,它们按预期工作。我试图通过将它们作为模块导入到第三个 Snakefile 中来组合这些管道。然而,snakefile 抛出了一个错误,我无法弄清楚我做错了什么。
我的snakemake版本是8.6
目录结构如下:
这是我在其中导入工作管道的 Snakefile 的内容。
from snakemake.utils import min_version
min_version("6.0")
module metadata:
snakefile:
"../../metadata/workflow/metadata.smk"
replace_prefix: '../../metadata'
config:
'config/metadata.yaml'
use rule * from metadata as metadata_*
module download:
snakefile:
"../../download/workflow/downloads.smk"
replace_prefix: "../../download"
config:
'config/download.yaml'
use rule * from download as download_*
rule all:
input:
rules.metadata_all.input,
rules.download_all.input
default_target: True
这是我运行时收到的错误
snakemake --cores 1 -n
:
Traceback (most recent call last):
File "/home/bayraktar/miniforge3/envs/snakemakefull/lib/python3.12/site-packages/snakemake/cli.py", line 1961, in args_to_api
dag_api = workflow_api.dag(
^^^^^^^^^^^^^^^^^
File "/home/bayraktar/miniforge3/envs/snakemakefull/lib/python3.12/site-packages/snakemake/api.py", line 328, in dag
return DAGApi(
^^^^^^^
File "<string>", line 6, in __init__
File "/home/bayraktar/miniforge3/envs/snakemakefull/lib/python3.12/site-packages/snakemake/api.py", line 438, in __post_init__
self.workflow_api._workflow.dag_settings = self.dag_settings
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bayraktar/miniforge3/envs/snakemakefull/lib/python3.12/site-packages/snakemake/api.py", line 385, in _workflow
workflow.include(
File "/home/bayraktar/miniforge3/envs/snakemakefull/lib/python3.12/site-packages/snakemake/workflow.py", line 1391, in include
exec(compile(code, snakefile.get_path_or_uri(), "exec"), self.globals)
File "/home/bayraktar/PycharmProjects/combined_pipelines/run_pipe/workflow/Snakefile", line 16, in <module>
"../../download/workflow/downloads.smk"
File "/home/bayraktar/miniforge3/envs/snakemakefull/lib/python3.12/site-packages/snakemake/workflow.py", line 2130, in decorate
module.use_rules(
File "/home/bayraktar/miniforge3/envs/snakemakefull/lib/python3.12/site-packages/snakemake/modules.py", line 82, in use_rules
modifier = WorkflowModifier(
^^^^^^^^^^^^^^^^^
File "/home/bayraktar/miniforge3/envs/snakemakefull/lib/python3.12/site-packages/snakemake/modules.py", line 207, in __init__
self.path_modifier = PathModifier(replace_prefix, prefix, workflow)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bayraktar/miniforge3/envs/snakemakefull/lib/python3.12/site-packages/snakemake/path_modifier.py", line 32, in __init__
for prefix, replacement in replace_prefix.items():
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'items'
错误消息清楚地解释了问题:
replace_prefix
应该是字典,而不是字符串。从逻辑上讲,要替换某些内容,您需要指定要替换的内容以及要替换的内容。所以它应该看起来像这样:
replace_prefix: {'../../metadata' : 'absolute_path_to_metadata'}