In [1]:
import cobra
from cobra.solvers import get_solver_name
from cobra import Model, Reaction, Metabolite
from cobra.flux_analysis import parsimonious
import pandas as pd
In [2]:
model = cobra.io.read_sbml_model('models/geenen_glutathione_original.xml')
Fix reaction reversibility
In [5]:
model.reactions.v_v1.lower_bound = 0 # met => SAM
model.reactions.v_v2.lower_bound = 0 # met => SAM
model.reactions.v_v3.lower_bound = 0 # SAM => SAH
model.reactions.v_v4.lower_bound = 0 #
model.reactions.v_v6.lower_bound = 0 # hcy => met
model.reactions.v_v12.lower_bound = 0 # 2 GSH -> GSSG
model.reactions.v_v13.lower_bound = 0 # GSSG -> 2 GSH
model.reactions.v_v14.lower_bound = 0 # cGSSG => bGSSG
model.reactions.v_v15.lower_bound = 0 # cGSSG => bGSSG
model.reactions.v_v16.lower_bound = 0 #
model.reactions.v_v17.lower_bound = 0 #
model.reactions.v_v23.lower_bound = 0 # cTHF => cCH2THF
model.reactions.v_v25.lower_bound = 0 # oxo -> cglut
model.reactions.v_v33.lower_bound = 0 # cGSH + para => ASG
model.reactions.v_v34.lower_bound = 0 # cGSH + para => ASG
model.reactions.v_v40.lower_bound = 0 # bGSSG -> 2.0 bcys
model.reactions.v_v41.lower_bound = 0 #
Modify the published SBML model and export it as a json for use with Escher
In [6]:
exchanges = [rxn for rxn in model.reactions if rxn.products == [] or rxn.reactants == []]
for r in exchanges:
if 'EX_' not in r.id:
r.id = 'EX_'+r.id
model.repair()
if list(r.metabolites.values())[0] == 1 :
r.add_metabolites({list(r.metabolites.keys())[0]:-2})
model.repair()
r.lower_bound = -1; r.upper_bound = 1000
print(r.id,r.reaction)
# Add paracetamol
para = Metabolite('para')
model.add_metabolites(para)
EX_para = Reaction('EX_para')
model.add_reaction(EX_para)
model.reactions.EX_para.add_metabolites({'para':-1})
model.reactions.EX_para.lower_bound = -1; model.reactions.EX_para.upper_bound = -1
model.reactions.v_v33.add_metabolites({'para':-1})
model.reactions.v_v34.add_metabolites({'para':-1})
# fix reaction 29 bug
# In the kinetic model bgly is considered to be a reservoir
# Upon importing into FBA this leads to this imbalanced reaction where cys = cysgly
# We solve this by making this reaction produce gly in the cytosol
# this is biochemically a bit strange but topologically does not matter
model.reactions.v_v29.add_metabolites({'cgly':1})
cobra.io.save_json_model(model,'models/Geenen_cobra_model.json')
exchanges
Out[6]:
Show all reactions and their bounds
In [8]:
df = pd.DataFrame.from_dict({'ID':[r.id for r in model.reactions],
'Reaction': [r.reaction for r in model.reactions],
'LB':[r.lower_bound for r in model.reactions],
'UB':[r.upper_bound for r in model.reactions] })
df[['ID','Reaction','LB','UB']]
Out[8]:
In [ ]: