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

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-docker flag 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 --tmpdir flag:
    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:
    singularity run docker://marcusczi/cellranger_clean cellranger count --help
    
    If this fails, the problem is with Singularity/container compatibility, not your Snakemake rule.
  • Verify environment variables: Add env to your shell block to confirm variables like INDEX and OUTDIR are properly passed into the container:
    shell: """
        env
        cellranger count --id={wildcards.sample} --transcriptome={params.transcriptome} ...
    """
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.08 17:12:56