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
相关产品推荐
相关产品推荐

