#!/usr/local2/bin/python2.3 import os, string from openeye.oechem import * rxn = 8 ifs = oemolistream() ifs.open('a_kegg_filter_1.sdf') ofs_1 = oemolostream() ofs_1.open('b_react_ti_'+str(rxn)+'_not_filtered_ln.sdf') ofs_3 = oemolostream() ofs_3.open('b_react_ti_'+str(rxn)+'_not_filtered_lp.sdf') mol_wat = OEGraphMol() OEParseSmiles(mol_wat, "O(H)H") mol_hyd = OEGraphMol() OEParseSmiles(mol_hyd, "[OH]") # Reaction 7: OH-H nucleophilic attack at X-C=N (X (not C) endocyclic or chain member) (Imine) (rxn6 - AROMATIC - wrong annot. in Kegg) # nothing protonated libgen1 = OELibraryGen("[a:4][c:1](=[N:2])[a&!#6:3].[O:100][H:99]>>[*:4][C:1]([N:2][H:99])([O-:100])[A:3]") # Leaving group X protonated libgen2 = OELibraryGen("[a:4][c:1](=[N:2])[aR&!#6:3].[O:100]([H:98])[H:99]>>[*:4][C:1]([N:2][H:99])([O-:100])[AR+:3][H:98]") # Leaving amine N protonated libgen3 = OELibraryGen("[a:4][c:1](=[N:2])[aR&!#6:3].[O:100]([H:98])[H:99]>>[*:4][C:1]([N+:2]([H:99])[H:98])([O-:100])[AR:3]") # Leaving group A:4 protonated (if 3 heteroatoms at the attacked center!) libgen4 = OELibraryGen("[#7,#8,#15,#16:4][c:1](=[N:2])[aR&!#6:3].[O:100]([H:99])[H:98]>>[A+:4]([H:98])[C:1]([N:2][H:99])([O-:100])[AR:3]") libgen1.SetExplicitHydrogens(True) libgen1.SetValenceCorrection(False) libgen2.SetExplicitHydrogens(True) libgen2.SetValenceCorrection(False) libgen3.SetExplicitHydrogens(True) libgen3.SetValenceCorrection(False) libgen4.SetExplicitHydrogens(True) libgen4.SetValenceCorrection(False) for mol in ifs.GetOEMols(): libgen1.AddStartingMaterial(mol, 0) libgen1.AddStartingMaterial(mol_hyd, 1) libgen2.AddStartingMaterial(mol, 0) libgen2.AddStartingMaterial(mol_wat, 1) libgen3.AddStartingMaterial(mol, 0) libgen3.AddStartingMaterial(mol_wat, 1) libgen4.AddStartingMaterial(mol, 0) libgen4.AddStartingMaterial(mol_wat, 1) mol.Clear() mol_wat.Clear() mol_hyd.Clear() title_list = [] rxn_n = 1 while rxn_n < rxn: try: old_title_file = open('b_react_ti_'+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: pass try: old_title_file = open('b_react_ti_'+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: pass rxn_n+=1 for products in libgen1.GetProducts(): if products.NumAtoms() < 76: num = 1 title = products.GetTitle()+str(num) while title in title_list: num+=1 title = products.GetTitle()+str(num) title_list.append(title) products.SetTitle(title) OEWriteMolecule(ofs_1, products) ofs_1.close() for products in libgen2.GetProducts(): if products.NumAtoms() < 76: num = 1 title = products.GetTitle()+str(num) while title in title_list: num+=1 title = products.GetTitle()+str(num) title_list.append(title) products.SetTitle(title) OEWriteMolecule(ofs_3, products) for products in libgen3.GetProducts(): if products.NumAtoms() < 76: num = 1 title = products.GetTitle()+str(num) while title in title_list: num+=1 title = products.GetTitle()+str(num) title_list.append(title) products.SetTitle(title) OEWriteMolecule(ofs_3, products) for products in libgen4.GetProducts(): if products.NumAtoms() < 76: num = 1 title = products.GetTitle()+str(num) while title in title_list: num+=1 title = products.GetTitle()+str(num) title_list.append(title) products.SetTitle(title) OEWriteMolecule(ofs_3, products) ofs_3.close() ifs.close()