def test_basic_gecko_adjustment(): in_model = {'P00549': 0.1, 'P31373': 0.1, 'P31382': 0.1, 'P39708': 0.1, 'P39714': 0.1, 'P39726': 0.1, 'Q01574': 0.1} not_in_model = {'P10591': 0.1, 'P31383': 0.1, 'P32471': 0.1} measurements = pd.concat([pd.Series(in_model), pd.Series(not_in_model)]) model = GeckoModel('multi-pool') model.limit_proteins(fractions=pd.Series(measurements)) sol = model.optimize() assert sol.objective_value > 0.05 assert len(model.proteins) - len(model.pool_proteins) - len(in_model) == 0 assert all(rxn.upper_bound > 0 for rxn in model.individual_protein_exchanges)
def simulate_wt(): model = GeckoModel('single-pool') res = model.optimize() print(res) #for p in model.proteins: p = "P38066" with model: r = model.reactions.get_by_id("draw_prot_" + p) lb = r.lower_bound ub = r.upper_bound r.lower_bound = 0 r.upper_bound = 0.000001 res = model.optimize() #r.knock_out() #res = model.optimize() print(p + " wt simulation1 " + str(res.objective_value)) print(str(r.lower_bound) + " --> " + str(r.upper_bound))
def analysis_ko(resFileName): levels = [0, 1e-10, 1e-8, 1e-6, 1e-4, 1e-2, 0.1] model = GeckoModel('single-pool') df = pandas.DataFrame(index=range(100), columns=["ko", "Biomass"]) for i in range(100): proteins = random.sample(model.proteins, 10) dic = {p: 0 for p in proteins} model.limit_proteins(pandas.Series(dic)) res = model.optimize() df.loc[i] = (dic, res.objective_value) df.to_csv(resFileName)
def simulate_wt_multi(): model = GeckoModel('multi-pool') import pandas some_measurements = pandas.Series({ 'P00549': 0.1, 'P31373': 0.1, 'P31382': 0.1 }) model = GeckoModel('multi-pool') model.limit_proteins(some_measurements) res = model.optimize() print(" wt simulation1 ", res.objective_value) for r in model.reactions: print(r.id, " --> ", res.fluxes[r.id])
def essential_prot_scale(): model = GeckoModel("single-pool") model.solver = 'cplex' print("Essential proteins with cplex, scale model (single-pool)") for r in model.reactions: r.lower_bound = r.lower_bound * 100000 r.upper_bound = r.upper_bound * 100000 for p in model.proteins: with model as m: r = model.reactions.get_by_id("draw_prot_" + p) r.lower_bound = 0 r.upper_bound = 0 res = model.optimize() print(p, ",", res.objective_value)
def simulate_prot(): model = GeckoModel("single-pool") model.solver = 'cplex' with model: # for p in ["P53685","Q01574"]: for p in ['P33421']: r = model.reactions.get_by_id("draw_prot_" + p) r.lower_bound = 0 r.upper_bound = 0 res = model.optimize() print(" --> growth " + str(res.objective_value)) print(" --> r_2111 " + str(res.fluxes["r_2111"])) print(" --> r_2056 " + str(res.fluxes["r_2056"])) print(" --> r_1714 " + str(res.fluxes["r_1714_REV"])) print(" ------------ ")
def analysis_growth(resFileName): levels = [0, 1e-10, 1e-8, 1e-6, 1e-4, 1e-2, 0.1] model = GeckoModel('single-pool') proteins = model.proteins df = pandas.DataFrame(index=proteins, columns=levels) for p in proteins: print(p) if p != "P38066": for level in levels: r = model.reactions.get_by_id("draw_prot_" + p) lb = r.lower_bound ub = r.upper_bound r.lower_bound = 0 r.upper_bound = level res = model.optimize() df.loc[p][level] = res.objective_value r.lower_bound = lb r.upper_bound = ub df.to_csv(resFileName)