def bnet_to_maboss(sbml_filename, cfg_filename=None): from .gsparser import load bnd_filename = new_output_file("bnd") default_cfg_filename = new_output_file("cfg") bnet_to_bnd_and_cfg(sbml_filename, bnd_filename, default_cfg_filename) sim = load( bnd_filename, cfg_filename if cfg_filename is not None else default_cfg_filename) if cfg_filename is None: for node in sim.network: sim.network.set_istate(node, [1, 0]) return sim
def to_booleannet(model, mode='async'): bnetfile = new_output_file("booleannet") assert save(model, bnetfile, "booleannet") with open(bnetfile, 'r') as f: rules = f.read() rules = rules.replace('#BOOLEAN RULES', '') boolean2 = import_colomoto_tool("boolean2") return boolean2.Model(rules, mode)
def to_pint(model, simplify=True): anfile = new_output_file("an") assert save(model, anfile, "an") pypint = import_colomoto_tool("pypint") an = pypint.load(anfile) if simplify: an = an.simplify() return an
def to_minibn(maboss_model): from colomoto import minibn bnet_filename = new_output_file("bnet") with open(bnet_filename, "w") as bnet_file: for node, rule in maboss_model.get_logical_rules().items(): bnet_file.write("%s, %s\n" % (node, rule)) return minibn.BooleanNetwork.load(bnet_filename)
def to_biolqm(maboss_model): biolqm = import_colomoto_tool("biolqm") bnet_filename = new_output_file("bnet") with open(bnet_filename, "w") as bnet_file: for node, rule in maboss_model.get_logical_rules().items(): bnet_file.write("%s, %s\n" % (node, rule)) return biolqm.load(bnet_filename)
def to_ginsim(model): """ Convert a bioLQM model into an equivalent GINsim model using the :py:mod:`ginsim` Python module. Please note that no layout is set for the regulatory graph. """ import_colomoto_tool("ginsim") ginml_file = new_output_file("ginml") assert save(model, ginml_file, "ginml") return ginsim.load(ginml_file)
def to_minibn(model): from colomoto import minibn if model.isBoolean(): fmt = "bnet" cls = minibn.BooleanNetwork else: fmt = "mnet" cls = minibn.MultiValuedNetwork bnfile = new_output_file(fmt) assert save(model, bnfile, fmt) with open(bnfile) as data: return cls(data)
def to_minibn(model, simplify=True, ensure_boolean=False): from colomoto import minibn if ensure_boolean or model.isBoolean(): fmt = "bnet" cls = minibn.BooleanNetwork else: fmt = "mnet" cls = minibn.MultiValuedNetwork bnfile = new_output_file(fmt) assert save(model, bnfile, fmt) with open(bnfile) as data: bn = cls(data) if simplify and hasattr(bn, "simplify"): bn = bn.simplify() return bn
def to_nusmv(lrg, update_mode="async"): assert update_mode in ["async", "sync", "complete"], "Unknown update mode" serv = service("NuSMV") cfg = serv.getConfig(lrg.getModel()) ## configure update mode d_update = { "async": cfg.CFG_ASYNC, "sync": cfg.CFG_SYNC, "complete": cfg.CFG_COMPLETE, } cfg.setUpdatePolicy(d_update[update_mode]) smvfile = new_output_file("smv") serv.run(cfg, smvfile) from colomoto.modelchecking import ColomotoNuSMV return ColomotoNuSMV(smvfile, nusmv_var_state)
def to_nusmv(lrg, update_mode="async"): assert update_mode in ["async", "sync", "complete"], "Unknown update mode" serv = service("NuSMV") cfg = serv.getConfig(lrg.getModel()) ## configure update mode d_update = { "async": cfg.CFG_ASYNC, "sync": cfg.CFG_SYNC, "complete": cfg.CFG_COMPLETE, } cfg.setUpdatePolicy(d_update[update_mode]) ## configure input nodes sinit = japi.gs.associated(lrg, "initialState", True) for inputNode in sinit.getInputNodes(): cfg.addFixedInput(str(inputNode)) smvfile = new_output_file("smv") serv.run(cfg, smvfile) from colomoto.modelchecking import ColomotoNuSMV return ColomotoNuSMV(smvfile, nusmv_var_state)
def to_pyboolnet(model): bnetfile = new_output_file("bnet") assert save(model, bnetfile, "bnet") PyBoolNet = import_colomoto_tool("PyBoolNet") bn = PyBoolNet.FileExchange.bnet2primes(bnetfile) return bn
def to_maboss(model): maboss = import_colomoto_tool("maboss") maboss_file = new_output_file("bnd") assert save(model, maboss_file, "bnd") return maboss.load(maboss_file, "%s.cfg" % maboss_file)
def to_biolqm(self): bnfile = new_output_file(ext=self.biolqm_format) with open(bnfile, "w") as f: f.write(self.source()) biolqm = import_colomoto_tool("biolqm") return biolqm.load(bnfile)
def biolqm_import(biolqm, lqm): bnfile = new_output_file(self.biolqm_format) assert biolqm.save(lqm, bnfile) with open(bnfile) as fp: self.import_data(fp) return True