Snakemake + docker示例,如何使用卷

不久

让我们有一个简单的snakefile像

rule targets:
    input:
        "plots/dataset1.pdf",
        "plots/dataset2.pdf"

rule plot:
    input:
        "raw/{dataset}.csv"
    output:
        "plots/{dataset}.pdf"
    shell:
        "somecommand {input} {output}"

我想归纳出绘图规则,以便它可以在docker容器中运行,

rule targets:
    input:
        "plots/dataset1.pdf",
        "plots/dataset2.pdf"

rule plot:
    input:
        "raw/{dataset}.csv"
    output:
        "plots/{dataset}.pdf"
    singularity:
        "docker://joseespinosa/docker-r-ggplot2"
    shell:
        "somecommand {input} {output}"

如果我很好理解,当我运行时,我会在docker容器snakemake --use-singularitysomecommand运行该文件,如果不对该容器进行一些卷配置,则无法找到输入的csv文件。

您能否提供一个小的工作示例,说明如何在Snakefile或其他Snakemake文件中配置卷?

巴里巴勒

当您运行snakemake并告诉它使用奇点图像时,您可以执行以下操作:

snakemake --use-singularity

您还可以将其他参数传递给奇异性,包括绑定点,如下所示:

snakemake --use-singularity --singularity-args "-B /path/outside/container/:/path/inside/container/"

现在,如果您的csv文件位于中/path/outside/container/,则可以通过somecommand毫无问题地看到。

请记住,如果内部和外部路径不相同,则需要在snakemake规则的不同部分中同时使用这两个路径。这是我的方法:

rule targets:
    input:
        "plots/dataset1.pdf",
        "plots/dataset2.pdf"

rule plot:
    input:
        "raw/{dataset}.csv"
    output:
        "plots/{dataset}.pdf"
    params:
        i = "inside/container/input/{dataset}.csv",
        o = "inside/container/output/{dataset}.pdf"
    singularity:
        "docker://joseespinosa/docker-r-ggplot2"
    shell:
        "somecommand {params.i} {params.o}"

当你运行这个snakefile,绑定raw/inside/container/input/,并绑定plots/inside/container/output/Snakemake会在本地计算机上查找输入/输出文件,但会向容器提供命令以使用内部容器路径运行,并且一切都会很棒。

TL; DR:输入和输出中的本地路径,params和shell中的容器路径。在命令行调用中绑定本地和容器路径。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章