本文整理汇总了Python中cobra.core.Reaction.bounds方法的典型用法代码示例。如果您正苦于以下问题:Python Reaction.bounds方法的具体用法?Python Reaction.bounds怎么用?Python Reaction.bounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cobra.core.Reaction
的用法示例。
在下文中一共展示了Reaction.bounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_complicated_model
# 需要导入模块: from cobra.core import Reaction [as 别名]
# 或者: from cobra.core.Reaction import bounds [as 别名]
def test_complicated_model():
"""Test a complicated model.
Difficult model since the online mean calculation is numerically
unstable so many samples weakly violate the equality constraints.
"""
model = Model('flux_split')
reaction1 = Reaction('V1')
reaction2 = Reaction('V2')
reaction3 = Reaction('V3')
reaction1.bounds = (0, 6)
reaction2.bounds = (0, 8)
reaction3.bounds = (0, 10)
A = Metabolite('A')
reaction1.add_metabolites({A: -1})
reaction2.add_metabolites({A: -1})
reaction3.add_metabolites({A: 1})
model.add_reactions([reaction1, reaction2, reaction3])
optgp = OptGPSampler(model, 1, seed=42)
achr = ACHRSampler(model, seed=42)
optgp_samples = optgp.sample(100)
achr_samples = achr.sample(100)
assert any(optgp_samples.corr().abs() < 1.0)
assert any(achr_samples.corr().abs() < 1.0)
# > 95% are valid
assert sum(optgp.validate(optgp_samples) == "v") > 95
assert sum(achr.validate(achr_samples) == "v") > 95
示例2: test_model_medium
# 需要导入模块: from cobra.core import Reaction [as 别名]
# 或者: from cobra.core.Reaction import bounds [as 别名]
def test_model_medium(self, model):
# Add a dummy 'malformed' import reaction
bad_import = Reaction('bad_import')
bad_import.add_metabolites({model.metabolites.pyr_c: 1})
bad_import.bounds = (0, 42)
model.add_reaction(bad_import)
# Test basic setting and getting methods
medium = model.medium
model.medium = medium
assert model.medium == medium
# Test context management
with model:
# Ensure the bounds are correct beforehand
assert model.reactions.EX_glc__D_e.lower_bound == -10
assert model.reactions.bad_import.upper_bound == 42
assert model.reactions.EX_co2_e.lower_bound == -1000
# Make changes to the media
new_medium = model.medium
new_medium['EX_glc__D_e'] = 20
new_medium['bad_import'] = 24
del new_medium['EX_co2_e']
# Change the medium, make sure changes work
model.medium = new_medium
assert model.reactions.EX_glc__D_e.lower_bound == -20
assert model.reactions.bad_import.upper_bound == 24
assert model.reactions.EX_co2_e.lower_bound == 0
# Make sure changes revert after the contex
assert model.reactions.EX_glc__D_e.lower_bound == -10
assert model.reactions.bad_import.upper_bound == 42
assert model.reactions.EX_co2_e.lower_bound == -1000
new_medium['bogus_rxn'] = 0
with pytest.raises(KeyError):
model.medium = new_medium