diff --git a/tests/fba.py b/tests/fba.py index 7c3561ae..94dc5b6f 100644 --- a/tests/fba.py +++ b/tests/fba.py @@ -10,7 +10,7 @@ from dingo import MetabolicNetwork class TestFba(unittest.TestCase): - + def test_fba_json(self): input_file_json = os.getcwd() + "/ext_data/e_coli_core.json" @@ -21,7 +21,7 @@ def test_fba_json(self): self.assertTrue(abs(res[1] - 0.8739215067486387) < 1e-03) def test_fba_mat(self): - + input_file_mat = os.getcwd() + "/ext_data/e_coli_core.mat" model = MetabolicNetwork.from_mat(input_file_mat) model.set_slow_mode() @@ -49,26 +49,33 @@ def test_modify_medium(self): initial_medium = model.medium initial_fba = model.fba()[-1] - initial_medium_indices = {} - for reac in initial_medium: - initial_medium_indices[reac] = model.reactions.index(reac) + e_coli_core_medium_compound_indices = { + "EX_co2_e" : 46, + "EX_glc__D_e" : 51, + "EX_h_e" : 54, + "EX_h2o_e" : 55, + "EX_nh4_e" : 58, + "EX_o2_e" : 59, + "EX_pi_e" : 60 + } glc_index = model.reactions.index("EX_glc__D_e") + o2_index = model.reactions.index("EX_o2_e") new_media = initial_medium.copy() new_media["EX_glc__D_e"] = 1.5 + new_media["EX_o2_e"] = -0.5 model.medium = new_media updated_media = model.medium updated_medium_indices = {} for reac in updated_media: - updated_medium_indices[reac] = model.reactions.index(reac) + updated_medium_indices[reac] = model.reactions.index(reac) - if len(updated_media) == len(new_media): - self.assertTrue(updated_medium_indices == initial_medium_indices) + self.assertTrue(updated_medium_indices == e_coli_core_medium_compound_indices) - self.assertTrue(model.lb[glc_index] == -1.5) + self.assertTrue(model.lb[glc_index] == -1.5 and model.lb[o2_index] == 0.5) self.assertTrue(initial_fba - model.fba()[-1] > 0)