def test_launch_model(): from models import readREINfile from launch_model import model2igraph, launch_model from grn_solver import grn_solver from grn_inference import getState print("------- START TEST") print("Test model2igraph:") print(">>> With non-coloured nodes:") C = ["Gene_" + str(i) for i in range(3)] Idef = [[C[1], C[2], "+"], [C[0], C[2], "-"]] Iopt = [[C[0], C[0], "+"], [C[1], C[0], "+"], [C[2], C[1], "-"]] resList = [[["Is", "011"]] + [["R", 10]]*3] P = [[]*3] model2igraph(0, resList, C, Idef, Iopt, P, plotIt=True, verbose=True) print(">>> With coloured nodes:") P = [["-", "+"], ["-"], ["+"]] model2igraph(0, resList, C, Idef, Iopt, P, plotIt=True, verbose=True) print("Test launch_model:") print("On toy model:") [C, CRM, length, Idef, Iopt, R, E, typeT, solmax, KO, FE, uniqueness, limreg, P, Fixpoint] = readREINfile(model="toy/model_expanded.net", experiments="toy/observations.spec") res = grn_solver(C, CRM, length, Idef, Iopt, R, E, typeT, 1, KO, FE, uniqueness, limreg, P, Fixpoint) try: [resList, _, _] = res except: resList = None if (resList): ## Random generation of state ## #q0 = [randint(0, 1) for i in range(len(C))] q0 = ["0", "1", "1", "0", "1"] print("Test on first model found:") modelID = 0 printStates([[">>> Initial state :", [["q0", q0]]]], 0, C) sstep = 6 print(">>> Number of steps: " + str(sstep)) print(">>> Not steady state:") states = launch_model(modelID, C, CRM, resList, Idef, Iopt, R, q0, sstep, typeT, KO, FE, P) for i in range(len(states)): printStates(states, i, C) print("\n") print(">>> Steady state:") states = launch_model(modelID, C, CRM, resList, Idef, Iopt, R, q0, sstep, typeT, KO, FE, P, steadyStates=True) for i in range(len(states)): printStates(states, i, C) print("------- END TEST")
def call_run(model=full_toy_model, experiments=full_toy_experiments, simplify=False, visualize=False): from models import readREINfile from grn_solver import grn_solver from get_grfs import get_grfs, write_grfs, simplify_grfs if (visualize): from launch_model import model2igraph [ C, CRM, length, Idef, Iopt, R, E, typeT, solmax, KO, FE, uniqueness, limreg, P, Fixpoint ] = readREINfile(model, experiments) res = grn_solver(C, CRM, length, Idef, Iopt, R, E, typeT, solmax, KO, FE, uniqueness, limreg, P, Fixpoint, verbose=False) try: [resList, s, regInt] = res except: return (res) title = "result_" + model.split("/")[0] + "_" + model.split("/")[1] grfsList = [get_grfs(C, res, regInt) for res in resList] write_grfs(grfsList, title=title) print("MSG: Wrote GRFs in " + title + ".txt") if (simplify): for m in range(1, len(grfsList) + 1): simplify_grfs(title=title + "_model" + str(m) + ".txt") print("MSG: Simplified functions.") if (visualize): for modelID in range(len(resList)): print("MSG: Close plot to resume.") model2igraph(modelID, resList, C, Idef, Iopt, P, plotIt=True) return (s)
P = [""] * len(C) if (not resList): addGRF = False R = [["?"]] * len(C) resList = [[['Is', [1] * len(Iopt)]] + [[C[i], R[i][0]] for i in range(len(C))] ] else: addGRF = True ## Boolean addGRF is set to True iff. indices corresponding to GRF ## ## templates should be printed ## model2igraph(0, resList, C, Idef, Iopt, P, model=sys.argv[2] + "_" + emodel, plotIt=True, addGRF=addGRF) else: print("-- START") if (len(Iopt) > 0): print("Solving abstract model...") [resList, _, _] = grn_solver(C, CRM, length, Idef, Iopt, R, E,