예제 #1
0
파일: test_sbo.py 프로젝트: sulheim/memote
def test_demand_specific_sbo_presence(read_only_model):
    """Expect all demand reactions to be annotated with SBO:0000627.

    SBO:0000628 represents the term 'demand reaction'. The Systems Biology
    Ontology defines a demand reaction as follows: 'A modeling process
    analogous to exchange reaction, but which operates upon "internal"
    metabolites. Metabolites that are consumed by these reactions are assumed
    to be used in intra-cellular processes that are not part of the model.
    Demand reactions, often represented 'R_DM_', can also deliver metabolites
    (from intra-cellular processes that are not considered in the model).'
    Every demand reaction should be annotated with
    this. Demand reactions differ from exchange reactions in that the
    metabolites are not removed from the extracellular environment, but from
    any of the organism's compartments. Demand reactions differ from sink
    reactions in that they are designated as irreversible.

    """
    ann = test_demand_specific_sbo_presence.annotation
    demands = helpers.find_demand_reactions(read_only_model)
    ann["data"] = get_ids(sbo.check_component_for_specific_sbo_term(
        demands, "SBO:0000628"))
    try:
        ann["metric"] = len(ann["data"]) / len(demands)
        ann["message"] = wrapper.fill(
            """A total of {} genes ({:.2%} of all demand reactions) lack
            annotation with the SBO term "SBO:0000628" for
            'demand reaction': {}""".format(
                len(ann["data"]), ann["metric"], truncate(ann["data"])))
    except ZeroDivisionError:
        ann["metric"] = 1.0
        ann["message"] = "The model has no demand reactions."
        pytest.skip(ann["message"])
    assert len(ann["data"]) == len(demands), ann["message"]
예제 #2
0
def find_untagged_demand_rxns(model):
    """
    Find demand reactions whose IDs do not begin with ``DM_``.

    Parameters
    ----------
    model : cobra.Model
        A cobrapy metabolic model

    """
    demand_rxns = helpers.find_demand_reactions(model)
    comp_pattern = "^DM_\w*?"
    return [rxn for rxn in demand_rxns if not re.match(comp_pattern, rxn.id)]
예제 #3
0
def find_false_demand_rxns(model):
    """
    Find reactions which are tagged with ``DM_`` but which are not demand rxns.

    Parameters
    ----------
    model : cobra.Model
        A cobrapy metabolic model

    """
    true_demand_rxns = helpers.find_demand_reactions(model)
    comp_pattern = "^DM_\w*?"
    all_rxns_tagged_DM = [
        rxn for rxn in model.reactions if re.match(comp_pattern, rxn.id)
    ]
    # false demand reactions
    return set(all_rxns_tagged_DM).difference(set(true_demand_rxns))
예제 #4
0
def test_demand_specific_sbo_presence(model):
    """Expect all demand reactions to be annotated with SBO:0000627.

    SBO:0000628 represents the term 'demand reaction'. The Systems Biology
    Ontology defines a demand reaction as follows: 'A modeling process
    analogous to exchange reaction, but which operates upon "internal"
    metabolites. Metabolites that are consumed by these reactions are assumed
    to be used in intra-cellular processes that are not part of the model.
    Demand reactions, often represented 'R_DM_', can also deliver metabolites
    (from intra-cellular processes that are not considered in the model).'
    Every demand reaction should be annotated with
    this. Demand reactions differ from exchange reactions in that the
    metabolites are not removed from the extracellular environment, but from
    any of the organism's compartments. Demand reactions differ from sink
    reactions in that they are designated as irreversible.

    Implementation:
    Check if each demand reaction has a non-zero "annotation"
    attribute that contains the key "sbo" with the associated
    value being one of the SBO terms above.

    """
    ann = test_demand_specific_sbo_presence.annotation
    demands = helpers.find_demand_reactions(model)
    ann["data"] = get_ids(sbo.check_component_for_specific_sbo_term(
        demands, "SBO:0000628"))
    try:
        ann["metric"] = len(ann["data"]) / len(demands)
        ann["message"] = wrapper.fill(
            """A total of {} genes ({:.2%} of all demand reactions) lack
            annotation with the SBO term "SBO:0000628" for
            'demand reaction': {}""".format(
                len(ann["data"]), ann["metric"], truncate(ann["data"])))
    except ZeroDivisionError:
        ann["metric"] = 1.0
        ann["message"] = "The model has no demand reactions."
        pytest.skip(ann["message"])
    assert len(ann["data"]) == len(demands), ann["message"]