当前位置: 首页>>代码示例>>Python>>正文


Python core.Reaction类代码示例

本文整理汇总了Python中cobra.core.Reaction的典型用法代码示例。如果您正苦于以下问题:Python Reaction类的具体用法?Python Reaction怎么用?Python Reaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Reaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_gpr

def test_gpr():
    model = Model()
    reaction = Reaction("test")

    # Set GPR to a reaction not in a model
    reaction.gene_reaction_rule = "(g1 or g2) and g3"
    assert reaction.gene_reaction_rule == "(g1 or g2) and g3"
    assert len(reaction.genes) == 3

    # Adding reaction with a GPR propagates to the model
    model.add_reactions([reaction])
    assert len(model.genes) == 3

    # Ensure the gene objects are the same in the model and reaction
    reaction_gene = list(reaction.genes)[0]
    model_gene = model.genes.get_by_id(reaction_gene.id)
    assert reaction_gene is model_gene

    # Test ability to handle uppercase AND/OR
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        reaction.gene_reaction_rule = "(b1 AND b2) OR (b3 and b4)"
        assert reaction.gene_reaction_rule == "(b1 and b2) or (b3 and b4)"
        assert len(reaction.genes) == 4

    # Ensure regular expressions correctly extract genes from malformed
    # GPR string
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        reaction.gene_reaction_rule = "(a1 or a2"
        assert len(reaction.genes) == 2
        reaction.gene_reaction_rule = "(forT or "
        assert len(reaction.genes) == 1
开发者ID:opencobra,项目名称:cobrapy,代码行数:33,代码来源:test_core_reaction.py

示例2: test__normalize_pseudoreaction_biomass_has_gpr

def test__normalize_pseudoreaction_biomass_has_gpr():
    reaction = Reaction('my_biomass_2')
    reaction.gene_reaction_rule = 'b1779'
    with pytest.raises(ConflictingPseudoreaction) as excinfo:
        _ = _normalize_pseudoreaction(reaction.id, reaction)
    assert 'has a gene_reaction_rule' in str(excinfo.value)
    assert reaction.id == 'my_biomass_2'
开发者ID:SBRG,项目名称:ome,代码行数:7,代码来源:test_parse.py

示例3: test__has_gene_reaction_rule

def test__has_gene_reaction_rule():
    reaction = Reaction('rxn')
    assert _has_gene_reaction_rule(reaction) is False
    reaction.gene_reaction_rule = 'b1779'
    assert _has_gene_reaction_rule(reaction) is True
    reaction.gene_reaction_rule = ' '
    assert _has_gene_reaction_rule(reaction) is False
开发者ID:SBRG,项目名称:ome,代码行数:7,代码来源:test_parse.py

示例4: test_add_reaction_context

def test_add_reaction_context(model):
    old_reaction_count = len(model.reactions)
    old_metabolite_count = len(model.metabolites)
    dummy_metabolite_1 = Metabolite("test_foo_1")
    dummy_metabolite_2 = Metabolite("test_foo_2")
    actual_metabolite = model.metabolites[0]
    copy_metabolite = model.metabolites[1].copy()
    dummy_reaction = Reaction("test_foo_reaction")
    dummy_reaction.add_metabolites({dummy_metabolite_1: -1,
                                    dummy_metabolite_2: 1,
                                    copy_metabolite: -2,
                                    actual_metabolite: 1})
    dummy_reaction.gene_reaction_rule = 'dummy_gene'

    with model:
        model.add_reaction(dummy_reaction)
        assert model.reactions.get_by_id(
            dummy_reaction.id) == dummy_reaction
        assert len(model.reactions) == old_reaction_count + 1
        assert len(model.metabolites) == old_metabolite_count + 2
        assert dummy_metabolite_1._model == model
        assert 'dummy_gene' in model.genes

    assert len(model.reactions) == old_reaction_count
    assert len(model.metabolites) == old_metabolite_count
    with pytest.raises(KeyError):
        model.reactions.get_by_id(dummy_reaction.id)
    assert dummy_metabolite_1._model is None
    assert 'dummy_gene' not in model.genes
开发者ID:opencobra,项目名称:cobrapy,代码行数:29,代码来源:test_model.py

示例5: test__normalize_pseudoreaction_exchange_error_bad_coeff

def test__normalize_pseudoreaction_exchange_error_bad_coeff():
    reaction = Reaction('EX_gone')
    reaction.add_metabolites({Metabolite('glu__L_e'): -2})
    with pytest.raises(ConflictingPseudoreaction) as excinfo:
        _ = _normalize_pseudoreaction(reaction.id, reaction)
    assert 'with coefficient' in str(excinfo.value)
    assert reaction.id == 'EX_gone'
开发者ID:SBRG,项目名称:ome,代码行数:7,代码来源:test_parse.py

示例6: test_reverse_reaction

def test_reverse_reaction():
    model = Model()
    reaction = Reaction('AB')
    model.add_reaction(reaction)
    reaction.build_reaction_from_string('a --> b')
    _reverse_reaction(reaction)
    assert reaction.reaction == 'b <-- a'
开发者ID:SBRG,项目名称:ome,代码行数:7,代码来源:test_parse.py

示例7: test_iadd

def test_iadd(model):
    PGI = model.reactions.PGI
    EX_h2o = model.reactions.EX_h2o_e
    original_PGI_gpr = PGI.gene_reaction_rule
    PGI += EX_h2o
    assert PGI.gene_reaction_rule == original_PGI_gpr
    assert PGI.metabolites[model.metabolites.h2o_e] == -1.0
    # Original should not change
    assert EX_h2o.gene_reaction_rule == ''
    assert EX_h2o.metabolites[model.metabolites.h2o_e] == -1.0
    # Add a reaction not in the model
    new_reaction = Reaction("test")
    new_reaction.add_metabolites({Metabolite("A"): -1, Metabolite("B"): 1})
    PGI += new_reaction
    assert PGI.gene_reaction_rule == original_PGI_gpr
    assert len(PGI.gene_reaction_rule) == 5
    # And vice versa
    new_reaction += PGI
    assert len(new_reaction.metabolites) == 5  # not
    assert len(new_reaction.genes) == 1
    assert new_reaction.gene_reaction_rule == original_PGI_gpr
    # Combine two GPRs
    model.reactions.ACKr += model.reactions.ACONTa
    expected_rule = '(b2296 or b3115 or b1849) and (b0118 or b1276)'
    assert model.reactions.ACKr.gene_reaction_rule == expected_rule
    assert len(model.reactions.ACKr.genes) == 5
开发者ID:opencobra,项目名称:cobrapy,代码行数:26,代码来源:test_core_reaction.py

示例8: test__normalize_pseudoreaction_exchange_error_has_gpr

def test__normalize_pseudoreaction_exchange_error_has_gpr():
    reaction = Reaction('EX_gone')
    reaction.add_metabolites({Metabolite('glu__L_e'): -1})
    reaction.gene_reaction_rule = 'b1779'
    with pytest.raises(ConflictingPseudoreaction) as excinfo:
        _ = _normalize_pseudoreaction(reaction.id, reaction)
    assert 'has a gene_reaction_rule' in str(excinfo.value)
    assert reaction.id == 'EX_gone'
开发者ID:SBRG,项目名称:ome,代码行数:8,代码来源:test_parse.py

示例9: test__normalize_pseudoreaction_demand

def test__normalize_pseudoreaction_demand():
    reaction = Reaction('DM_gone')
    reaction.add_metabolites({Metabolite('glu__L_c'): -1})
    reaction.lower_bound = 0
    reaction.upper_bound = 1000
    pseudo_id = _normalize_pseudoreaction(reaction.id, reaction)
    assert pseudo_id == 'DM_glu__L_c'
    assert reaction.subsystem == 'Intracellular demand'
开发者ID:SBRG,项目名称:ome,代码行数:8,代码来源:test_parse.py

示例10: test_add_reactions_single_existing

 def test_add_reactions_single_existing(self, model):
     rxn = model.reactions[0]
     r1 = Reaction(rxn.id)
     r1.add_metabolites({Metabolite('A'): -1, Metabolite('B'): 1})
     r1.lower_bound, r1.upper_bound = -999999., 999999.
     model.add_reactions([r1])
     assert rxn in model.reactions
     assert r1 is not model.reactions.get_by_id(rxn.id)
开发者ID:cdiener,项目名称:cobrapy,代码行数:8,代码来源:test_solver_model.py

示例11: test__normalize_pseudoreaction_sink

def test__normalize_pseudoreaction_sink():
    reaction = Reaction('SInk_gone')
    reaction.add_metabolites({Metabolite('glu__L_c'): -1})
    reaction.lower_bound = -1000
    reaction.upper_bound = 0
    pseudo_id = _normalize_pseudoreaction(reaction.id, reaction)
    assert pseudo_id == 'SK_glu__L_c'
    assert reaction.subsystem == 'Intracellular source/sink'
开发者ID:SBRG,项目名称:ome,代码行数:8,代码来源:test_parse.py

示例12: test__normalize_pseudoreaction_exchange

def test__normalize_pseudoreaction_exchange():
    reaction = Reaction('EX_gone')
    reaction.add_metabolites({Metabolite('glu__L_e'): -1})
    reaction.lower_bound = -1000
    reaction.upper_bound = 0
    pseudo_id = _normalize_pseudoreaction(reaction.id, reaction)
    assert pseudo_id == 'EX_glu__L_e'
    assert reaction.subsystem == 'Extracellular exchange'
开发者ID:SBRG,项目名称:ome,代码行数:8,代码来源:test_parse.py

示例13: test__normalize_pseudoreaction_demand_reversed

def test__normalize_pseudoreaction_demand_reversed():
    reaction = Reaction('DM_gone')
    reaction.add_metabolites({Metabolite('glu__L_c'): 1})
    reaction.lower_bound = -1000
    reaction.upper_bound = 0
    pseudo_id = _normalize_pseudoreaction(reaction.id, reaction)
    assert list(reaction.metabolites.values()) == [-1]
    assert reaction.lower_bound == 0
    assert reaction.upper_bound == 1000
    assert pseudo_id == 'DM_glu__L_c'
开发者ID:SBRG,项目名称:ome,代码行数:10,代码来源:test_parse.py

示例14: test__normalize_pseudoreaction_demand_reversed_prefer_sink_name

def test__normalize_pseudoreaction_demand_reversed_prefer_sink_name():
    reaction = Reaction('sink_gone')
    reaction.add_metabolites({Metabolite('glu__L_c'): 1})
    reaction.lower_bound = -1000
    reaction.upper_bound = 0
    _normalize_pseudoreaction(reaction)
    assert list(reaction.metabolites.values()) == [-1]
    assert reaction.lower_bound == 0
    assert reaction.upper_bound == 1000
    assert reaction.id == 'SK_glu__L_c'
开发者ID:P0N3Y,项目名称:ome,代码行数:10,代码来源:test_parse.py

示例15: test__normalize_pseudoreaction_atpm

def test__normalize_pseudoreaction_atpm():
    reaction = Reaction('notATPM')
    reaction.add_metabolites({Metabolite('atp_c'): -1,
                              Metabolite('h2o_c'): -1,
                              Metabolite('pi_c'): 1,
                              Metabolite('h_c'): 1,
                              Metabolite('adp_c'): 1})
    pseudo_id = _normalize_pseudoreaction(reaction.id, reaction)
    assert pseudo_id == 'ATPM'
    assert reaction.subsystem == 'Biomass and maintenance functions'
开发者ID:SBRG,项目名称:ome,代码行数:10,代码来源:test_parse.py


注:本文中的cobra.core.Reaction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。