def constrainosmolytelevels(model, osmolytelevels):
= model.osmolarities[0]/model.getvolumes(perguardcell = False)[0]
closedphaseos
= 0
totallevel for osmolytelevel in osmolytelevels.values():
+= osmolytelevel[0][1]
totallevel = closedphaseos/totallevel
scaling_closed
= model.osmolarities[1]/model.getvolumes(perguardcell = False)[1]
openphaseos
= 0
totallevel for osmolytelevel in osmolytelevels.values():
+= osmolytelevel[1][1]
totallevel = openphaseos/totallevel
scaling_open
print(scaling_closed, scaling_open)
= copy.deepcopy(osmolytelevels)
osmolytelevel_scaled
for osmolytelevel in osmolytelevel_scaled.values():
0][1] = osmolytelevel[0][1]*scaling_closed
osmolytelevel[1][1] = osmolytelevel[1][1]*scaling_open
osmolytelevel[0][1] = osmolytelevel[1][1] # IMPORTANT LINE ignores scaling closed
osmolytelevel[
= []
otherlist = ["aMAL", "STARCH"]
skipother
for reaction in model.model.reactions:
if "gc_Linker_1" in reaction.id:
= "_".join(reaction.id.split("_")[:-4])
osmolytename if osmolytename in skipother:
continue
= True
other if osmolytename in osmolytelevel_scaled:
= False
other if other == True:
otherlist.append(osmolytename)for osmolyte, concentration in osmolytelevel_scaled.items():
if osmolyte == "Other":
for other in otherlist:
try:
= [model.model.problem.Constraint((model.model.reactions.get_by_id(other + "_v_gc_Linker_" + str(phase)).flux_expression+model.model.reactions.get_by_id(other + "_c_gc_Linker_" + str(phase)).flux_expression)/model.getvolumes(perguardcell = False)[phase-1],
constraints_open =concentration[1][0],
lb=concentration[1][1]) for phase in [2]]
ub= [model.model.problem.Constraint((model.model.reactions.get_by_id(other + "_v_gc_Linker_" + str(phase)).flux_expression+model.model.reactions.get_by_id(other + "_c_gc_Linker_" + str(phase)).flux_expression)/model.getvolumes(perguardcell = False)[phase-1],
constraints_closed =concentration[0][0],
lb=concentration[0][1]) for phase in [1,3,4]]
ubexcept:
= [model.model.problem.Constraint((model.model.reactions.get_by_id(other + "_v_gc_Linker_" + str(phase)).flux_expression)/model.getvolumes(perguardcell = False)[phase-1],
constraints_open =concentration[1][0],
lb=concentration[1][1]) for phase in [2]]
ub= [model.model.problem.Constraint((model.model.reactions.get_by_id(other + "_v_gc_Linker_" + str(phase)).flux_expression)/model.getvolumes(perguardcell = False)[phase-1],
constraints_closed =concentration[0][0],
lb=concentration[0][1]) for phase in [1,3,4]]
ubfor constraint in constraints_open+constraints_closed:
model.model.add_cons_vars(constraint)
elif osmolyte == "MAL":
= [model.model.problem.Constraint((model.model.reactions.get_by_id(osmolyte + "_v_gc_Linker_" + str(phase)).flux_expression+model.model.reactions.get_by_id("a" + osmolyte + "_v_gc_Linker_" + str(phase)).flux_expression+model.model.reactions.get_by_id(osmolyte + "_c_gc_Linker_" + str(phase)).flux_expression)/model.getvolumes(perguardcell = False)[phase-1],
constraints_open =concentration[1][0],
lb=concentration[1][1]) for phase in [2]]
ub= [model.model.problem.Constraint((model.model.reactions.get_by_id(osmolyte + "_v_gc_Linker_" + str(phase)).flux_expression+model.model.reactions.get_by_id("a" + osmolyte + "_v_gc_Linker_" + str(phase)).flux_expression+model.model.reactions.get_by_id(osmolyte + "_c_gc_Linker_" + str(phase)).flux_expression)/model.getvolumes(perguardcell = False)[phase-1],
constraints_closed =concentration[0][0],
lb=concentration[0][1]) for phase in [1,3,4]]
ubfor constraint in constraints_open+constraints_closed:
model.model.add_cons_vars(constraint)
else:
= [model.model.problem.Constraint((model.model.reactions.get_by_id(osmolyte + "_v_gc_Linker_" + str(phase)).flux_expression+model.model.reactions.get_by_id(osmolyte + "_c_gc_Linker_" + str(phase)).flux_expression)/model.getvolumes(perguardcell = False)[phase-1],
constraints_open =concentration[1][0],
lb=concentration[1][1]) for phase in [2]]
ub= [model.model.problem.Constraint((model.model.reactions.get_by_id(osmolyte + "_v_gc_Linker_" + str(phase)).flux_expression+model.model.reactions.get_by_id(osmolyte + "_c_gc_Linker_" + str(phase)).flux_expression)/model.getvolumes(perguardcell = False)[phase-1],
constraints_closed =concentration[0][0],
lb=concentration[0][1]) for phase in [1,3,4]]
ubfor constraint in constraints_open+constraints_closed:
model.model.add_cons_vars(constraint)
osmolyteconstraints
This module