【问题标题】:MissingOutputException with SnakemakeSnakemake 的 MissingOutputException
【发布时间】:2020-12-30 22:26:39
【问题描述】:

我遇到以下问题: 我的 Snakemake 程序无法识别我的 python 脚本生成的输出。我都尝试了,将输出写入标准输出,然后从那里写入正确的输出文件,然后直接从 python 脚本(以下版本)写入。

--latency-wait 设置为 600 也无济于事。 其他用户报告说运行ls 有帮助,我在等待延迟时尝试过,但这也无济于事。 此外,当再次运行时,snakemake 想要再次运行所有输入文件,尽管一些输出文件已经存在。 有没有人建议我还能尝试什么? 这是我正在使用的蛇形命令:

snakemake -j 2 --use-conda

下面是我的蛇文件:

import os

dir = "my/data/dir"
cell_lines = os.listdir(dir)
files = os.listdir(dir+"GM12878/25kb_resolution_intrachromosomal")
chromosomes = [i.split("_")[0] for i in files]

rule all:
        input:
                expand("~/TADs/{cell_lines}_{chromosomes}_TADs.tsv", cell_lines = cell_lines, chromosomes = chromosomes)

rule tad_calling:
        input:
                "my/data/dir/{cell_lines}/25kb_resolution_intrachromosomal/{chromosomes}_25kb.RAWobserved"

        output:
                "~/TADs/{cell_lines}_{chromosomes}_TADs.tsv"

        benchmark:
              "benchmarks/{cell_lines}_{chromosomes}.txt"

        conda:
                "my_env.yaml"

        shell:
                """
                python ~/script.py {input} {output}
                """

【问题讨论】:

    标签: python snakemake


    【解决方案1】:

    我认为问题出在波浪号(~)上,snakemake 不会扩展这些(或例如 $HOME)。它将这些作为文字路径。你可以这样做:

    from pathlib import Path
    home = str(Path.home())
    
    rule tad_calling:
        ...
        output:
            f"{home}/TADs/{cell_lines}_{chromosomes}_TADs.tsv"
        ...
    

    【讨论】:

    • 是的,事情就是这样。我更换了所有这些,它工作得很好!不知道“~”必须被扩展,当替换为 /home/usr/ 时它起作用了。由于 shell 正确解释了波浪号,我没想到它会成为问题的原因。
    • 只是一个警告:即使它看起来有效,我也觉得在snakemake 中对(输入和)输出使用绝对路径并不是一个好习惯。努力只在可配置的输出目录中创建文件,使工作流程更易于重用,并且不太可能覆盖宝贵的文件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-15
    • 1970-01-01
    • 1970-01-01
    • 2022-11-13
    • 2021-02-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多