首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >正确访问cluster_config '__default__‘值

正确访问cluster_config '__default__‘值
EN

Stack Overflow用户
提问于 2017-10-14 00:08:34
回答 1查看 123关注 0票数 1

我有一个cluster.json文件,如下所示:

代码语言:javascript
复制
{
    "__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对象

代码语言:javascript
复制
params:
  memory=cluster_config['__default__']['jvm']

但这会给我一个“KeyError”

代码语言:javascript
复制
KeyError in line 27 of home/bwubb/projects/Germline/S0330901/haplotype.snake:
'__default__'

这与'__default__‘是一个特殊的对象有关吗?它在一个视觉上很吸引人的字典中打印,其他的都被标记为OrderDict,但当我查看json时,它看起来是一样的。

如果我的json没有问题,那么我应该避免访问'__default__‘吗?

EN

回答 1

Stack Overflow用户

发布于 2017-10-14 00:25:53

默认值是通过关键字"cluster“访问的,而不是

代码语言:javascript
复制
__default__ 

See here in this example in the tutorial:

代码语言:javascript
复制
{
"__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.

代码语言:javascript
复制
#!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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46733981

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档