小编nic*_*mee的帖子

Snakemake 如何在上游规则失败时执行下游规则

抱歉标题不好 - 我不知道如何最好地用几句话来解释我的问题。当规则之一失败时,我在处理蛇形中的下游规则时遇到了麻烦。在下面的示例中,规则黑桃在某些样本上失败。这是意料之中的,因为我的一些输入文件会出现问题,黑桃会返回错误,并且不会生成目标文件。这很好,直到我开始统治 eval_ani。在这里,我基本上想在规则 ani 的所有成功输出上运行此规则。但我不确定如何做到这一点,因为我已经有效地将一些样本放入了规则黑桃中。我认为使用 snakemake 检查点可能很有用,但我无法从文档中弄清楚如何应用它。

我也想知道是否有一种方法可以在不重新运行规则黑桃的情况下重新运行规则 ani。假设我提前终止了我的运行,并且规则 ani 没有在所有样本上运行。现在我想重新运行我的管道,但我不想让 snakemake 尝试重新运行所有失败的黑桃作业,因为我已经知道它们对我没有用,而且只会浪费资源。我试过 -R 和 --allowed-rules 但这些都不是我想要的。

rule spades:
    input:
        read1=config["fastq_dir"]+"combined/{sample}_1_combined.fastq",
        read2=config["fastq_dir"]+"combined/{sample}_2_combined.fastq"
    output:
        contigs=config["spades_dir"]+"{sample}/contigs.fasta",
        scaffolds=config["spades_dir"]+"{sample}/scaffolds.fasta"
    log:
        config["log_dir"]+"spades/{sample}.log"
    threads: 8
    shell:
        """
        python3 {config[path_to_spades]} -1 {input.read1} -2 {input.read2} -t 16 --tmp-dir {config[temp_dir]}spades_test -o {config[spades_dir]}{wildcards.sample} --careful > {log} 2>&1
        """

rule ani:
    input:
        config["spades_dir"]+"{sample}/scaffolds.fasta"
    output:
        "fastANI_out/{sample}.txt"
    log:
        config["log_dir"]+"ani/{sample}.log"
    shell:
        """
        fastANI -q {input} --rl {config[reference_dir]}ref_list.txt -o fastANI_out/{wildcards.sample}.txt
        """

rule eval_ani:
    input:
        expand("fastANI_out/{sample}.txt", sample=samples)
    output:
        "ani_results.txt"
    log: 
        config["log_dir"]+"eval_ani/{sample}.log"
    shell:
        """
            python3 ./bin/evaluate_ani.py …
Run Code Online (Sandbox Code Playgroud)

snakemake

6
推荐指数
1
解决办法
614
查看次数

标签 统计

snakemake ×1