예제 #1
0
def test_biomass_precursors_open_production(model, reaction_id):
    """
    Expect precursor production in complete medium.

    Using flux balance analysis this test optimizes for the production of each
    metabolite that is a substrate of the biomass reaction with the exception
    of atp and h2o. Optimizations are carried out using a complete
    medium i.e. unconstrained boundary reactions. This is useful when
    reconstructing the precursor biosynthesis pathways of a metabolic model.
    To pass this test, the model should be able to synthesis all the
    precursors.
    """
    ann = test_biomass_precursors_open_production.annotation
    with model:
        for exchange in model.exchanges:
            exchange.bounds = (-1000, 1000)
        reaction = model.reactions.get_by_id(reaction_id)
        ann["data"][reaction_id] = get_ids(
            biomass.find_blocked_biomass_precursors(reaction, model))
    ann["message"][reaction_id] = wrapper.fill(
        """Using the biomass reaction {} and when the model is simulated in
        complete medium a total of {} precursors cannot be produced: {}
        """.format(reaction_id, len(ann["data"][reaction_id]),
                   ann["data"][reaction_id]))
    assert len(ann["data"][reaction_id]) == 0, ann["message"][reaction_id]
예제 #2
0
def test_biomass_precursors_open_production(model, reaction_id):
    """
    Expect precursor production in complete medium.

    Using flux balance analysis this test optimizes for the production of each
    metabolite that is a substrate of the biomass reaction with the exception
    of atp and h2o. Optimizations are carried out using a complete
    medium i.e. unconstrained boundary reactions. This is useful when
    reconstructing the precursor biosynthesis pathways of a metabolic model.
    To pass this test, the model should be able to synthesis all the
    precursors.

    Implementation:
    First remove any constraints from all boundary reactions, then for each
    biomass precursor (except ATP and H2O) add a temporary demand
    reaction, then carry out FBA with this reaction as the objective. Collect
    all metabolites for which this optimization is below or equal to zero or is
    infeasible.

    """
    ann = test_biomass_precursors_open_production.annotation
    helpers.open_boundaries(model)
    reaction = model.reactions.get_by_id(reaction_id)
    ann["data"][reaction_id] = get_ids(
        biomass.find_blocked_biomass_precursors(reaction, model))
    ann["metric"][reaction_id] = len(ann["data"][reaction_id]) / \
        len(biomass.find_biomass_precursors(model, reaction))
    ann["message"][reaction_id] = wrapper.fill(
        """Using the biomass reaction {} and when the model is simulated in
        complete medium a total of {} precursors
        ({:.2%} of all precursors except h2o and atp) cannot be produced: {}
        """.format(reaction_id, len(ann["data"][reaction_id]),
                   ann["metric"][reaction_id], ann["data"][reaction_id]))
    assert len(ann["data"][reaction_id]) == 0, ann["message"][reaction_id]
예제 #3
0
def test_production_biomass_precursors_default(model, num):
    """
    Expect that there are no biomass precursors that cannot be produced.

    This is without changing the model"s default state.
    """
    biomass_rxns = helpers.find_biomass_reaction(model)
    for rxn in biomass_rxns:
        blocked_mets = biomass.find_blocked_biomass_precursors(rxn, model)
        assert len(blocked_mets) == num
예제 #4
0
def test_production_biomass_precursors_default(model, num):
    """
    Expect that there are no biomass precursors that cannot be produced.

    This is without changing the model's default state.
    """
    biomass_rxns = helpers.find_biomass_reaction(model)
    for rxn in biomass_rxns:
        blocked_mets = biomass.find_blocked_biomass_precursors(rxn, model)
        assert len(blocked_mets) == num
예제 #5
0
def test_production_biomass_precursors_exchange(model, num):
    """
    Expect that there are no biomass precursors that cannot be produced.

    This is after opening the model"s exchange reactions.
    """
    biomass_rxns = helpers.find_biomass_reaction(model)
    for rxn in biomass_rxns:
        helpers.open_boundaries(model)
        blocked_mets = biomass.find_blocked_biomass_precursors(rxn, model)
        assert len(blocked_mets) == num
예제 #6
0
def test_production_biomass_precursors_exchange(model, num):
    """
    Expect that there are no biomass precursors that cannot be produced.

    This is after opening the model"s exchange reactions.
    """
    biomass_rxns = helpers.find_biomass_reaction(model)
    for rxn in biomass_rxns:
        helpers.open_boundaries(model)
        blocked_mets = biomass.find_blocked_biomass_precursors(rxn, model)
        assert len(blocked_mets) == num
예제 #7
0
def test_biomass_precursors_default_production(read_only_model, reaction_id,
                                               store):
    """Expect production of all biomass precursors in default medium."""
    store["default_blocked_precursors"] = store.get(
        "default_blocked_precursors", list())
    reaction = read_only_model.reactions.get_by_id(reaction_id)
    blocked = [
        met.id for met in biomass.find_blocked_biomass_precursors(
            reaction, read_only_model)
    ]
    store["default_blocked_precursors"].append(blocked)
    assert len(blocked) == 0, \
        "{}'s following precursors cannot be produced: {}" \
        "".format(reaction.id, ", ".join(blocked))
예제 #8
0
def test_biomass_precursors_open_production(model, reaction_id, store):
    """Expect precursor production in complete medium."""
    store["open_blocked_precursors"] = store.get("open_blocked_precursors",
                                                 list())
    reaction = model.reactions.get_by_id(reaction_id)
    for exchange in model.exchanges:
        exchange.bounds = (-1000, 1000)
    blocked = [
        met.id
        for met in biomass.find_blocked_biomass_precursors(reaction, model)
    ]
    store["open_blocked_precursors"].append(blocked)
    assert len(blocked) == 0, \
        "{}'s following precursors cannot be produced: {}" \
        "".format(reaction.id, ", ".join(blocked))
예제 #9
0
def test_biomass_precursors_default_production(read_only_model, reaction_id):
    """
    Expect production of all biomass precursors in default medium.

    Using flux balance analysis this test optimizes for the production of each
    metabolite that is a substrate of the biomass reaction with the exception
    of atp and h2o. Optimizations are carried out using the default
    conditions. This is useful when reconstructing the precursor biosynthesis
    pathways of a metabolic model. To pass this test, the model should be able
    to synthesis all the precursors.
    """
    ann = test_biomass_precursors_default_production.annotation
    reaction = read_only_model.reactions.get_by_id(reaction_id)
    ann["data"][reaction_id] = get_ids(
        biomass.find_blocked_biomass_precursors(reaction, read_only_model))
    ann["message"][reaction_id] = wrapper.fill(
        """Using the biomass reaction {} and when the model is simulated on the
        provided default medium a total of {} precursors cannot be produced: {}
        """.format(reaction_id, len(ann["data"][reaction_id]),
                   ann["data"][reaction_id]))
    assert len(ann["data"][reaction_id]) == 0, ann["message"][reaction_id]