#!/usr/local2/bin/python2.3 from openeye.oechem import * import os, string rxn = 2 ifs = oemolistream() ifs.open('ORIGINAL_MOLS/a4_kegg_012506.ism') ofs_1 = oemolostream() ofs_2 = oemolostream() ofs_1.open('b'+str(rxn)+'.1_ln.ism') ofs_2.open('b'+str(rxn)+'.1_lp.ism') mol_hyd = OEGraphMol() OEParseSmiles(mol_hyd, "[OH]") # Reaction 1 aromatic: OH- nucleophilic attack at a-C(=O)-X (amide etc., O exocyclic) # Former Carbonyl-oxygen becomes OH-group, attacking OH- becomes O- # (AROMATIC -> partly wrong annotations in KEGG) #leaving group NOT protonated [*:4] included, because leaving group needs to be recognized only once (if there are 2!) libgen1 = OELibraryGen("[a&!-:4][c:1]=([O,S:3])[!#6:2].[OH:100]>>[A:4][C:1]([A-:3])([OH:100])[*:2]") for mol in ifs.GetOEMols(): libgen1.AddStartingMaterial(mol, 0) libgen1.AddStartingMaterial(mol_hyd, 1) mol.Clear() mol_hyd.Clear() title_list = [] rxn_n = 1 while rxn_n < rxn: old_title_file = open('b'+str(rxn_n)+'_ln.ism','r') for title in old_title_file.readlines(): title_list.append(string.split(title)[1]) old_title_file.close() old_title_file = open('b'+str(rxn_n)+'_lp.ism','r') for title in old_title_file.readlines(): title_list.append(string.split(title)[1]) old_title_file.close() rxn_n+=1 for products in libgen1.GetProducts(): num = 1 prot = 0 title = products.GetTitle()+str(num)+'p'+str(prot) while title in title_list: num+=1 title = products.GetTitle()+str(num)+'p'+str(prot) title_list.append(title) products.SetTitle(title) OEWriteMolecule(ofs_1, products) ofs_1.close() ifs.close() #raise SystemExit() ifs.open('b'+str(rxn)+'.1_ln.ism') mol_prot = OEGraphMol() OEParseSmiles(mol_prot, "[H+]") #leaving group protonated - will create attacked carboxylates!(can't avoid otherwise not all pot. leaving groups recognized) libgen2 = OELibraryGen("[#6R:1]([O,S-:3])([OH:5])[R&!#6&!-:2].[H:102]>>[C:1]([A:3])([OH:5])[*+:2][H:102]") for mol in ifs.GetOEMols(): libgen2.AddStartingMaterial(mol, 0) libgen2.AddStartingMaterial(mol_prot, 1) mol.Clear() mol_prot.Clear() for products in libgen2.GetProducts(): prot = 0 title = products.GetTitle()[:string.find(products.GetTitle(), 'p0')]+'p'+str(prot) while title in title_list: prot+=1 title = products.GetTitle()[:string.find(products.GetTitle(), 'p')]+'p'+str(prot) title_list.append(title) products.SetTitle(title) OEWriteMolecule(ofs_2, products) ofs_2.close() ifs.close()