def test_reaction_translated_compounds(self): r = Reaction(Direction.Forward, [(Compound('Pb'), 1)], [(Compound('Au'), 1)]) rt = r.translated_compounds(lambda name: name.lower()) self.assertEqual( rt, Reaction(Direction.Forward, [(Compound('pb'), 1)], [(Compound('au'), 1)]))
def test_reaction_translated_compounds(self): r = Reaction(Direction.Forward, [(Compound('Pb'), 1)], [(Compound('Au'), 1)]) rt = r.translated_compounds(lambda name: name.lower()) self.assertEqual( rt, Reaction(Direction.Forward, [(Compound('pb'), 1)], [(Compound('au'), 1)]))
if cpd not in wp2_structure: no_structure = 1 if no_structure == 0: lhs = [] rhs = [] for i in rx_original.left: cpd = i[0].name if cpd != 'C00080': lhs.append(i) for j in rx_original.right: cpd = j[0].name if cpd != 'C00080': rhs.append(j) no_h_rxn = Reaction(Direction.Both, lhs, rhs) rx = str(no_h_rxn.translated_compounds(compound_name)) # rx = str(no_h_rxn) rx_trans_string_no_comp = rx.replace('C00080[', '[') for comp in nm.compartments: rx_trans_string_no_comp = rx_trans_string_no_comp.replace( '[%s]' % comp.id, '') rx_trans_string_no_comp = rx_trans_string_no_comp.replace('(', '') rx_trans_string_no_comp = rx_trans_string_no_comp.replace(')', '') rx_trans_string_no_comp = rx_trans_string_no_comp.replace( '<=>', '=') rx_trans_string_no_comp = rx_trans_string_no_comp.replace( '=>', '=') rxn_list.append(rx_trans_string_no_comp) rxn_dict[rx_trans_string_no_comp] = rxn else: