2017-10-13 28 views
1

我有一个cluster.json文件看起来像这样:正确访问cluster_config“__default__价值观

{ 
    "__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我有尝试访问他们的PARAMS的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__'?

回答

0

的默认值是通过关键字 “集群” 访问,不

__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)) 
+0

谢谢你的答复。当我改变 '内存= cluster_config [“集群”] [“JVM”]' 我即使添加了read_job_properties后遇到了一个关键的错误为“集群” – bwubb

+0

我为我的困惑表示歉意,但它仍然不是清楚我做错了什么。 我的job_properties是None,即使我专门说明了我的jobcript。 另外,我不明白为什么我可以通过cluster_config ['rule']访问其他参数,但不能以类似的方式访问其他参数。 – bwubb

+0

我实际上并不知道cluster_config可以工作。奇怪的是,为什么你想要在你的规则中访问集群级别的变量。将集群级别配置和规则级别配置分开是不是更好?您希望将群集请求的内存量与您正在运行的(Java?)程序请求的内存量配对?像-Xmx10240m? – TBoyarski