Snakemake结合Singularity运行报错:未终止的引号字符串
Fixing Snakemake + Singularity macOS Issues with Cellranger Container
Let's break down the two key problems you're facing and walk through actionable fixes:
1. Resolve the "unterminated quoted string" syntax error
This error is almost certainly a bug in the Singularity macOS beta version you're using (3.3.0-rc.1), which has known issues parsing multi-line shell scripts from Snakemake. Try these fixes:
- Collapse multi-line shell commands into a single line: Replace the triple-quote multi-line shell script with a single line using
&&to chain commands. For your minimal example:rule counts: output: "output.txt" container: "docker://marcusczi/cellranger_clean" shell: "cellranger count --help && echo \"hurray!\" > {output}" - Force bash instead of sh: Explicitly call bash inside the container to avoid sh's strict parsing rules. Modify your shell block like this:
shell: """ bash -c 'cellranger count --help; echo "hurray!" > {output}' """ - Upgrade Singularity (or switch to Docker): The 3.3.0 beta is unstable. If possible, switch to a stable Singularity release for macOS, or use Snakemake's
--use-dockerflag directly (since you're on macOS, Docker Desktop is a more mature option than Singularity's beta).
2. Fix Cellranger's false "disk space insufficient" error
Cellranger's disk space check often misbehaves in Singularity containers on macOS due to how system partitions are mounted. Try these workarounds:
- Specify a custom temporary directory: Cellranger defaults to
/tmp, which may be a small mounted partition in the container. Override it with a directory on your local large drive using the--tmpdirflag:shell: """ cellranger count --id={wildcards.sample} --transcriptome={params.transcriptome} --fastqs={params.indir} --sample={params.name} --tmpdir /path/to/your/local/large/tmp mkdir -p {params.outdir} mv ./{wildcards.sample}/ {params.outdir} """ - Bind a local temp dir to the container: Add Singularity bind arguments to map your local temp space to the container's
/tmp:
Run Snakemake with:snakemake -j1 --use-singularity --singularity-args "--bind /your/local/large/tmp:/tmp"
Quick Debugging Checks
- Test the container directly: Run the Singularity command outside Snakemake to isolate issues:
If this fails, the problem is with Singularity/container compatibility, not your Snakemake rule.singularity run docker://marcusczi/cellranger_clean cellranger count --help - Verify environment variables: Add
envto your shell block to confirm variables likeINDEXandOUTDIRare properly passed into the container:shell: """ env cellranger count --id={wildcards.sample} --transcriptome={params.transcriptome} ... """
内容的提问来源于stack exchange,提问作者compuTE
相关产品推荐
相关产品推荐

