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

Snakemake中Singularity字段能否使用wildcards及param变量?

在Snakemake的Singularity字段中使用Wildcards和Param变量

可以在Snakemake的singularity字段中使用wildcards和param变量,你遇到的问题大概率是写法有误导致的。以下是具体的使用示例:

  • 使用Wildcards
    若规则需针对不同样本匹配对应容器,直接在singularity字段中引用wildcards变量即可:

    rule process_sample:
        input: "data/{sample}.fastq"
        output: "results/{sample}.bam"
        singularity: "containers/{sample}_processor.sif"
        shell: "samtools view -Sb {input} > {output}"
    

    执行时{sample}会被自动替换为当前规则实例的样本名称,匹配对应的容器文件。

  • 使用Param变量
    若需通过参数动态指定容器版本或路径,可结合params字段实现:

    rule run_analysis:
        input: "input.txt"
        output: "output.txt"
        params: container_version = "v2.1"
        singularity: "containers/analysis_tool_{params.container_version}.sif"
        shell: "analysis_tool --input {input} --output {output}"
    

    这里params.container_version会被替换为指定的参数值,实现容器的动态选择。

注意事项

  • 确保容器路径对应的本地文件存在,或Singularity可从远程仓库(如Docker Hub)拉取对应镜像;
  • 建议使用较新版本的Snakemake,旧版本可能不支持singularity字段的动态变量替换。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 23:43:10