def singleSimulation(self, carbon_source='r_1714', cs_lb=-1.5, geneko=None, o2_lb=None, type='fba'): with self.model as m: m.set_carbon_source(carbon_source, lb=cs_lb) if o2_lb is not None: m.reactions.get_by_id('r_1992').lower_bound = float(o2_lb) if geneko is not None: if type == 'lmoma': r = pfba(m) m.set_environmental_conditions(gene_knockout=geneko) res = lmoma(m, r) else: m.set_environmental_conditions(gene_knockout=geneko) if type == 'fba': res = fba(m) elif type == 'pfba': res = pfba(m) elif type == 'fva': res = fva(m, reaction_list=m.reactions, fix_biomass=True) return res
def testO2EthanolProd (self, g_knockout = None, react_id = 'r_2115', cs = 'glucose', range_o2 = list(np.arange(-20, 0, 2))): res = {} for i in range_o2: with self.model as m: m.set_carbon_source(self.cs_reaction[cs], lb = self.cs_lb[cs]) m.reactions.get_by_id('r_1992').lower_bound = float(i) if g_knockout is not None: m.set_environmental_conditions(gene_knockout = g_knockout) r = pfba(m) if hasattr(r, 'x_dict'): #if legacy solution fluxes = pd.DataFrame(list(r.x_dict.items())).set_index(0) else: fluxes = r.fluxes res[str(i)] = fluxes.loc[react_id] for key, val in sorted(res.items()): print(key, '\t', val) return res
#Reaction Bounds for r in model.reactions: print(r.id, '\t', r.lower_bound, '\t', r.upper_bound) #SIMULATIONS #FBA res_fba = fba(model) res_fba.objective_value # The (optimal) value for the objective function. res_fba.status # The solver status related to the solution. res_fba.fluxes # Contains the reaction fluxes (primal values of variables). res_fba.reduced_costs # Contains reaction reduced costs (dual values of variables). res_fba.shadow_prices # Contains metabolite shadow prices (dual values of constraints). #PFBA res_pfba = pfba(model) res_pfba.objective_value res_pfba.status res_pfba.fluxes res_pfba.reduced_costs res_pfba.shadow_prices #FVA res_fva = fva(model, reaction_list=model.reactions) #pandas dataframe res_fva.to_csv('fva_res.csv', sep='\t') #RANDOM TESTS model.get_model_id() model.get_biomass_id() model.get_biomass() model.get_exchanges_ids()