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

Snakemake工作流本地正常运行,GitHub Action执行失败排查

Snakemake规则跨环境运行异常问题

问题背景

Snakemake工作流在本地macOS环境运行完全正常,但其中一个规则在GitHub Action(Ubuntu)以及Ubuntu工作站上总是失败,尝试多种方案仍未解决。

核心需求

使用bigwigmerge汇总bigwig文件信号,但该工具要求至少2个输入文件;当只有1个输入文件时,改用bigwigtobedgraph(两者输出均为bedgraph格式)。

初始规则实现

rule bigwigs_to_summed_bedgraph:
    input:
        expand(
            "results/bigwig/{dataset}.bw",
            dataset=DATASETS,
        ),
    output:
        pipe("results/bigwig/all_summed.bedGraph"),
    params:
        nargs=len(DATASETS),
    log:
        std="results/bigwig/logs/bigwigs_to_summed_bedgraph.stdout",
        err="results/bigwig/logs/bigwigs_to_summed_bedgraph.stderr",
    conda:
        "../envs/bigwig_tools.yml"
    shell:
        # bigwigmerge requires a minimum of 2 files, but the original R script
        # supports 1, so to support 1 file here, we use bigwigtobedgraph
        """
        if [ {params.nargs} -eq 1 ]; then \
            bigwigtobedgraph {input:q} {output:q} 1> {log.std:q} 2> {log.err:q}; \
        else \
            bigwigmerge {input:q} {output:q} 1> {log.std:q} 2> {log.err:q}; \
        fi
        """

本地运行命令(macOS)

snakemake --directory .tests/test_6_summits --use-conda --cores 2 --printshellcmds all_atac_summits --forceall --show-failed-logs

GitHub Action配置

temporary-summits-delete-after-59-merged:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Codebase
        uses: actions/checkout@v3
      - name: Test summits steps only
        uses: snakemake/snakemake-github-action@v1
        with:
          directory: '.tests/test_6_summits'
          snakefile: 'workflow/Snakefile'
          args: >-
            --use-conda -c 2 --show-failed-logs -p --verbose all_atac_summits

关联的all_atac_summits规则

rule all_atac_summits:
    input:
        "results/all_atac_summits.bed",
        "results/all_atac_summits.tsv",

GitHub Action报错信息

Error in group 8c80e530-b72c-4cd2-ba80-00b10c34aa9e:
    jobs:
        rule sort_summed_bedgraph:
            jobid: 5
            output: results/bigwig/all_sorted.bedGraph
            log: results/bigwig/logs/sort_summed_bedgraph.stderr (check log file(s) for error details)
        rule bigwigs_to_summed_bedgraph:
            jobid: 6
            output: results/bigwig/all_summed.bedGraph (pipe)
            log: results/bigwig/logs/bigwigs_to_summed_bedgraph.stdout, results/bigwig/logs/bigwigs_to_summed_bedgraph.stderr (check log file(s) for error details)
Logfile results/bigwig/logs/sort_summed_bedgraph.stderr: empty file

Removing output files of failed job sort_summed_bedgraph since they might be corrupted:
results/bigwig/all_sorted.bedGraph
Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message

已尝试的解决方案

  • 将pipe()改为temp():本地正常,GitHub Action仍报错
  • 修改条件判断为if [ "{params.nargs}" == "1" ]; then \:本地正常,GitHub Action仍报错
  • 修改条件判断为if [[ {params.nargs} -eq 1 ]]; then \:本地正常,GitHub Action出现语法错误
  • 修改shell命令为尝试bigwigmerge失败后执行bigwigtobedgraph:本地正常,GitHub Action仍报错
  • 仅保留bigwigtobedgraph命令:本地和GitHub Action均正常

补充说明

曾考虑用run替代shell,但得知run无法配合conda使用(Python代码会在Snakemake环境中运行);尝试拆分规则未成功,且报错信息缺乏有效调试内容,最初无法在本地复现。

更新

Ubuntu工作站(GNU bash 5.1.16(1)-release)能复现该错误,macOS机器(GNU bash 5.0.17(1)-release)无此问题,怀疑与bash版本差异有关。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 06:02:09