def test_detect_energy_generating_cycles(read_only_model, met): u""" Expect that no energy metabolite can be produced out of nothing. When a model is not sufficiently constrained to account for the thermodynamics of reactions, flux cycles may form which provide reduced metabolites to the model without requiring nutrient uptake. These cycles are referred to as erroneous energy-generating cycles. Their effect on the predicted growth rate in FBA may account for an increase of up to 25%, which makes studies involving the growth rates predicted from such models unreliable. This test uses an implementation of the algorithm presented by: Fritzemeier, C. J., Hartleb, D., Szappanos, B., Papp, B., & Lercher, M. J. (2017). Erroneous energy-generating cycles in published genome scale metabolic networks: Identification and removal. PLoS Computational Biology, 13(4), 1–14. http://doi.org/10.1371/journal.pcbi.1005494 """ ann = test_detect_energy_generating_cycles.annotation if met not in read_only_model.metabolites: pytest.skip("This test has been skipped since metabolite {} could " "not be found in the model.".format(met)) ann["data"][met] = consistency.detect_energy_generating_cycles( read_only_model, met) ann["message"][met] = wrapper.fill( """The model can produce '{}' without requiring resources. This is caused by improperly constrained reactions leading to erroneous energy-generating cycles. The following {} reactions are involved in those cycles: {}""".format( met, len(ann["data"][met]), truncate(ann["data"][met]))) assert len(ann["data"][met]) == 0, ann["message"][met]
def test_detect_energy_generating_cycles(read_only_model, store, met): """Expect that no energy metabolite can be produced out of nothing.""" try: result = \ consistency.detect_energy_generating_cycles(read_only_model, met) except KeyError: result = "not found" store["magic_{}_production".format(met)] = result if result == "not found": assert False,\ "The metabolite '{}' was not found in the model.".format(met) elif result == "infeasible": assert False,\ "Solving the model is infeasible. Often this is due to missing " \ "or disconnected metabolites, or too strict constraints." else: assert len(result) == 0,\ "The model can produce '{}' without requiring resources. This is " \ "likely caused by improperly constrained reactions leading to " \ "erroneous energy-generating cycles.".format(met)
def test_detect_energy_generating_cycles(model, met): u""" Expect that no energy metabolite can be produced out of nothing. When a model is not sufficiently constrained to account for the thermodynamics of reactions, flux cycles may form which provide reduced metabolites to the model without requiring nutrient uptake. These cycles are referred to as erroneous energy-generating cycles. Their effect on the predicted growth rate in FBA may account for an increase of up to 25%, which makes studies involving the growth rates predicted from such models unreliable. Implementation: This test uses an implementation of the algorithm presented by: Fritzemeier, C. J., Hartleb, D., Szappanos, B., Papp, B., & Lercher, M. J. (2017). Erroneous energy-generating cycles in published genome scale metabolic networks: Identification and removal. PLoS Computational Biology, 13(4), 1–14. http://doi.org/10.1371/journal.pcbi.1005494 First attempt to identify the main compartment (cytosol), then attempt to identify each metabolite of the referenced list of energy couples via an internal mapping table. Construct a dissipation reaction for each couple. Carry out FBA with each dissipation reaction as the objective and report those reactions that non-zero carry flux. """ ann = test_detect_energy_generating_cycles.annotation if met not in model.metabolites: pytest.skip("This test has been skipped since metabolite {} could " "not be found in the model.".format(met)) ann["data"][met] = consistency.detect_energy_generating_cycles(model, met) # Report the number of cycles scaled by the number of reactions. ann["metric"][met] = len(ann["data"][met]) / len(model.reactions) ann["message"][met] = wrapper.fill( """The model can produce '{}' without requiring resources. This is caused by improperly constrained reactions leading to erroneous energy-generating cycles. The following {} reactions are involved in those cycles: {}""".format( met, len(ann["data"][met]), truncate(ann["data"][met]))) assert len(ann["data"][met]) == 0, ann["message"][met]
def test_detect_energy_generating_cycles_exceptions(model, metabolite_id, output): """Expect that energy-generating cycles don't exist for metabolite ID.""" result = consistency.detect_energy_generating_cycles(model, metabolite_id) assert set(result) == set(output)
def test_detect_energy_generating_cycles_control_flow(model, metabolite_id): """Expect that energy-generating cycles don't exist for metabolite ID.""" cycle = consistency.detect_energy_generating_cycles(model, metabolite_id) assert set(cycle) == {'A', 'B', 'C'}