예제 #1
0
 def test_lump_coupled_reactions_NV(self):
     N = model2stoichiometric_matrix(self.model, self.s_id2i, self.r_id2i)
     V = get_efm_matrix([{'r1': 10, 'r2': 10, 'r3': 10}, {'r1': 1, 'r3': 1, 'r4': 1, 'r6': 1}], self.r_id2i)
     NV = np.dot(N, V)
     coupled_r_id_groups = get_coupled_reactions(V, self.r_id2i)
     N_new, V_new, new_r_id2i, r_id2lr_id, _ = lump_coupled_reactions(N, V, coupled_r_id_groups, self.r_id2i)
     NV_new = np.dot(N_new, V_new)
     self.assertListEqual(list(NV.flatten()), list(NV_new.flatten()), 'NV should not have changed')
예제 #2
0
 def test_lump_coupled_reactions_N_2(self):
     N = model2stoichiometric_matrix(self.model, self.s_id2i, self.r_id2i)
     V = get_efm_matrix([{'r1': 10, 'r2': 10, 'r3': 10}, {'r1': 1, 'r3': 1, 'r4': 1, 'r6': 1}], self.r_id2i)
     coupled_r_id_groups = get_coupled_reactions(V, self.r_id2i)
     N_new, V_new, new_r_id2i, r_id2lr_id, _ = lump_coupled_reactions(N, V, coupled_r_id_groups, self.r_id2i)
     lr_id = next(r_id2lr_id.values())
     st = N_new[self.s_id2i['m2_b'], new_r_id2i[lr_id]]
     self.assertEqual(1, st, 'The lumped reaction was supposed to produce 1 m2_b, consumes %g instead' % -st)
예제 #3
0
 def test_lump_coupled_reactions_V(self):
     N = model2stoichiometric_matrix(self.model, self.s_id2i, self.r_id2i)
     V = get_efm_matrix([{'r1': 10, 'r2': 10, 'r3': 10}, {'r1': 1, 'r3': 1, 'r4': 1, 'r6': 1}], self.r_id2i)
     coupled_r_id_groups = get_coupled_reactions(V, self.r_id2i)
     N_new, V_new, new_r_id2i, r_id2lr_id, _ = lump_coupled_reactions(N, V, coupled_r_id_groups, self.r_id2i)
     lr_id = next(r_id2lr_id.values())
     r_i = V_new[new_r_id2i[lr_id], :]
     self.assertListEqual([10, 1], list(r_i),
                          'The lumped reaction was supposed to participate in EFMs with coefficients [10, 1] not %s'
                          % r_i)