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


Python KQMLList.append方法代码示例

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


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

示例1: subscribe_tell

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import append [as 别名]
 def subscribe_tell(self, tell_type):
     msg = KQMLPerformative('subscribe')
     content = KQMLList('tell')
     content.append('&key')
     content.set('content', KQMLList.from_string('(%s . *)' % tell_type))
     msg.set('content', content)
     self.send(msg)
开发者ID:pagreene,项目名称:pykqml,代码行数:9,代码来源:kqml_module.py

示例2: subscribe_request

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import append [as 别名]
 def subscribe_request(self, req_type):
     msg = KQMLPerformative('subscribe')
     content = KQMLList('request')
     content.append('&key')
     content.set('content', KQMLList.from_string('(%s . *)' % req_type))
     msg.set('content', content)
     self.send(msg)
开发者ID:pagreene,项目名称:pykqml,代码行数:9,代码来源:kqml_module.py

示例3: _get_drug_kqml

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import append [as 别名]
 def _get_drug_kqml(drug_list):
     drugs = KQMLList()
     for dn, pci in drug_list:
         drug = KQMLList()
         drug.sets('name', dn.replace(' ', '-'))
         if pci:
             drug.sets('pubchem_id', pci)
         drugs.append(drug)
     return drugs
开发者ID:bgyori,项目名称:bioagents,代码行数:11,代码来源:dtda_module.py

示例4: respond_get_common

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import append [as 别名]
    def respond_get_common(self, content):
        """Find the common up/down streams of a protein."""
        # TODO: This entire function could be part of the MSA.
        if not CAN_CHECK_STATEMENTS:
            return self.make_failure(
                'NO_KNOWLEDGE_ACCESS',
                'Cannot access the database through the web api.'
                )
        genes_ekb = content.gets('genes')
        agents = _get_agents(genes_ekb)
        if len(agents) < 2:
            return self.make_failure('NO_TARGET',
                                     'Only %d < 2 agents given.' % len(agents))

        direction = content.gets('up-down')
        logger.info("Got genes: %s and direction %s." % (agents, direction))

        # Choose some parameters based on direction.
        if direction == 'ONT::MORE':
            method = 'common_upstreams'
            prefix = 'up'
        elif direction == 'ONT::SUCCESSOR':
            method = 'common_downstreams'
            prefix = 'down'
        else:
            # TODO: With the new MSA we could handle common neighbors.
            return self.make_failure("UNKNOWN_ACTION", direction)

        # Find the commonalities.
        try:
            finder = self.msa.find_mechanisms(method, *agents)
        except EntityError as e:
            return self.make_failure("MISSING_TARGET", e.args[0])

        # Get post statements to provenance.
        if len(agents) > 2:
            name_list = ', '.join(ag.name for ag in agents[:-1]) + ','
        else:
            name_list = agents[0].name
        name_list += ' and ' + agents[-1].name
        msg = ('%sstreams of ' % prefix).capitalize() + name_list
        self.send_provenance_for_stmts(finder.get_statements(), msg,
                                       ev_counts=finder.get_ev_totals())

        # Create the reply
        resp = KQMLPerformative('SUCCESS')
        gene_list = KQMLList()
        for gene in finder.get_common_entities():
            gene_list.append(gene)
        resp.set('commons', gene_list)
        resp.sets('prefix', prefix)
        return resp
开发者ID:bgyori,项目名称:bioagents,代码行数:54,代码来源:msa_module.py

示例5: get_kagent

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import append [as 别名]
def get_kagent(agent_tuple, term_id=None):
    agent, ont_type, urls = agent_tuple
    db_refs = '|'.join('%s:%s' % (k, v) for k, v in
                       agent.db_refs.items())
    kagent = KQMLList(term_id) if term_id else KQMLList()
    kagent.sets('name', agent.name)
    kagent.sets('ids', db_refs)
    url_parts = [KQMLList([':name', KQMLString(k),
                           ':dblink', KQMLString(v)])
                 for k, v in urls.items()]
    url_list = KQMLList()
    for url_part in url_parts:
        url_list.append(url_part)
    kagent.set('id-urls', url_list)
    kagent.set('ont-type', ont_type)
    return kagent
开发者ID:bgyori,项目名称:bioagents,代码行数:18,代码来源:biosense_module.py

示例6: respond_get_synonyms

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import append [as 别名]
 def respond_get_synonyms(self, content):
     """Respond to a query looking for synonyms of a protein."""
     ekb = content.gets('entity')
     try:
         synonyms = self.bs.get_synonyms(ekb)
     except InvalidAgentError:
         msg = self.make_failure('INVALID_AGENT')
     except SynonymsUnknownError:
         msg = self.make_failure('SYNONYMS_UNKNOWN')
     else:
         syns_kqml = KQMLList()
         for s in synonyms:
             entry = KQMLList()
             entry.sets(':name', s)
             syns_kqml.append(entry)
         msg = KQMLList('SUCCESS')
         msg.set('synonyms', syns_kqml)
     return msg
开发者ID:bgyori,项目名称:bioagents,代码行数:20,代码来源:biosense_module.py

示例7: respond_find_drug_targets

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import append [as 别名]
    def respond_find_drug_targets(self, content):
        """Response content to find-drug-target request."""
        try:
            drug_arg = content.gets('drug')
            drug = self._get_agent(drug_arg)
        except Exception as e:
            return self.make_failure('INVALID_DRUG')
        logger.info('DTDA looking for targets of %s' % drug.name)
        drug_targets = self.dtda.find_drug_targets(drug)
        all_targets = sorted(list(set(drug_targets)))

        reply = KQMLList('SUCCESS')
        targets = KQMLList()
        for target_name in all_targets:
            target = KQMLList()
            target.sets('name', target_name)
            targets.append(target)
        reply.set('targets', targets)
        return reply
开发者ID:bgyori,项目名称:bioagents,代码行数:21,代码来源:dtda_module.py

示例8: respond_model_undo

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import append [as 别名]
    def respond_model_undo(self, content):
        """Return response content to model-undo request."""
        res = self.mra.model_undo()
        no_display = content.get('no-display')
        model_id = res.get('model_id')
        # Start a SUCCESS message
        msg = KQMLPerformative('SUCCESS')
        # Add the model id
        msg.set('model-id', 'NIL' if model_id is None else str(model_id))
        # Add the INDRA model json
        model = res.get('model')

        # Handle empty model
        if not model:
            self.send_clean_model()

        model_msg = encode_indra_stmts(model)
        msg.sets('model', model_msg)
        # Get the action and add it to the message
        action = res.get('action')
        actionl = KQMLList()
        # Here we handle no action as effectively an empty remove action
        if action['action'] in ('no_op', 'remove_stmts'):
            actionl.append('remove_stmts')
            actionl.sets(
                'statements',
                encode_indra_stmts(action['statements'])
                )
        msg.set('action', actionl)

        # Add the diagram
        diagrams = res.get('diagrams')
        if not no_display:
            if diagrams:
                rxn_diagram = diagrams.get('reactionnetwork')
                if rxn_diagram:
                    msg.sets('diagram', rxn_diagram)
                self.send_display_model(diagrams)
        return msg
开发者ID:bgyori,项目名称:bioagents,代码行数:41,代码来源:mra_module.py

示例9: say

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import append [as 别名]
 def say(self, message):
     """Say something to the user."""
     msg = KQMLList('say')
     msg.append(KQMLString(message))
     self.request(msg)
开发者ID:bgyori,项目名称:bioagents,代码行数:7,代码来源:__init__.py


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