Example #1
0
def test_direct_metabolites_in_biomass(model, reaction_id):
    """
    Expect the ratio of direct metabolites to be below 0.5.

    Some biomass precursors are taken from the media and directly consumed by
    the biomass reaction. It might not be a problem for ions or
    metabolites for which the organism in question is auxotrophic. However,
    too many of these metabolites may be artifacts of automated gap-filling
    procedures. Many gap-filling algorithms attempt to minimise the number of
    added reactions. This can lead to many biomass precursors being
    "direct metabolites".

    This test reports the ratio of direct metabolites to the total amount of
    precursors to a given biomass reaction. It specifically looks for
    metabolites that are only in either exchange, transport or biomass
    reactions. Bear in mind that this may lead to false positives in heavily
    compartimentalized models.

    To pass this test, the ratio of direct metabolites should be less than 50%
    of all biomass precursors. This is an arbitrary threshold but it takes
    into account that while certain ions do not serve a relevant metabolic
    function, it may still be important to include them in the biomass
    reaction to account for the impact of their uptake energy costs.

    This threshold is subject to change in the future.

    Implementation:
    Identify biomass precursors (excluding ATP and H+), identify cytosol
    and extracellular compartment from an internal mapping table. Then,
    determine which precursors is only involved in transport, boundary and
    biomass reactions. Using FBA with the biomass function as the objective
    then determine whether the metabolite is taken up only to be consumed by
    the biomass reaction.

    """
    # TODO: Update the threshold as soon as we have an overview of the average!
    ann = test_direct_metabolites_in_biomass.annotation
    reaction = model.reactions.get_by_id(reaction_id)
    try:
        ann["data"][reaction_id] = get_ids(
            biomass.find_direct_metabolites(model, reaction))
    except OptimizationError:
        ann["data"][reaction_id] = []
        ann["metric"][reaction_id] = 1.0
        ann["message"][reaction_id] = "This model does not grow."
        pytest.skip(ann["message"])
    ann["metric"][reaction_id] = len(ann["data"][reaction_id]) / \
        len(biomass.find_biomass_precursors(model, reaction))
    ann["message"][reaction_id] = wrapper.fill(
        """{} contains a total of {} direct metabolites ({:.2%}).
        Specifically these are: {}.
        """.format(reaction_id, len(ann["data"][reaction_id]),
                   ann["metric"][reaction_id], ann["data"][reaction_id]))
    assert ann["metric"][reaction_id] < 0.5, ann["message"][reaction_id]
Example #2
0
def test_direct_metabolites_in_biomass(model, reaction_id):
    """
    Expect the biomass reactions to contain atp and adp.

    Some biomass precursors are taken from the media and directly consumed by
    the biomass reaction. It might not be a problem for ions or
    metabolites for which the organism in question is auxotrophic. However,
    too many of these metabolites may be artifacts of automated gap-filling
    procedures. Many gap-filling algorithms attempt to minimise the number of
    added reactions. This can lead to many biomass precursors being
    "direct metabolites".

    This test reports the ratio of direct metabolites to the total amount of
    precursors to a given biomass reaction. It specifically looks for
    metabolites that are only in either exchange, transport or biomass
    reactions. Bear in mind that this may lead to false positives in heavily
    compartimentalized models.

    To pass this test, the ratio of direct metabolites should be less than 50%
    of all biomass precursors. This is an arbitrary threshold but it takes
    into account that while certain ions do not serve a relevant metabolic
    function, it may still be important to include them in the biomass
    reaction to account for the impact of their uptake energy costs.

    This threshold is subject to change in the future.
    """
    # TODO: Update the threshold as soon as we have an overview of the average!
    ann = test_direct_metabolites_in_biomass.annotation
    reaction = model.reactions.get_by_id(reaction_id)
    ann["data"][reaction_id] = [
        m.id for m in biomass.find_direct_metabolites(model, reaction)
    ]
    ann["metric"][reaction_id] = len(ann["data"][reaction_id]) / \
        len(biomass.find_biomass_precursors(model, reaction))
    ann["message"][reaction_id] = wrapper.fill(
        """{} contains a total of {} direct metabolites ({:.2%}). Specifically
        these are: {}.""".format(reaction_id, len(ann["data"][reaction_id]),
                                 ann["metric"][reaction_id],
                                 ann["data"][reaction_id]))
    assert ann["metric"][reaction_id] < 0.5, ann["message"][reaction_id]
Example #3
0
def test_find_direct_metabolites(model, number):
    """Expect the appropriate amount of direct metabolites to be found."""
    biomass_rxns = helpers.find_biomass_reaction(model)
    for rxn in biomass_rxns:
        assert len(biomass.find_direct_metabolites(model, rxn)) is number
Example #4
0
def test_find_direct_metabolites_errors(model):
    """Expect the appropriate amount of direct metabolites to be found."""
    biomass_rxns = helpers.find_biomass_reaction(model)
    for rxn in biomass_rxns:
        biomass.find_direct_metabolites(model, rxn)
Example #5
0
def test_find_direct_metabolites_errors(model):
    """Expect the appropriate amount of direct metabolites to be found."""
    biomass_rxns = helpers.find_biomass_reaction(model)
    for rxn in biomass_rxns:
        biomass.find_direct_metabolites(model, rxn)
Example #6
0
def test_find_direct_metabolites(model, number):
    """Expect the appropriate amount of direct metabolites to be found."""
    biomass_rxns = helpers.find_biomass_reaction(model)
    for rxn in biomass_rxns:
        assert len(biomass.find_direct_metabolites(model, rxn)) is number