处理snakemake中的SIGPIPE错误

时间:2017-10-04 15:56:29

标签: snakemake sigpipe

以下snakemake脚本:

rule all:
    input:
        'test.done'

rule pipe:
   output:
       'test.done'
   shell:
        """
        seq 1 10000 | head > test.done
        """

因以下错误而失败:

snakemake -s test.snake

Provided cores: 1
Rules claiming more threads will be scaled down.
Job counts:
    count   jobs
    1   all
    1   pipe
    2

rule pipe:
    output: test.done
    jobid: 1

Error in job pipe while creating output file test.done.
RuleException:
CalledProcessError in line 9 of /Users/db291g/Tritume/test.snake:
Command '
        seq 1 10000 | head > test.done
        ' returned non-zero exit status 141.
  File "/Users/db291g/Tritume/test.snake", line 9, in __rule_pipe
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/concurrent/futures/thread.py", line 55, in run
Removing output files of failed job pipe since they might be corrupted:
test.done
Will exit after finishing currently running jobs.
Exiting because a job execution failed. Look above for error message

解释返回非零退出状态141 似乎表示snakemake已捕获head发送的SIGPIPE失败。我认为严格来说,snakemake在捕捉失败方面正在做正确的事情,但我想知道是否有可能忽略某些类型的错误,比如这个错误。我有一个使用head命令的snakemake脚本,我正在尝试找到一个解决方法此错误。

2 个答案:

答案 0 :(得分:4)

是的,Snakemake默认设置pipefail,因为在大多数情况下,这是人们暗中期望的。您可以通过将set +o pipefail;添加到shell命令之前始终为特定命令停用它。

答案 1 :(得分:2)

某种笨重的解决方案是将$initialString = "Hello, PHP"; $myFunc = function(&$myFunc, $n = 3, $initialString){ if($n >= 0){ $temp = $myFunc($myFunc, $n - 1, $initialString); $initialString .= ", " . $initialString; return $temp; } return $initialString; }; 附加到脚本中。这将使命令始终干净地退出,这是不可接受的。要检查脚本是否实际成功,您可以查询数组变量|| true以确保它包含预期的退出代码:

这个脚本没问题:

${PIPESTATUS[@]}

这不行:

seq 1 10000 | head | grep 1 > test.done || true
echo ${PIPESTATUS[@]}
141 0 0