#!/usr/local2/bin/python2.3 import os, string from openeye.oechem import * rxn = 6 ifs = oemolistream() ifs.open('ORG_BRENDA_MOL_FILES_PREP/a4_brenda_031306.ism') ofs_1 = oemolostream() ofs_1.open('bb'+str(rxn)+'_ln.ism') ofs_2 = oemolostream() ofs_2.open('bb'+str(rxn)+'_lp.ism') mol_hyd = OEGraphMol() OEParseSmiles(mol_hyd, "[OH]") # Reaction 6: OH-H nucleophilic attack at X:-C(Y)=N endocyclic or chain member) (Imine, Amidine, Guanidine) # Nothing protonated libgen1 = OELibraryGen("[A,H:4][C:1]([*:2])=[N:3].[O:100][H:99]>>[*:4][C:1]([*:2])([O-:100])[N:3][H:99]") libgen1.SetExplicitHydrogens(True) libgen1.SetValenceCorrection(False) 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: try: old_title_file = open('bb'+str(rxn_n)+'_ln.ism','r') for title in old_title_file.readlines(): title_list.append(string.split(title)[1]) old_title_file.close() except IOError: print 'bb'+str(rxn_n)+'_ln.ism not existent\n' try: old_title_file = open('bb'+str(rxn_n)+'_lp.ism','r') for title in old_title_file.readlines(): title_list.append(string.split(title)[1]) old_title_file.close() except IOError: print 'bb'+str(rxn_n)+'_lp.ism not existent\n' 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() ifs.open('bb'+str(rxn)+'_ln.ism') mol_prot = OEGraphMol() OEParseSmiles(mol_prot, "[H]") # Leaving group X,Y: protonated libgen2 = OELibraryGen("[C:1]([!#6;!#1:2])([O-:5])[N:3].[H:98]>>[C:1]([*+:2][H:98])([O-:5])[N:3]") # Leaving group N protonated libgen3 = OELibraryGen("[*:4][C:1]([*:2])([O-:5])[N:3].[H:98]>>[*:4][C:1]([*:2])([O-:5])[N+:3][H:98]") libgen2.SetExplicitHydrogens(True) libgen2.SetValenceCorrection(False) libgen3.SetExplicitHydrogens(True) libgen3.SetValenceCorrection(False) for mol in ifs.GetOEMols(): libgen2.AddStartingMaterial(mol, 0) libgen2.AddStartingMaterial(mol_prot, 1) libgen3.AddStartingMaterial(mol, 0) libgen3.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) for products in libgen3.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) ifs.close()