gpt4 book ai didi

docker - Snakemake 奇点与本地资源/关于 Snakemake 与 --use-singularity 的问题

转载 作者:行者123 更新时间:2023-12-04 13:50:57 26 4
gpt4 key购买 nike

我开始尝试在 Snakemake 中使用容器,我有一个问题,什么需要预先构建到容器中,什么不需要。例如:
我想在一个容器中运行一个 python 脚本(例如,存储在 workflow_root/scripts/myScript.py 中),并带有来自另一个程序的管道。我是否需要将 python 脚本构建到容器中,将其声明为输入文件,还是可以从容器内访问(以及如何指向它)?我目前的规则看起来像:

rule myRule:
params:
sample = get_sample,
basePath = sys.path[0]
input:
in1=get_in1,
in2=get_in2
output:
out1 = "{runPath}/{sample}_read1_dcs.fq.gz",
out2 = "{runPath}/{sample}_read2_dcs.fq.gz"
priority: 50
conda:
"envs/myEnv.yaml"
log:
"{runPath}/logs/{sample}_myRule.log"
shell:
"""
set -e
set -o pipefail
set -x
{{
picard FastqToSam \
F1={input.in1} \
F2={input.in2} \
O=/dev/stdout \
SM={params.sample} \
TMP_DIR=picardTempDir \
SORT_ORDER=unsorted \
| python3 {params.basePath}/scripts/myScript.py \
--input /dev/stdin \
--prefix {wildcards.sample}
}} 2>&1 | tee -a {log}
"""
我想运行 bwa,在那里我有一个需要使用的大量用户提供的引用。我可以这样做,还是需要将该引用构建到容器中? (我还想使用 ensemble-VEP,它有自己相当大的引用数据库来处理)。
我想我的问题归结为:Snakemake 将哪些文件/位置安装到容器中,以及在编写涉及 shell 命令的规则时在哪里找到它们?文档似乎对此不是很清楚,如果能够在无需进行大量实验的情况下弄清楚它会很好。

最佳答案

我将分享我如何使用snakemake 和singularity 和conda。一年多来,这种设置对我来说非常有效。此设置可能适合也可能不适合您的目的;所以请随意提问。

  • Snakemake 工作流程以及必要的脚本、配置和文档都在一个单独的 git 存储库中。数据不会存储在这里。
  • Singularity 容器是通过 singularity: 在全局级别定义的工作流中的指令。我不手动构建容器;蛇形就是这样做的。
  • Conda 环境是通过 conda: 按规则定义的指示。在复杂的项目中,有时这可能是 > 15-20 个单独的 conda 环境。 Snakemake 在奇点容器中构建这些 conda 环境。
  • 数据与源代码分开保存。相反,工作流配置文件(通常通过 configfile: 指令定义)包含它们的路径信息。

  • Snakefile 示例如下所示:
    # config for the workflow
    configfile: "configs/workflow_configs.yaml"

    # singularity image to use
    singularity: "docker://continuumio/miniconda3:4.7.12"

    rule all:
    input:
    .....

    rule some_job:
    input:
    .....
    output:
    .....
    conda:
    "path/to/conda_env.yaml"
    shell:
    "....."
    只要工作流所需的所有工具都可以通过 conda 获得,此设置就可以工作。也可以针对特定规则覆盖全局奇异性容器,并使用不同的奇异性容器或根本不使用容器。
    此外,我不构建自己的奇点容器,而是使用 docker-hub 提供的通用容器。无论如何,我没有特权在我使用的 HPC 系统中构建我自己的奇点容器。因此,此设置消除了在某处构建镜像然后将其移动到 HPC 环境的麻烦。

    关于docker - Snakemake 奇点与本地资源/关于 Snakemake 与 --use-singularity 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69470051/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com