我有一个cluster.json文件,如下所示:
{
"__default__":
{
"queue":"normal",
"memory":"12288",
"nCPU":"1",
"name":"{rule}_{wildcards.sample}",
"o":"logs/cluster/{wildcards.sample}/{rule}.o",
"e":"logs/cluster/{wildcards.sample}/{rule}.e",
"jvm":"10240m"
},
"aln_pe":
{
"memory":"61440",
"nCPU":"16"
},
"GenotypeGVCFs":
{
"jvm":"102400m",
"memory":"122880"
}
}在我的snakefile中,我有一些规则,它们试图以参数形式访问cluster_config对象
params:
memory=cluster_config['__default__']['jvm']但这会给我一个“KeyError”
KeyError in line 27 of home/bwubb/projects/Germline/S0330901/haplotype.snake:
'__default__'这与'__default__‘是一个特殊的对象有关吗?它在一个视觉上很吸引人的字典中打印,其他的都被标记为OrderDict,但当我查看json时,它看起来是一样的。
如果我的json没有问题,那么我应该避免访问'__default__‘吗?
发布于 2017-10-14 00:25:53
默认值是通过关键字"cluster“访问的,而不是
__default__ See here in this example in the tutorial:
{
"__default__" :
{
"account" : "my account",
"time" : "00:15:00",
"n" : 1,
"partition" : "core"
},
"compute1" :
{
"time" : "00:20:00"
}
}The JSON list in the URL above and listed above is the one being accessed in this example. It's unfortunate they are not on the same page. To access time, J.K. uses the following call.
#!python
#!/usr/bin/env python3
import os
import sys
from snakemake.utils import read_job_properties
jobscript = sys.argv[1]
job_properties = read_job_properties(jobscript)
# do something useful with the threads
threads = job_properties[threads]
# access property defined in the cluster configuration file (Snakemake >=3.6.0)
job_properties["cluster"]["time"]
os.system("qsub -t {threads} {script}".format(threads=threads, script=jobscript))https://stackoverflow.com/questions/46733981
复制相似问题