本文整理汇总了Python中cobra.Model.objective方法的典型用法代码示例。如果您正苦于以下问题:Python Model.objective方法的具体用法?Python Model.objective怎么用?Python Model.objective使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cobra.Model
的用法示例。
在下文中一共展示了Model.objective方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_inequality
# 需要导入模块: from cobra import Model [as 别名]
# 或者: from cobra.Model import objective [as 别名]
def test_inequality(self):
# The space enclosed by the constraints is a 2D triangle with
# vertexes as (3, 0), (1, 2), and (0, 1)
solver = self.solver
# c1 encodes y - x > 1 ==> y > x - 1
# c2 encodes y + x < 3 ==> y < 3 - x
c1 = Metabolite("c1")
c2 = Metabolite("c2")
x = Reaction("x")
x.lower_bound = 0
y = Reaction("y")
y.lower_bound = 0
x.add_metabolites({c1: -1, c2: 1})
y.add_metabolites({c1: 1, c2: 1})
c1._bound = 1
c1._constraint_sense = "G"
c2._bound = 3
c2._constraint_sense = "L"
m = Model()
m.add_reactions([x, y])
# test that optimal values are at the vertices
m.objective = "x"
self.assertAlmostEqual(solver.solve(m).f, 1.0)
self.assertAlmostEqual(solver.solve(m).x_dict["y"], 2.0)
m.objective = "y"
self.assertAlmostEqual(solver.solve(m).f, 3.0)
self.assertAlmostEqual(solver.solve(m, objective_sense="minimize").f,
1.0)
示例2: tiny_toy_model
# 需要导入模块: from cobra import Model [as 别名]
# 或者: from cobra.Model import objective [as 别名]
def tiny_toy_model():
tiny = Model("Toy Model")
m1 = Metabolite("M1")
d1 = Reaction("ex1")
d1.add_metabolites({m1: -1})
d1.upper_bound = 0
d1.lower_bound = -1000
tiny.add_reactions([d1])
tiny.objective = 'ex1'
return tiny
示例3: build_model
# 需要导入模块: from cobra import Model [as 别名]
# 或者: from cobra.Model import objective [as 别名]
def build_model():
m = Model("Blazier et al 2012")
m1_e = Metabolite("M1_e")
m1 = Metabolite("M1")
m2 = Metabolite("M2")
m3 = Metabolite("M3")
m4_e = Metabolite("M4_e")
m4 = Metabolite("M4")
m5 = Metabolite("M5")
r1 = Reaction("R1")
r1.add_metabolites({m1_e: -1, m1: 1})
r2 = Reaction("R2")
r2.add_metabolites({m1: -1, m2: 1})
r2.gene_reaction_rule = "Gene2"
r3 = Reaction("R3")
r3.add_metabolites({m2: -1, m3: 1})
r3.gene_reaction_rule = "Gene3"
r4 = Reaction("R4")
r4.add_metabolites({m3: -1})
r5 = Reaction("R5")
r5.add_metabolites({m4_e: -1, m4: 1})
r6 = Reaction("R6")
r6.add_metabolites({m4: -1, m5: 1})
r6.gene_reaction_rule = "Gene6"
r7 = Reaction("R7")
r7.add_metabolites({m5: -1, m2: 1})
r7.lower_bound = -r7.upper_bound
r7.gene_reaction_rule = "Gene7"
r8 = Reaction("R8")
r8.add_metabolites({m5: -1})
m.add_reactions([r1, r2, r3, r4, r5, r6, r7, r8])
EX_M1_e = m.add_boundary(m1_e)
EX_M1_e.lower_bound = -10
EX_M4_e = m.add_boundary(m4_e)
EX_M4_e.lower_bound = -10
m.objective = r4
return m
示例4: build_model
# 需要导入模块: from cobra import Model [as 别名]
# 或者: from cobra.Model import objective [as 别名]
def build_model():
m = Model("Zur et al 2012")
m1 = Metabolite("M1")
m2 = Metabolite("M2")
m3 = Metabolite("M3")
m4 = Metabolite("M4")
m5 = Metabolite("M5")
m6 = Metabolite("M6")
m7 = Metabolite("M7")
m8 = Metabolite("M8")
m9 = Metabolite("M9")
m10 = Metabolite("M10")
r1 = Reaction("R1")
r1.add_metabolites({m3: 1})
r2 = Reaction("R2")
r2.add_metabolites({m1: 1})
r2.gene_reaction_rule = "G1 or G2"
r3 = Reaction("R3")
r3.add_metabolites({m2: 1})
r3.gene_reaction_rule = "G5"
r4 = Reaction("R4")
r4.add_metabolites({m1: -1, m10: 1})
r4.lower_bound = -r4.upper_bound
r5 = Reaction("R5")
r5.add_metabolites({m10: -1, m4: 1})
r5.lower_bound = -r5.upper_bound
r6 = Reaction("R6")
r6.add_metabolites({m1: -1, m4: 1})
r7 = Reaction("R7")
r7.add_metabolites({m1: -1, m2: -1, m5: 1, m6: 1})
r7.gene_reaction_rule = "G6"
r8 = Reaction("R8")
r8.add_metabolites({m3: -1, m4: -1, m7: 1, m8: 1})
r8.gene_reaction_rule = "G3"
r9 = Reaction("R9")
r9.add_metabolites({m5: -1})
r10 = Reaction("R10")
r10.add_metabolites({m6: -1, m9: 1})
r10.gene_reaction_rule = "G7"
r11 = Reaction("R11")
r11.add_metabolites({m7: -1})
r12 = Reaction("R12")
r12.add_metabolites({m8: -1})
r12.gene_reaction_rule = "G4"
r13 = Reaction("R13")
r13.add_metabolites({m9: -1})
m.add_reactions([r1, r2, r3, r4, r5, r6, r7, r8])
m.objective = r4
return m