当前位置: 首页>>代码示例>>Python>>正文


Python Service.list_manager方法代码示例

本文整理汇总了Python中intermine.webservice.Service.list_manager方法的典型用法代码示例。如果您正苦于以下问题:Python Service.list_manager方法的具体用法?Python Service.list_manager怎么用?Python Service.list_manager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在intermine.webservice.Service的用法示例。


在下文中一共展示了Service.list_manager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plot_go_vs_p

# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import list_manager [as 别名]
def plot_go_vs_p(list_name):
    """
    A function to plot GO Term vs P-value with label of gene count on each bar
    ================================================
    example:

        >>>from intermine import query_manager as qm
        >>>b.plot_go_vs_p("PL_obesityMonogen_ORahilly09")

    """
    link = "http://registry.intermine.org/service/instances/" + mine
    r = requests.get(link)

    dict = json.loads(r.text)
    url = dict["instance"]["url"]
    service = Service(url)

    lm = service.list_manager()
    store = lm.get_list(name=list_name)
    r = store.calculate_enrichment(widget="go_enrichment_for_gene")

    gene_count = []
    identifier = []
    p_value = []
    object_count = 0
    for i in r:
        if object_count < 5:
            gene_count.append(i.matches)
            identifier.append(i.identifier)
            p_value.append(i.p_value)
            object_count = object_count + 1
        else:
            if object_count >= 5:
                break
    y = pd.Series(p_value)
    x = identifier
    # Plot the figure.

    ax = y.plot(kind='bar')
    ax.set_title('GO Term vs p-value (Label: Gene count)')
    ax.set_xlabel('GO Term')
    ax.set_ylabel('p_value')
    ax.set_xticklabels(x, rotation='horizontal')

    rects = ax.patches

    def autolabel(rects, ax):
        i = 0
        for rect in rects:
            x = rect.get_x() + rect.get_width()/2.
            y = rect.get_height()
            ax.annotate(gene_count[i], (x, y), xytext=(0, 5),
                        textcoords="offset points",
                        ha='center', va='bottom')
            i = i+1

    autolabel(ax.patches, ax)

    ax.margins(y=0.1)
    plt.show()
开发者ID:intermine,项目名称:intermine-ws-client.py,代码行数:62,代码来源:bar_chart.py

示例2: attack

# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import list_manager [as 别名]
    def attack(self):
        username = "user-weapon-{0}@noreply.intermine.org".format(self.ident)
        password = "yolo"

        try:
            s = Service(self.service.root, username, password)
            s.deregister(s.get_deregistration_token())
            self.counter.add(3)
        except:
            pass

        s = self.service.register(username, password)
        self.LOG.debug("Registered user " + username)
        self.counter.add(1)

        c = 0
        classes = s.model.classes.values()
        self.counter.add(1)

        classkeys = s._get_json('/classkeys')['classes']
        self.counter.add(1)

        while c == 0:
            table = random.choice(classes)
            if not (table.has_id and table.name in classkeys):
                continue
            query = s.query(table.name).select(classkeys[table.name][0])

            c = query.count()
            self.counter.add(1)

        n = random.randint(1, min(100, c))
        members = random.sample(map(lambda r: r[0], query.rows()), n)
        self.counter.add(1)

        self.LOG.debug("Will construct list of %s with: %r", table.name, members)

        with s.list_manager() as lm:
            l = lm.create_list(members, table.name)
            self.LOG.debug('Created list %s, size: %d', l.name, l.size)
            self.counter.add(1)

        try:
            s.deregister(s.get_deregistration_token())
            self.counter.add(2)
        except:
            pass
开发者ID:alexkalderimis,项目名称:death-by-snoo-snoo,代码行数:49,代码来源:weapons.py


注:本文中的intermine.webservice.Service.list_manager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。