Skip to content

Commit

Permalink
edit test for modify_medium()
Browse files Browse the repository at this point in the history
  • Loading branch information
hariszaf committed Jan 25, 2024
1 parent a722447 commit 0f4024d
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions tests/fba.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 0f4024d

Please sign in to comment.