當前位置: 首頁>>代碼示例>>Python>>正文


Python kqml.KQMLList類代碼示例

本文整理匯總了Python中kqml.KQMLList的典型用法代碼示例。如果您正苦於以下問題:Python KQMLList類的具體用法?Python KQMLList怎麽用?Python KQMLList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了KQMLList類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: respond_find_disease_targets

    def respond_find_disease_targets(self, content):
        """Response content to find-disease-targets request."""
        try:
            disease_arg = content.gets('disease')
            disease = get_disease(ET.fromstring(disease_arg))
        except Exception as e:
            logger.error(e)
            reply = self.make_failure('INVALID_DISEASE')
            return reply

        if not trips_isa(disease.disease_type, 'ont::cancer'):
            reply = self.make_failure('DISEASE_NOT_FOUND')
            return reply

        logger.debug('Disease: %s' % disease.name)

        try:
            mut_protein, mut_percent, agents = \
                self.dtda.get_top_mutation(disease.name)
        except DiseaseNotFoundException:
            reply = self.make_failure('DISEASE_NOT_FOUND')
            return reply

        # TODO: get functional effect from actual mutations
        # TODO: add list of actual mutations to response (get from agents)
        # TODO: get fraction not percentage from DTDA (edit get_top_mutation)
        reply = KQMLList('SUCCESS')
        protein = KQMLList()
        protein.set('name', mut_protein)
        protein.set('hgnc', mut_protein)
        reply.set('protein', protein)
        reply.set('prevalence', '%.2f' % (mut_percent/100.0))
        reply.set('functional-effect', 'ACTIVE')
        return reply
開發者ID:bgyori,項目名稱:bioagents,代碼行數:34,代碼來源:dtda_module.py

示例2: send_display_figure

 def send_display_figure(self, path):
     msg = KQMLPerformative('tell')
     content = KQMLList('display-image')
     content.set('type', 'simulation')
     content.sets('path', path)
     msg.set('content', content)
     self.send(msg)
開發者ID:bgyori,項目名稱:bioagents,代碼行數:7,代碼來源:tra_module.py

示例3: receive_request

    def receive_request(self, msg, content):
        """Handle request messages and respond.

        If a "request" message is received, decode the task and the content
        and call the appropriate function to prepare the response. A
        reply_content message is then sent back.
        """
        try:
            content = msg.get('content')
            task_str = content.head().upper()
            logger.info(task_str)
        except Exception as e:
            logger.error('Could not get task string from request.')
            logger.error(e)
            return self.error_reply(msg, 'Invalid task')
        try:
            if task_str == 'INDRA-TO-NL':
                reply_content = self.respond_indra_to_nl(content)
            else:
                return self.error_reply(msg, 'Unknown task ' + task_str)
        except Exception as e:
            logger.error('Failed to perform task.')
            logger.error(e)
            reply_content = KQMLList('FAILURE')
            reply_content.set('reason', 'NL_GENERATION_ERROR')

        return self.reply_with_content(msg, reply_content)
開發者ID:bgyori,項目名稱:bioagents,代碼行數:27,代碼來源:bionlg_module.py

示例4: create_message

 def create_message(self):
     target = ekb_kstring_from_text(self.target)
     drug = ekb_kstring_from_text(self.drug)
     content = KQMLList('IS-DRUG-TARGET')
     content.set('target', target)
     content.set('drug', drug)
     return get_request(content), content
開發者ID:bgyori,項目名稱:bioagents,代碼行數:7,代碼來源:dtda_test.py

示例5: respond_has_qca_path

    def respond_has_qca_path(self, content):
        """Response content to find-qca-path request."""
        target_arg = content.gets('TARGET')
        source_arg = content.gets('SOURCE')
        reltype_arg = content.get('RELTYPE')

        if not source_arg:
            raise ValueError("Source list is empty")
        if not target_arg:
            raise ValueError("Target list is empty")

        target = self._get_term_name(target_arg)
        source = self._get_term_name(source_arg)

        if reltype_arg is None or len(reltype_arg) == 0:
            relation_types = None
        else:
            relation_types = [str(k.data) for k in reltype_arg.data]

        has_path = self.qca.has_path([source], [target])

        reply = KQMLList('SUCCESS')
        reply.set('haspath', 'TRUE' if has_path else 'FALSE')

        return reply
開發者ID:bgyori,項目名稱:bioagents,代碼行數:25,代碼來源:qca_module.py

示例6: response_error

 def response_error(self, error):
     reply_content = KQMLList()
     for e in error:
         error_msg = '"%s"' %\
             str(e).encode('string-escape').replace('"', '\\"')
         reply_content.add(error_msg)
     return self.format_error(reply_content.to_string())
開發者ID:sorgerlab,項目名稱:bioagents,代碼行數:7,代碼來源:kappa_module.py

示例7: make_failure

 def make_failure(self, reason=None, description=None):
     msg = KQMLList('FAILURE')
     if reason:
         msg.set('reason', reason)
     if description:
         msg.sets('description', description)
     return msg
開發者ID:bgyori,項目名稱:bioagents,代碼行數:7,代碼來源:__init__.py

示例8: test_respond_choose_nonsense

def test_respond_choose_nonsense():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE')
    msg_content.sets('ekb-term', ekb_from_text('bagel'))
    res = bs.respond_choose_sense(msg_content)
    print(res)
    assert res.head() == 'SUCCESS'
    assert res.get('agents')[0].gets('ont-type') is None
開發者ID:bgyori,項目名稱:bioagents,代碼行數:8,代碼來源:biosense_test.py

示例9: send_null_provenance

 def send_null_provenance(self, stmt, for_what, reason=''):
     """Send out that no provenance could be found for a given Statement."""
     content_fmt = ('<h4>No supporting evidence found for {statement} from '
                    '{cause}{reason}.</h4>')
     content = KQMLList('add-provenance')
     stmt_txt = EnglishAssembler([stmt]).make_model()
     content.sets('html', content_fmt.format(statement=stmt_txt,
                                             cause=for_what, reason=reason))
     return self.tell(content)
開發者ID:bgyori,項目名稱:bioagents,代碼行數:9,代碼來源:__init__.py

示例10: _get_perf

def _get_perf(text, msg_id):
    """Return a request message for a given text."""
    msg = KQMLPerformative('REQUEST')
    msg.set('receiver', 'READER')
    content = KQMLList('run-text')
    content.sets('text', text)
    msg.set('content', content)
    msg.set('reply-with', msg_id)
    return msg
開發者ID:johnbachman,項目名稱:indra,代碼行數:9,代碼來源:drum_reader.py

示例11: respond_indra_to_nl

 def respond_indra_to_nl(self, content):
     """Return response content to build-model request."""
     stmts_json_str = content.gets('statements')
     stmts = decode_indra_stmts(stmts_json_str)
     txts = assemble_english(stmts)
     txts_kqml = [KQMLString(txt) for txt in txts]
     txts_list = KQMLList(txts_kqml)
     reply = KQMLList('OK')
     reply.set('NL', txts_list)
     return reply
開發者ID:bgyori,項目名稱:bioagents,代碼行數:10,代碼來源:bionlg_module.py

示例12: reply

 def reply(self,):
     reply_msg = KQMLPerformative('reply')
     reply_content = KQMLList()
     for t in self.tests:
         print 'reply {0}'.format(t)
         t_content = t.get_content()
         if t_content:
             reply_content.add(t_content.to_string())
     reply_msg.setParameter(':content', reply_content)
     return reply_msg
開發者ID:sorgerlab,項目名稱:bioagents,代碼行數:10,代碼來源:test_module.py

示例13: respond_test

    def respond_test(self):
        '''
        Response content to version message
        '''
        reply_content = KQMLList()
        version_response = KQMLList.from_string( '' +\
            '(ONT::TELL :content ' +\
            ')')

        reply_content.add(KQMLList(version_response))
        return reply_content
開發者ID:sorgerlab,項目名稱:bioagents,代碼行數:11,代碼來源:test_module.py

示例14: test_respond_get_synonyms

def test_respond_get_synonyms():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('GET-SYNONYMS')
    msg_content.sets('entity', mek1_ekb)
    res = bs.respond_get_synonyms(msg_content)
    assert res.head() == 'SUCCESS'
    syns = res.get('synonyms')
    syn_strs = [s.gets(':name') for s in syns]
    assert 'MAP2K1' in syn_strs
    assert 'MEK1' in syn_strs
    assert 'MKK1' in syn_strs
開發者ID:bgyori,項目名稱:bioagents,代碼行數:11,代碼來源:biosense_test.py

示例15: test_respond_choose_sense_is_member

def test_respond_choose_sense_is_member():
    bs = BioSense_Module(testing=True)
    msg_content = KQMLList('CHOOSE-SENSE-IS-MEMBER')
    msg_content.sets('ekb-term', mek1_ekb)
    msg_content.sets('collection', mek_ekb)
    print(msg_content)
    res = bs.respond_choose_sense_is_member(msg_content)
    print(res)
    print(res.head())
    assert(res.head() == 'SUCCESS')
    assert(res.get('is-member') == 'TRUE')
開發者ID:bgyori,項目名稱:bioagents,代碼行數:11,代碼來源:biosense_test.py


注:本文中的kqml.KQMLList類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。