def __init__(self): self.model = create_cobra_model_from_sbml_file("../data/iJO1366.xml") # Modify model convert_to_irreversible(self.model) self.rxns = dict([(r.id, r) for r in self.model.reactions]) self.genes = dict([(g.id, g) for g in self.model.genes]) add_to_model(self.model) self.include_specific_isozmyes() self.gc = pd.DataFrame.from_csv("../data/growth_conditions.csv") flux = pd.DataFrame.from_csv('../data/flux[mmol_gCDW_h].csv') self.v = self._convert_mmol_gCDW_h_to_mmol_gCDW_s(flux) # PPKr_reverse reaction is used for ATP generation from ADP # in the FBA model. Nevertheless, acording to EcoCyc, it is used to # to generate polyP (inorganic phosphate) chains from ATP and it is not # part of the oxidative phosphorilation, thus removed from rate calculations if 'PPKr_reverse' in self.v.index: self.v.drop('PPKr_reverse', axis=0, inplace=True) self.enzymatic_reactions = self._enzymatic_reactions() self.homomeric_reactions = self.reactions_by_homomeric_enzymes() proteins_copies_fL = pd.DataFrame.from_csv( '../data/meta_abundance[copies_fL].csv') self.proteins_mmol_gCDW = self._convert_copies_fL_to_mmol_gCDW( proteins_copies_fL) self.E = self.map_expression_by_reaction() self.kapp = self.get_kapp() # per subunit self.SA = self.get_specific_activity() self.kcat = pd.DataFrame.from_csv("../data/kcat_data.csv") self.p_per_as = (self.kcat['polypeptides per complex'] / self.kcat['catalytic sites per complex']) self.kmax = self.get_kmax(self.kapp) self.SAmax = self.get_maximum_specific_activity(self.SA)
def __init__(self): self.model = create_cobra_model_from_sbml_file("../data/iJO1366.xml") # Modify model convert_to_irreversible(self.model) self.rxns = dict([(r.id, r) for r in self.model.reactions]) self.genes = dict([(g.id, g) for g in self.model.genes]) add_to_model(self.model) self.include_specific_isozmyes() self.gc = pd.DataFrame.from_csv("../data/growth_conditions.csv") flux = pd.DataFrame.from_csv('../data/flux[mmol_gCDW_h].csv') self.v = self._convert_mmol_gCDW_h_to_mmol_gCDW_s(flux) # PPKr_reverse reaction is used for ATP generation from ADP # in the FBA model. Nevertheless, acording to EcoCyc, it is used to # to generate polyP (inorganic phosphate) chains from ATP and it is not # part of the oxidative phosphorilation, thus removed from rate calculations if 'PPKr_reverse' in self.v.index: self.v.drop('PPKr_reverse', axis=0, inplace=True) self.enzymatic_reactions = self._enzymatic_reactions() self.homomeric_reactions = self.reactions_by_homomeric_enzymes() proteins_copies_fL = pd.DataFrame.from_csv('../data/meta_abundance[copies_fL].csv') self.proteins_mmol_gCDW = self._convert_copies_fL_to_mmol_gCDW(proteins_copies_fL) self.E = self.map_expression_by_reaction() self.kapp = self.get_kapp() # per subunit self.SA = self.get_specific_activity() self.kcat = pd.DataFrame.from_csv("../data/kcat_data.csv") self.p_per_as = (self.kcat['polypeptides per complex'] / self.kcat['catalytic sites per complex']) self.kmax = self.get_kmax(self.kapp) self.SAmax = self.get_maximum_specific_activity(self.SA)
# reversibility index N_P = sum([v for v in r.metabolites.itervalues() if v > 0]) N_S = sum([-v for v in r.metabolites.itervalues() if v < 0]) N = N_P + N_S fixed_conc = 0.1 r.logRI = (2 / N) * (r.logKeq + (N_P - N_S) * np.log(fixed_conc)) for r in set(reactions) - set(self.reactions): r.dG0_prime = np.NaN r.dGm_prime = np.NaN r.logKeq = np.NaN r.logRI = np.NaN return dG0_prime if __name__ == "__main__": from model_addons import add_to_model model_fname = "../shared_data/iJO1366.xml" model = create_cobra_model_from_sbml_file(model_fname) add_to_model(model) reactions = [ 'MDH', 'FBA', 'TPI', 'FBP', 'PGM', 'SERAT', 'TMDS', 'DBTS', 'DM_4CRSOL' ] reactions = ['PPS'] reactions = map(model.reactions.get_by_id, reactions) # reactions = model.reactions Th = reaction_thermodynamics(reactions)
def filter_reactions(metabolite, only_irreversible=True): metabolite_forming_reactions = [r for r in metabolite.reactions if metabolite in r.products] homomeric_reactions = filter(lambda r: 'and' not in r.gene_reaction_rule, metabolite_forming_reactions) reactions = {r:r.dG0_prime for r in homomeric_reactions} if only_irreversible: reactions = {k:v for k,v in reactions.iteritems() if v<10} return reactions #model = create_cobra_model_from_sbml_file('../data/iJO1366.xml') model = create_cobra_model_from_sbml_file('/home/yinonbaron/git/shared_data/iJO1366.xml') add_to_model(model) tr = reaction_thermodynamics(model.reactions) nadh = model.metabolites.get_by_id('nadh_c') # reactions which produce NADH, and are thermodynamically favorable # Also, all reactions are catalyzed by homomeric enzymes. nadh_forming = filter_reactions(nadh, only_irreversible=True) water = model.metabolites.get_by_id('h2o_c') first_hop = defaultdict(list) for r in nadh_forming: for m in r.reactants: if m not in [water, nadh]: homomeric_and_favorable = filter_reactions(m) for k in homomeric_and_favorable.iterkeys(): if k not in nadh_forming:
document = parse(model_fname) ec_list = [] for r_elem in document.getElementsByTagName('reaction'): for p_elem in r_elem.getElementsByTagName('p'): val = p_elem.childNodes[0].nodeValue if val.find('EC Number:') != -1: ec = val[11:].encode('utf-8') ec_list.append(ec) return ec_list a = map_model_reactions_to_EC("../data/iJO1366.xml") m = create_cobra_model_from_sbml_file("../data/iJO1366.xml") add_to_model(m) #b = set(filter(None, a)) brenda = pd.DataFrame.from_csv("../data/BRENDA_data.csv") brenda = brenda[brenda["Organism ID"] == 6] # ecoli reactions brenda = brenda[brenda["kcat"] > 0] measured_ecs = set(brenda.index) out = pd.DataFrame(index=a) out['reaction'] = [r.id for r in m.reactions] out['subsystem'] = [r.subsystem for r in m.reactions] out['kcat'] = [1 if ec in brenda.index else 'NaN' for ec in out.index] out[out['kcat'] != 1] out.drop('', inplace=True) out.drop('', inplace=True) out['EC'] = out.index
''' parse the sbml model file to extract EC numbers of reactions ''' document = parse(model_fname) ec_list = [] for r_elem in document.getElementsByTagName('reaction'): for p_elem in r_elem.getElementsByTagName('p'): val = p_elem.childNodes[0].nodeValue if val.find('EC Number:') != -1: ec = val[11:].encode('utf-8') ec_list.append(ec) return ec_list a = map_model_reactions_to_EC("../data/iJO1366.xml") m = create_cobra_model_from_sbml_file("../data/iJO1366.xml") add_to_model(m) #b = set(filter(None, a)) brenda = pd.DataFrame.from_csv("../data/BRENDA_data.csv") brenda = brenda[brenda["Organism ID"]==6] # ecoli reactions brenda = brenda[brenda["kcat"]>0] measured_ecs = set(brenda.index) out = pd.DataFrame(index=a) out['reaction'] = [r.id for r in m.reactions] out['subsystem'] = [r.subsystem for r in m.reactions] out['kcat'] = [1 if ec in brenda.index else 'NaN' for ec in out.index] out[out['kcat']!=1] out.drop('', inplace=True) out.drop('', inplace=True) out['EC'] = out.index