例如,我有 python 脚本snakemake.py
:
from snakemake import snakemake
cfg={'a':'aaaa', 'b':'bbbb', 'c': 'cccc'}
snakemake(
'Snakefile',
targets=['all'],
printshellcmds=True,
forceall=True,
config=cfg,
# configfile=config,
keep_target_files=True,
keep_logger=False)
Snakefile
看起来像这样:
print(config)
print('------------------------------------------------------------------------------------------')
rule a:
output:
'a.out'
shell:
"echo %s ; "
"touch {output[0]}" % config['a']
rule b:
output:
'b.out'
shell:
"echo %s ; touch {output[0]}" % config['b']
rule c:
output:
'c.out'
run:
print(config['c'])
import os
os.system('touch ' + output[0])
rule all:
input:
'a.out', 'b.out', 'c.out'
当我运行时python snakemake.py
,我遇到了一个错误:
{'a': 'aaaa', 'c': 'cccc', 'b': 'bbbb'}
------------------------------------------------------------------------------------------
Provided cores: 1
Rules claiming more threads will be scaled down.
Job counts:
count jobs
1 a
1 all
1 b
1 c
4
rule c:
output: c.out
jobid: 1
{}
------------------------------------------------------------------------------------------
KeyError in line 8 of /Users/zech/Desktop/snakemake/Snakefile:
'a'
File "/Users/zech/Desktop/snakemake/Snakefile", line 8, in <module>
Will exit after finishing currently running jobs.
Exiting because a job execution failed. Look above for error message
当我删除c.out
fromrule all
时,它运行得非常好。看起来run
规则重置中的每个块都config
传递给snakemake
函数为空?这不是一种奇怪的行为吗?有什么解决方法吗?
我在最新的 OSX 上使用 snakemake 版本 3.11.2(从 anaconda 的 bioconda 频道安装)。
注意:当我运行 snakemake command line 时它运行良好snakemake -p --keep-target-files all --config a="aaaa" b="bbb" c="cccc"
。所以这看起来像是 API 的一个问题。