def test_merge_efm_groups_V_shape(self): N = np.array([[-1, 0, -1, 0], [1, -1, 0, 0], [0, 1, 0, 1], [0, 0, 1, -1]]) V = np.array([[1, 0, 1], [1, 0, 0], [0, 10, 0], [0, 10, 0]]) efm_id2i = {0: 0, 1: 1, 2: 2} groups = get_efm_groups_based_on_boundary_metabolites(N, V, efm_id2i) V_new, new_efm_id2i, efm_id2gr_id = merge_efm_groups(V, groups, efm_id2i) self.assertTupleEqual((4, 2), V_new.shape, 'Was supposed to get 4x2 V, got %s' % [str(it) for it in V_new.shape])
def test_merge_efm_groups_V_content_2(self): N = np.array([[-1, 0, -1, 0], [1, -1, 0, 0], [0, 1, 0, 1], [0, 0, 1, -1]]) V = np.array([[1, 0, 1], [1, 0, 0], [0, 10, 0], [0, 10, 0]]) efm_id2i = {0: 0, 1: 1, 2: 2} groups = get_efm_groups_based_on_boundary_metabolites(N, V, efm_id2i) V_new, new_efm_id2i, efm_id2gr_id = merge_efm_groups(V, groups, efm_id2i) new_efm_index = new_efm_id2i[efm_id2gr_id[0]] r2 = V_new[2, new_efm_index] / V_new[3, new_efm_index] self.assertEqual(1, r2, 'Ratio r3/r4 in the new EFM was supposed to be 1, got %d' % r2)