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


Python KQMLList.add方法代码示例

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


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

示例1: response_error

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import add [as 别名]
 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,代码行数:9,代码来源:kappa_module.py

示例2: reply

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import add [as 别名]
 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,代码行数:12,代码来源:test_module.py

示例3: respond_satisfies_pattern

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import add [as 别名]
    def respond_satisfies_pattern(self, content_list):
        """
        Response content to satisfies-pattern request
        """
        model_token = content_list.get_keyword_arg(":model")
        pattern_lst = content_list.get_keyword_arg(":pattern")
        conditions_lst = content_list.get_keyword_arg(":conditions")

        try:
            model_str = str(model_token)
            model = decode_model(model_str)
        except Exception as e:
            logger.error(e)
            reply_content = KQMLList.from_string("(FAILURE :reason INVALID_MODEL)")
            return reply_content

        try:
            pattern = get_temporal_pattern(pattern_lst)
        except InvalidTimeUnitError as e:
            logger.error(e)
            reply_content = KQMLList.from_string("(FAILURE :reason INVALID_TIME_LIMIT)")
            return reply_content
        except Exception as e:
            logger.error(e)
            reply_content = KQMLList.from_string("(FAILURE :reason INVALID_PATTERN)")
            return reply_content
        if conditions_lst is None:
            conditions = None
        else:
            try:
                conditions = []
                for condition_lst in conditions_lst:
                    condition = get_molecular_condition(condition_lst)
                    conditions.append(condition)
            except Exception as e:
                logger.error(e)
                msg_str = "(FAILURE :reason INVALID_CONDITIONS)"
                reply_content = KQMLList.from_string(msg_str)
                return reply_content

        try:
            sat_rate, num_sim = self.tra.check_property(model, pattern, conditions)
        except SimulatorError as e:
            logger.error(e)
            reply_content = KQMLList.from_string("(FAILURE :reason KAPPA_FAILURE)")
            return reply_content
        except Exception as e:
            logger.error(e)
            reply_content = KQMLList.from_string("(FAILURE :reason INVALID_PATTERN)")
            return reply_content

        reply_content = KQMLList()
        msg_str = "(:satisfies-rate %.1f :num-sim %d)" % (sat_rate, num_sim)
        reply_content.add("SUCCESS :content %s" % msg_str)
        return reply_content
开发者ID:sorgerlab,项目名称:bioagents,代码行数:57,代码来源:tra_module.py

示例4: respond_test

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import add [as 别名]
    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,代码行数:13,代码来源:test_module.py

示例5: respond_simulate_model

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import add [as 别名]
    def respond_simulate_model(self, content_list):
        """
        Response content to simulate-model request
        """
        model_str = content_list.get_keyword_arg(":model")
        try:
            # model_str = model_str.to_string()
            model = self.decode_model(model_str)
        except InvalidModelDescriptionError as e:
            logger.error(e)
            reply_content = KQMLList.from_string("(FAILURE :reason INVALID_MODEL)")
            return reply_content
        except Exception as e:
            logger.error(e)
            reply_content = KQMLList.from_string("(FAILURE :reason INVALID_MODEL)")
            return reply_content

        target_entity = content_list.get_keyword_arg(":target_entity")
        if target_entity is not None:
            target_entity = target_entity.to_string()[1:-1]
        else:
            reply_content = KQMLList.from_string("(FAILURE :reason MISSING_PARAMETER)")
            return reply_content
        target_pattern = content_list.get_keyword_arg(":target_pattern")
        if target_pattern is not None:
            target_pattern = target_pattern.to_string().lower()
        else:
            reply_content = KQMLList.from_string("(FAILURE :reason MISSING_PARAMETER)")
            return reply_content
        condition_entity = content_list.get_keyword_arg(":condition_entity")
        if condition_entity is not None:
            condition_entity = condition_entity.to_string()[1:-1]
        condition_type = content_list.get_keyword_arg(":condition_type")
        if condition_type is not None:
            condition_type = condition_type.to_string().lower()

        self.get_context(model)
        if condition_entity is None:
            target_match = self.mea.check_pattern(model, target_entity, target_pattern)
        else:
            target_match = self.mea.compare_conditions(
                model, target_entity, target_pattern, condition_entity, condition_type
            )
        target_match_str = "TRUE" if target_match else "FALSE"
        reply_content = KQMLList()
        reply_content.add("SUCCESS :content (:target_match %s)" % target_match_str)
        return reply_content
开发者ID:sorgerlab,项目名称:bioagents,代码行数:49,代码来源:mea_module.py

示例6: respond_find_treatment

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import add [as 别名]
    def respond_find_treatment(self, content_list):
        '''
        Response content to find-treatment request
        '''
        reply_content = KQMLList()
        #TODO: eliminate code duplication here
        disease_arg = content_list.get_keyword_arg(':disease')
        try:
            disease = self.get_disease(disease_arg)
        except Exception as e:
            logger.error(e)
            msg_str = '(FAILURE :reason INVALID_DISEASE)'
            reply_content = KQMLList.from_string(msg_str)
            return reply_content

        if disease.disease_type != 'cancer':
            reply_content.add('FAILURE :reason DISEASE_NOT_FOUND')
            return reply_content

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

        try:
            mut_protein, mut_percent = \
                self.dtda.get_top_mutation(disease.name)
        except DiseaseNotFoundException:
            reply_content.add('FAILURE :reason DISEASE_NOT_FOUND')
            return reply_content

        # TODO: get functional effect from actual mutations
        # TODO: add list of actual mutations to response
        # TODO: get fraction not percentage from DTDA
        reply_content.add(KQMLList.from_string(
                '(SUCCESS ' +
                ':protein (:name %s :hgnc %s) ' % (mut_protein, mut_protein) +
                ':prevalence %.2f ' % (mut_percent/100.0) +
                ':functional-effect ACTIVE)'))

        # Try to find a drug
        drug_names, chebi_ids = self.dtda.find_target_drugs(mut_protein)
        drug_list_str = ''
        for dn, ci in zip(drug_names, chebi_ids):
            if ci is None:
                drug_list_str += '(:name %s) ' % dn.encode('ascii', 'ignore')
            else:
                drug_list_str += '(:name %s :chebi_id %s) ' % (dn, ci)
        reply_content.add(KQMLList.from_string(
            '(SUCCESS :drugs (' + drug_list_str + '))'))

        return reply_content
开发者ID:sorgerlab,项目名称:bioagents,代码行数:51,代码来源:dtda_module.py

示例7: respond_is_drug_target

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import add [as 别名]
 def respond_is_drug_target(self, content_list):
     '''
     Response content to is-drug-target request
     '''
     drug_arg = content_list.get_keyword_arg(':drug')
     drug = drug_arg[0].to_string()
     target_arg = content_list.get_keyword_arg(':target')
     target = self._get_target(target_arg)
     target_name = target.name
     reply_content = KQMLList()
     try:
         is_target = self.dtda.is_nominal_drug_target(drug, target_name)
     except DrugNotFoundException:
         reply_content.add('FAILURE :reason DRUG_NOT_FOUND')
         return reply_content
     status = 'SUCCESS'
     if is_target:
         is_target_str = 'TRUE'
     else:
         is_target_str = 'FALSE'
     msg_str = '%s :is-target %s' %\
               (status, is_target_str)
     reply_content.add(msg_str)
     return reply_content
开发者ID:sorgerlab,项目名称:bioagents,代码行数:26,代码来源:dtda_module.py

示例8: render_status

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import add [as 别名]
def render_status(status):
    reply_content = KQMLList()
    reply_content.add(":status")
    if 'plot' in status:
        plot_data = status['plot']
        plot = KQMLList()
        plot.add(':plot')
        if 'legend' in plot_data:
            legend = KQMLList()
            legend.add(':legend')
            for label in plot_data['legend']:
                legend.add('"'+label+'"')
            plot.add(legend)
        if 'observables' in plot_data:
            observables = KQMLList()
            observables.add(':observables')
            for o in plot_data['observables']:
                observation = KQMLList()
                observation.add(':observation')
                if 'time' in o:
                    time = KQMLList()
                    time.add(':time')
                    time.add(render_value(o['time']))
                    observation.add(time)
                if 'values' in o:
                    values = KQMLList()
                    values.add(':values')
                    for f in o['values']:
                        values.add(render_value(f))
                    observation.add(values)
                observables.add(observation)
            plot.add(observables)
        reply_content.add(plot)
    if 'tracked_events' in status:
        tracked_events = KQMLList()
        tracked_events.add(':tracked_events')
        tracked_events.add(render_value(status['tracked_events']))
        plot.add(tracked_events)
    if 'is_running' in status:
        is_running = KQMLList()
        is_running.add(':is_running')
        is_running.add(render_value(status['is_running']))
        plot.add(is_running)
    if 'event_percentage' in status:
        event_percentage = KQMLList()
        event_percentage.add(':event_percentage')
        event_percentage.add(render_value(status['event_percentage']))
        plot.add(event_percentage)
    if 'time_percentage' in status:
        time_percentage = KQMLList()
        time_percentage.add(':time_percentage')
        time_percentage.add(render_value(status['time_percentage']))
        plot.add(time_percentage)
    if 'time' in status:
        time = KQMLList()
        time.add(':time')
        time.add(render_value(status['time']))
        plot.add(time)
    if 'event' in status:
        event = KQMLList()
        event.add(':event')
        event.add(render_value(status['event']))
        plot.add(event)
    # trips is not happy with this not sure why
    # if 'log_messages':
    #     log_messages = KQMLList()
    #     log_messages.add(':log_messages')
    #     for message in status['log_messages']:
    #         log_messages.add("'"+render_value(message)+"'")
    #     plot.add(log_messages)
    return reply_content
开发者ID:sorgerlab,项目名称:bioagents,代码行数:73,代码来源:kappa_module.py

示例9: get_content

# 需要导入模块: from kqml import KQMLList [as 别名]
# 或者: from kqml.KQMLList import add [as 别名]
 def get_content(self):
     reply_content = KQMLList()
     if self.get_actual():
         actual_string = self.get_actual().to_string()
         expected_string = self.get_expected().to_string()
         print 'get_content:actual_string {0}'.format(actual_string)
         print 'get_content:expected_string {0}'.format(expected_string)
         if expected_string in actual_string:
             return None
         else:
             reply_content.add(":request")
             reply_content.add(self.get_request())
             reply_content.add(":expected")
             reply_content.add(self.get_expected())                
             reply_content.add(":actual")
             reply_content.add(self.get_actual())
     else:
         reply_content.add(":request")
         reply_content.add(self.get_request())
         reply_content.add(":noresponse")
     return reply_content
开发者ID:sorgerlab,项目名称:bioagents,代码行数:23,代码来源:test_module.py


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