コード例 #1
0
ファイル: test_sbo.py プロジェクト: sgalkina/memote
def test_sink_specific_sbo_presence(read_only_model):
    """Expect all sink reactions to be annotated with SBO:0000632.

    SBO:0000632 represents the term 'sink reaction'. The Systems Biology
    Ontology defines an exchange reaction as follows: 'A modeling process to
    provide matter influx or efflux to a model, for example to replenish a
    metabolic network with raw materials (eg carbon / energy sources). Such
    reactions are conceptual, created solely for modeling purposes, and do not
    have a physical correspondence. Unlike the analogous demand (SBO:....)
    reactions, which are usually designated as irreversible, sink reactions
    always represent a reversible uptake/secretion processes, and act as a
    metabolite source with no cost to the cell. Sink reactions, also referred
    to as R_SINK_, are generally used for compounds that are metabolized by
    the cell but are produced by non-metabolic, un-modeled cellular processes.'
    Every sink reaction should be annotated with
    this. Sink reactions differ from exchange reactions in that the metabolites
    are not removed from the extracellular environment, but from any of the
    organism's compartments.
    """
    ann = test_sink_specific_sbo_presence.annotation
    sinks = helpers.find_sink_reactions(read_only_model)
    ann["data"] = get_ids(
        sbo.check_component_for_specific_sbo_term(sinks, "SBO:0000632"))
    try:
        ann["metric"] = len(ann["data"]) / len(sinks)
    except ZeroDivisionError:
        ann["metric"] = 1.0
        ann["message"] = "No sink reactions found."
        pytest.skip(ann["message"])
    ann["message"] = wrapper.fill(
        """A total of {} genes ({:.2%} of all sink reactions) lack
        annotation with the SBO term "SBO:0000632" for
        'sink reaction': {}""".format(len(ann["data"]), ann["metric"],
                                      truncate(ann["data"])))
    assert len(ann["data"]) == len(sinks), ann["message"]
コード例 #2
0
def find_untagged_sink_rxns(model):
    """
    Find demand reactions whose IDs do not begin with ``SK_``.

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

    """
    sink_rxns = helpers.find_sink_reactions(model)
    comp_pattern = "^SK_\w*?"
    return [rxn for rxn in sink_rxns if not re.match(comp_pattern, rxn.id)]
コード例 #3
0
def find_false_sink_rxns(model):
    """
    Find reactions which are tagged with ``SK_`` but which are not sink rxns.

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

    """
    true_sink_rxns = helpers.find_sink_reactions(model)
    comp_pattern = "^SK_\w*?"
    all_rxns_tagged_SK = [
        rxn for rxn in model.reactions if re.match(comp_pattern, rxn.id)
    ]
    # false sink reactions
    return set(all_rxns_tagged_SK).difference(set(true_sink_rxns))
コード例 #4
0
ファイル: test_sbo.py プロジェクト: biosustain/memote
def test_sink_specific_sbo_presence(model):
    """Expect all sink reactions to be annotated with SBO:0000632.

    SBO:0000632 represents the term 'sink reaction'. The Systems Biology
    Ontology defines a sink reaction as follows: 'A modeling process to
    provide matter influx or efflux to a model, for example to replenish a
    metabolic network with raw materials (eg carbon / energy sources). Such
    reactions are conceptual, created solely for modeling purposes, and do not
    have a physical correspondence. Unlike the analogous demand (SBO:....)
    reactions, which are usually designated as irreversible, sink reactions
    always represent a reversible uptake/secretion processes, and act as a
    metabolite source with no cost to the cell. Sink reactions, also referred
    to as R_SINK_, are generally used for compounds that are metabolized by
    the cell but are produced by non-metabolic, un-modeled cellular processes.'
    Every sink reaction should be annotated with
    this. Sink reactions differ from exchange reactions in that the metabolites
    are not removed from the extracellular environment, but from any of the
    organism's compartments.

    Implementation:
    Check if each sink 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_sink_specific_sbo_presence.annotation
    sinks = helpers.find_sink_reactions(model)
    ann["data"] = get_ids(sbo.check_component_for_specific_sbo_term(
        sinks, "SBO:0000632"))
    try:
        ann["metric"] = len(ann["data"]) / len(sinks)
    except ZeroDivisionError:
        ann["metric"] = 1.0
        ann["message"] = "No sink reactions found."
        pytest.skip(ann["message"])
    ann["message"] = wrapper.fill(
        """A total of {} genes ({:.2%} of all sink reactions) lack
        annotation with the SBO term "SBO:0000632" for
        'sink reaction': {}""".format(
            len(ann["data"]), ann["metric"], truncate(ann["data"])
        ))
    assert len(ann["data"]) == len(sinks), ann["message"]