예제 #1
0
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
예제 #2
0
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)
예제 #3
0
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
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
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)
예제 #7
0
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)
예제 #8
0
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
예제 #9
0
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)
예제 #10
0
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)
예제 #11
0
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
예제 #12
0
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)
예제 #13
0
 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)
예제 #14
0
 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