如何将通量比设置为约束条件?
How to set a flux ratio as a constraint?
在某些数据集中,我有时会观察到固定的通量比,我想将其纳入我的模拟中。我如何在 CBMPy 中执行此操作?
例如,我有来自 here 的模型,现在想将琥珀酸流出和丙酮酸流出的比率限制为 2.0。我知道如何对个人反应设置约束:
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'])
对于这种情况,比率是正确的,但我如何将其添加为在所有条件下都满足的约束条件?
这确实是通量平衡分析 (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
这正是我们在 addUserConstraint
中传递给 fluxes
的内容:
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)
{}
但我强烈建议您每次对模型进行重大更改时都创建一个克隆。
在某些数据集中,我有时会观察到固定的通量比,我想将其纳入我的模拟中。我如何在 CBMPy 中执行此操作?
例如,我有来自 here 的模型,现在想将琥珀酸流出和丙酮酸流出的比率限制为 2.0。我知道如何对个人反应设置约束:
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'])
对于这种情况,比率是正确的,但我如何将其添加为在所有条件下都满足的约束条件?
这确实是通量平衡分析 (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
这正是我们在 addUserConstraint
中传递给 fluxes
的内容:
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)
{}
但我强烈建议您每次对模型进行重大更改时都创建一个克隆。