对于
snakemake
v8.10.8
,如果我有以下使用容器的Snakefile
rule hello_world_container:
params:
output_dir="results",
name="standard model"
output:
"results/hello_world.txt"
container:
"docker://busybox:1.33"
shell:
"""
mkdir -p {params.output_dir}
echo "Hello my Name is {params.name}" | tee {output}
"""
因此使用
--software-deployment-method apptainer
命令行选项,如何设置 Apptainer 在运行时使用的 shell 命令? shell 默认为 Bash,但有些容器没有 bash
作为 shell,例如 busybox
。所以这个 Snakefile 的命令如下
snakemake --verbose --cores 1 --printshellcmds --software-deployment-method apptainer --snakefile Snakefile hello_world_container
立即失败
Command ' singularity exec --home '<cwd>' <cwd>/.snakemake/singularity/893d95b26cf7d03ff72563d5db3f40ca.simg bash -c 'set -euo pipefail;
mkdir -p results
echo "Hello my Name is standard model" | tee results/hello_world.txt'' returned non-zero exit status 255.
使用现有的 shell 将
busybox
与 Apptainer 一起使用,正如预期的那样,
$ apptainer exec docker://busybox:1.33 sh -c "echo 'hello world'"
INFO: Using cached SIF image
hello world
那么Snakemake中如何设置shell呢?
目前,可以使用例如设置所有规则的外壳
shell.executable("sh")
Snakefile 中第一条规则之前的某个位置。但是,对于您的情况,最好能够按规则设置 shell。从技术上来说,这相对容易实现(尽管需要修改一些尚未优化的代码)。我现在已经在这里完成了:https://github.com/snakemake/snakemake/pull/2856