You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Snakemake规则per_read_aggregate通配符不一致报错排查求助

Snakemake报错定位与修复

报错信息

SyntaxError:
Not all output, log and benchmark files of rule per_read_aggregate contain the same wildcards. This is crucial though, in order to avoid that two or more jobs write to the same file.
  File "/scripts/workflows/aggregate_per_reads_ONT/Snakefile.smk", line 14, in <module>

关联代码

Snakefile内容

configfile: "config/config.yaml"
configfile: "config/samples.yaml"

rule all:
    input: 
        expand("results/per_read_aggregate/{samples}/{samples}.5hmC_CpGs_aggregate_reads_stats.rds", samples=config["samples"]),
        expand("results/per_read_aggregate/{samples}/{samples}.5mC_CpGs_aggregate_reads_stats.rds", samples=config["samples"]),
        expand("results/per_read_aggregate/{samples}/{samples}.methylation_states_counts_5hmC_5mC_Unmeth.pdf", samples=config["samples"]),
        expand("results/per_read_aggregate/{samples}/{samples}.hist_nReads_5hmC_5mC_Unmeth.pdf", samples=config["samples"]),
        expand("results/per_read_aggregate/{samples}/{samples}.hist_mean_exp_mod_prob_5hmC_5mC_aggregate_reads_perCpG_sites.pdf", samples=config["samples"]),
        expand("results/per_read_aggregate/{samples}/{samples}.hist_mean_exp_5mC_prob_aggregate_reads_perCpG_sites.pdf", samples=config["samples"]),
        expand("results/per_read_aggregate/{samples}/{samples}.hist_mean_exp_5hmC_prob_aggregate_reads_perCpG_sites.pdf", samples=config["samples"])

rule per_read_aggregate:
    input:
        input_file_from_config=lambda wildcards: config["samples"][wildcards.samples]
    output:
        agg_5hmC_rds="results/per_read_aggregate/{samples}/{samples}.5hmC_CpGs_aggregate_reads_stats.rds",
        agg_5mC_rds="results/per_read_aggregate/{samples}/{samples}.5mC_CpGs_aggregate_reads_stats.rds",
        plt_meth_state="results/per_read_aggregate/{samples}/{samples}.methylation_states_counts_5hmC_5mC_Unmeth.pdf",
        hist_agg_nReads_pdf="results/per_read_aggregate/{samples}/{samples}.hist_nReads_5hmC_5mC_Unmeth.pdf",
        hist_agg_5hmC_5mC_pdf="results/per_read_aggregate/{samples}/{samples}.hist_mean_exp_mod_prob_5hmC_5mC_aggregate_reads_perCpG_sites.pdf",
        hist_agg_5mC_pdf="results/per_read_aggregate/{samples}/{samples}.hist_mean_exp_5mC_prob_aggregate_reads_perCpG_sites.pdf",
        hist_agg_5hmc_pdf="results/per_read_aggregate/{samples}/{samples}.hist_mean_exp_5hmC_prob_aggregate_reads_perCpG_sites.pdf"
    params:
        rscript_from_config=config["Rscript_config"]
    log:
        "logs/{rule}/{samples}/{samples}.log"
    shell:
        """
        Rscript {params.rscript_from_config} --input_file {input.input_file_from_config} --hmc_output_file {output.agg_5hmC_rds} --mc_output_file {output.agg_5mC_rds} --plot_meth_state {output.plt_meth_state} --plot_nReads {output.hist_agg_nReads_pdf} --plot_mean_exp_5mC_5hmC_prob {output.hist_agg_5hmC_5mC_pdf} --plot_mean_exp_5mC_prob {output.hist_agg_5mC_pdf} --plot_mean_exp_5hmC_prob {output.hist_agg_5hmc_pdf} 2> {log}
        """
onsuccess:
    shell("date '+%d/%m/%Y %H:%M:%S' > time_end_Aggregate_per_read_stats_ONT.txt") 

samples.yaml内容

samples:
    sample1_N: /directory/sample1_N/per_read_modified_base_calls.txt
    sample1_T: /directory/sample1_T/per_read_modified_base_calls.txt

问题原因

规则per_read_aggregate的所有输出文件仅使用{samples}通配符,但日志文件额外引入了{rule}通配符。Snakemake强制要求同一规则的输出、日志、基准文件必须包含完全一致的通配符集合,以此保证每个任务生成的文件路径唯一,避免多任务写入冲突。

修复方法

修改日志路径,移除{rule}通配符,替换为当前规则的静态名称,确保日志与输出文件的通配符完全匹配:

log:
    "logs/per_read_aggregate/{samples}/{samples}.log"

内容的提问来源于stack exchange,提问作者sahuno

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 17:18:10