def __init__(self, argv): super(TRA_Module, self).__init__(argv) self.tasks = ["SATISFIES-PATTERN"] parser = argparse.ArgumentParser() parser.add_argument("--kappa_url", help="kappa endpoint") args = parser.parse_args() if args.kappa_url: self.kappa_url = args.kappa_url else: logger.error("No Kappa URL given.") sys.exit() # Generate a basic model as placeholder (for testing) # model_text = 'MAPK1 binds MAP2K1.' # pa = PysbAssembler() # pa.add_statements(trips.process_text(model_text).statements) # self.model = pa.make_model() # Send subscribe messages for task in self.tasks: msg_txt = "(subscribe :content (request &key :content (%s . *)))" % task self.send(KQMLPerformative.from_string(msg_txt)) # Instantiate a singleton TRA agent try: kappa = kappa_client.KappaRuntime(self.kappa_url) self.tra = TRA(kappa) except Exception as e: logger.error("Could not instantiate TRA with Kappa service.") self.tra = None self.ready() super(TRA_Module, self).start()
def get_content(self): """Convert the entry to a message.""" if not self.content: maxlen = 100000 if len(self.message) <= maxlen: self.content = KQMLPerformative.from_string(self.message) else: raise KQMLException('Message is longer than %d characters' % maxlen) return self.content
def __init__(self, argv): super(MRA_Module, self).__init__(argv) self.tasks = ["BUILD-MODEL", "EXPAND-MODEL", "MODEL-HAS-MECHANISM"] self.models = [] for task in self.tasks: msg_txt = "(subscribe :content (request &key :content (%s . *)))" % task self.send(KQMLPerformative.from_string(msg_txt)) # Instantiate a singleton MRA agent self.mra = MRA() self.ready() super(MRA_Module, self).start()
def performative(string: str) -> KQMLPerformative: """Wrapper for KQMLPerformative.from_string, produces a performative object from a KQML string Arguments: string (str): well formed KQML performative as a string Returns: KQMLPerformative """ return KQMLPerformative.from_string(string)
def init(self): ''' Initialize TRIPS module ''' super(Test_Module, self).init() # Send subscribe messages for task, subtasks in self.tasks.iteritems(): for subtask in subtasks: msg_txt = '(subscribe :content (request &key :content ' +\ '(%s &key :content (%s . *))))' % (task, subtask) self.send(KQMLPerformative.from_string(msg_txt)) # Send ready message self.ready() return None
def __init__(self, argv): # Call the constructor of TripsModule super(DTDA_Module, self).__init__(argv) self.tasks = ['IS-DRUG-TARGET', 'FIND-TARGET-DRUG', 'FIND-DISEASE-TARGETS', 'FIND-TREATMENT'] # Send subscribe messages for task in self.tasks: msg_txt =\ '(subscribe :content (request &key :content (%s . *)))' % task self.send(KQMLPerformative.from_string(msg_txt)) # Instantiate a singleton DTDA agent self.dtda = DTDA() # Send ready message self.ready() super(DTDA_Module, self).start()
def __init__(self, argv): super(MEA_Module, self).__init__(argv) self.tasks = ["SIMULATE-MODEL"] parser = argparse.ArgumentParser() parser.add_argument("--kappa_url", help="kappa endpoint") args = parser.parse_args() if args.kappa_url: self.kappa_url = args.kappa_url # Send subscribe messages for task in self.tasks: msg_txt = "(subscribe :content (request &key :content (%s . *)))" % task self.send(KQMLPerformative.from_string(msg_txt)) # Instantiate a singleton MEA agent self.mea = MEA() self.ready() super(MEA_Module, self).start()
def __init__(self, argv): # Call the constructor of TripsModule super(Kappa_Module, self).__init__(argv) self.tasks = ['KAPPA-VERSION', 'KAPPA-PARSE', 'KAPPA-START', 'KAPPA-STATUS', 'KAPPA-STOP'] parser = argparse.ArgumentParser() parser.add_argument("--kappa_url", help="kappa endpoint") args = parser.parse_args() if args.kappa_url: self.kappa_url = args.kappa_url else: logger.error('No Kappa URL given.') sys.exit() # Send subscribe messages for task in self.tasks: msg_txt =\ '(subscribe :content (request &key :content (%s . *)))' % task self.send(KQMLPerformative.from_string(msg_txt)) # Instantiate a kappa runtime self.kappa = KappaRuntime(self.kappa_url) # Send ready message self.ready() super(Kappa_Module, self).start()
def performative(string: str) -> KQMLPerformative: return KQMLPerformative.from_string(string)
def get_perf(self, msg_id, msg_txt): msg_txt = msg_txt.replace('\\n', '\n') perf = KQMLPerformative.from_string( '(request :reply-with IO-%d :content %s)' % (msg_id, msg_txt)) return perf