示例#1
0
def test_group_kind():
    group = Group("arbitrary_group1")
    with pytest.raises(ValueError) as excinfo:
        group.kind = "non-SBML compliant group kind"
    assert "Kind can only by one of:" in str(excinfo.value)

    group.kind = "collection"
    assert group.kind == "collection"
示例#2
0
def test_group_kind():
    group = Group("arbitrary_group1")
    with pytest.raises(ValueError) as excinfo:
        group.kind = "non-SBML compliant group kind"
    assert "Kind can only by one of:" in str(excinfo.value)

    group.kind = "collection"
    assert group.kind == "collection"
示例#3
0
def test_group_add_elements(model):
    num_members = 5
    reactions_for_group = model.reactions[0:num_members]
    group = Group("arbitrary_group1")
    group.add_members(reactions_for_group)
    group.kind = "collection"
    # number of member sin group should equal the number of reactions
    # assigned to the group
    assert len(group.members) == num_members

    # Choose an overlapping, larger subset of reactions for the group
    num_total_members = 12
    reactions_for_larger_group = model.reactions[0:num_total_members]
    group.add_members(reactions_for_larger_group)
    assert len(group.members) == num_total_members
示例#4
0
def test_group_add_elements(model):
    num_members = 5
    reactions_for_group = model.reactions[0:num_members]
    group = Group("arbitrary_group1")
    group.add_members(reactions_for_group)
    group.kind = "collection"
    # number of member sin group should equal the number of reactions
    # assigned to the group
    assert len(group.members) == num_members

    # Choose an overlapping, larger subset of reactions for the group
    num_total_members = 12
    reactions_for_larger_group = model.reactions[0:num_total_members]
    group.add_members(reactions_for_larger_group)
    assert len(group.members) == num_total_members
示例#5
0
def test_group_members_add_to_model(model):
    # remove a few reactions from the model and add them to a new group
    num_members = 5
    reactions_for_group = model.reactions[0:num_members]
    model.remove_reactions(reactions_for_group, remove_orphans=False)
    group = Group("arbitrary_group1")
    group.add_members(reactions_for_group)
    group.kind = "collection"
    # the old reactions should not be in the model
    for reaction in reactions_for_group:
        assert reaction not in model.reactions

    # add the group to the model and check that the reactions were added
    model.add_groups([group])
    assert group in model.groups
    for reaction in reactions_for_group:
        assert reaction in model.reactions
示例#6
0
def test_group_members_add_to_model(model):
    # remove a few reactions from the model and add them to a new group
    num_members = 5
    reactions_for_group = model.reactions[0:num_members]
    model.remove_reactions(reactions_for_group, remove_orphans=False)
    group = Group("arbitrary_group1")
    group.add_members(reactions_for_group)
    group.kind = "collection"
    # the old reactions should not be in the model
    for reaction in reactions_for_group:
        assert reaction not in model.reactions

    # add the group to the model and check that the reactions were added
    model.add_groups([group])
    assert group in model.groups
    for reaction in reactions_for_group:
        assert reaction in model.reactions
示例#7
0
def test_group_loss_of_elements(model):
    # when a metabolite, reaction, or gene is removed from a model, it
    # should no longer be a member of any groups
    num_members_each = 5
    elements_for_group = model.reactions[0:num_members_each]
    elements_for_group.extend(model.metabolites[0:num_members_each])
    elements_for_group.extend(model.genes[0:num_members_each])
    group = Group("arbitrary_group1")
    group.add_members(elements_for_group)
    group.kind = "collection"
    model.add_groups([group])

    remove_met = model.metabolites[0]
    model.remove_metabolites([remove_met])
    remove_rxn = model.reactions[0]
    model.remove_reactions([remove_rxn])
    remove_gene = model.genes[0]
    remove_gene.remove_from_model()
    assert remove_met not in group.members
    assert remove_rxn not in group.members
    assert remove_gene not in group.members
示例#8
0
def test_group_loss_of_elements(model):
    # when a metabolite, reaction, or gene is removed from a model, it
    # should no longer be a member of any groups
    num_members_each = 5
    elements_for_group = model.reactions[0:num_members_each]
    elements_for_group.extend(model.metabolites[0:num_members_each])
    elements_for_group.extend(model.genes[0:num_members_each])
    group = Group("arbitrary_group1")
    group.add_members(elements_for_group)
    group.kind = "collection"
    model.add_groups([group])

    remove_met = model.metabolites[0]
    model.remove_metabolites([remove_met])
    remove_rxn = model.reactions[0]
    model.remove_reactions([remove_rxn])
    remove_gene = model.genes[0]
    remove_gene.remove_from_model()
    assert remove_met not in group.members
    assert remove_rxn not in group.members
    assert remove_gene not in group.members
示例#9
0
def test_group_model_reaction_association(model):
    num_members = 5
    reactions_for_group = model.reactions[0:num_members]
    group = Group("arbitrary_group1")
    group.add_members(reactions_for_group)
    group.kind = "collection"
    model.add_groups([group])
    # group should point to and be associated with the model
    assert group._model is model
    assert group in model.groups

    # model.get_associated_groups should find the group for each reaction
    # we added to the group
    for reaction in reactions_for_group:
        assert group in model.get_associated_groups(reaction)

    # remove the group from the model and check that reactions are no
    # longer associated with the group
    model.remove_groups([group])
    assert group not in model.groups
    assert group._model is not model
    for reaction in reactions_for_group:
        assert group not in model.get_associated_groups(reaction)
示例#10
0
def test_group_model_reaction_association(model):
    num_members = 5
    reactions_for_group = model.reactions[0:num_members]
    group = Group("arbitrary_group1")
    group.add_members(reactions_for_group)
    group.kind = "collection"
    model.add_groups([group])
    # group should point to and be associated with the model
    assert group._model is model
    assert group in model.groups

    # model.get_associated_groups should find the group for each reaction
    # we added to the group
    for reaction in reactions_for_group:
        assert group in model.get_associated_groups(reaction)

    # remove the group from the model and check that reactions are no
    # longer associated with the group
    model.remove_groups([group])
    assert group not in model.groups
    assert group._model is not model
    for reaction in reactions_for_group:
        assert group not in model.get_associated_groups(reaction)