如何设置通量比作为约束? [英] How to set a flux ratio as a constraint?
问题描述
在某些数据集中,有时会观察到固定的通量比,我希望将其合并到仿真中.我该如何在CBMPy中做到这一点?
In some datasets, I sometimes observe fixed flux ratios which I would like to incorporate into my simulations. How could I do this in CBMPy?
例如,我有一个模型来自此处,现在想限制比例琥珀酸外排和丙酮酸外排至2.0.我知道如何对单个反应设置约束:
For example, I have the model from here and would now like to constrain the ratio of succinate efflux and pyruvate efflux to 2.0. I know how to set constraints on individual reactions:
import cbmpy
# downloaded from http://bigg.ucsd.edu/models/e_coli_core
ecoli = cbmpy.CBRead.readSBML3FBC('e_coli_core.xml')
ecoli.setReactionBounds('R_EX_pyr_e', 1.0, 1000.0)
ecoli.setReactionBounds('R_EX_succ_e', 2.0, 1000.0)
# solve the model
cbmpy.doFBA(ecoli)
# get all reaction values
solution = ecoli.getReactionValues()
print(solution['R_EX_pyr_e'])
print(solution['R_EX_succ_e'])
在这种情况下,该比率是正确的,但是如何添加它作为在所有条件下都可以满足的约束呢?
For this case the ratio is correct, but how can I add it as a constraint that it will be fulfilled for all conditions?
推荐答案
这确实是通量平衡分析(FBA)中的常用方法,您可以使用函数addUserConstraint
来完成此任务.
That is indeed a common approach in Flux Balance Analysis (FBA) and you can use the function addUserConstraint
to accomplish this.
整个代码示例可能如下所示(以下说明):
The entire code sample could look like this (explanation below):
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
.
As you can see the ratio is 2.0
as desired.
更多说明:
约束是
J_succ / J_pyr = 2.0
可以重写为
J_succ = 2.0 J_pyr
最后
J_pyr - 0.5 J_succ = 0
这正是我们在addUserConstraint
中传递给fluxes
的内容:
That's exactly what we pass to fluxes
in addUserConstraint
:
fluxes=[(1.0, 'R_EX_pyr_e' ),(-0.5, 'R_EX_succ_e')], operator='=', rhs=0.0)
您可以通过打印检查用户定义的约束:
You can check the user defined constraints by printing:
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')]}}
由于这是字典,因此您只需执行以下操作即可删除约束:
As this is a dictionary you can delete the constraint by simply doing:
del ecoli_ratio.user_constraints['pyr_succ_ratio']
print(ecoli_ratio.user_constraints)
{}
但是我强烈建议您在每次对模型进行重大更改时都创建一个克隆.
but I highly recommend to create a clone everytime you introduce major changes to a model.
这篇关于如何设置通量比作为约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!