这确实是通量平衡分析 (FBA) 中的常用方法,您可以使用该功能addUserConstraint
来完成此操作。
整个代码示例可能如下所示(解释如下):
import cbmpy as cbm
# downloaded from http://bigg.ucsd.edu/models/e_coli_core
ecoli = cbm.CBRead.readSBML3FBC('e_coli_core.xml')
# make a clone of the original model
ecoli_ratio = ecoli.clone()
# add the desired user constraint; explanation follows below
ecoli_ratio.addUserConstraint("pyr_succ_ratio", fluxes=[(1.0, 'R_EX_pyr_e' ),(-0.5, 'R_EX_succ_e')], operator='=', rhs=0.0)
# now we have to set only one flux bound; if you think it is naturally excreted, this step is not needed
ecoli_ratio.setReactionBounds('R_EX_succ_e', 4.0, cbm.INF)
cbm.doFBA(ecoli_ratio)
solution = ecoli_ratio.getReactionValues()
print("{}: {}".format("succinate excretion rate", solution['R_EX_succ_e']))
print("{}: {}".format("pyruvate excretion rate", solution['R_EX_pyr_e']))
这将打印
succinate excretion rate: 4.0
pyruvate excretion rate: 2.0
如您所见,该比率2.0
符合要求。
多一点解释:
约束是
J_succ / J_pyr = 2.0
可以重写为
J_succ = 2.0 J_pyr
最后
J_pyr - 0.5 J_succ = 0
这正是我们传递给fluxes
in 的内容addUserConstraint
:
fluxes=[(1.0, 'R_EX_pyr_e' ),(-0.5, 'R_EX_succ_e')], operator='=', rhs=0.0)
您可以通过打印检查用户定义的约束:
print(ecoli_ratio.user_constraints)
{'pyr_succ_ratio': {'operator': 'E', 'rhs': 0.0, 'fluxes': [(1.0, 'R_EX_pyr_e'), (-0.5, 'R_EX_succ_e')]}}
由于这是一本字典,您只需执行以下操作即可删除约束:
del ecoli_ratio.user_constraints['pyr_succ_ratio']
print(ecoli_ratio.user_constraints)
{}
但我强烈建议您每次对模型进行重大更改时创建一个克隆。