#!/usr/local2/bin/python2.3 from openeye.oechem import * import os, string rxn = 1 ifs = oemolistream() ifs.open('zinc_hydsdhps.ism') ofs_1 = oemolostream() ofs_1.open('b_hydsdhps_ti_'+str(rxn)+'_ln.ism') ofs_3 = oemolostream() ofs_3.open('b_hydsdhps_ti_'+str(rxn)+'_lp.ism') mol_hyd = OEGraphMol() OEParseSmiles(mol_hyd, "[OH]") mol_wat = OEGraphMol() OEParseSmiles(mol_wat, "O(H)H") # Reaction 1: OH- nucleophilic attack at A-C(=O)-X (amide, ester etc., O exocyclic) (Non-aromatic) # Former Carbonyl-oxygen becomes OH-group, attacking OH- becomes O- # leaving group NOT protonated [*:4] included, because leaving group needs to be recognized only once (if there are 2!) libgen1 = OELibraryGen("[*&!-:4][C:1]=([O:3])[!#6&!-&!#1:2].[OH:100]>>[*:4][C:1]([O-:3])([OH:100])[*:2]") # leaving group protonated - will create attacked carboxylates! -> removing libgen2 = OELibraryGen("[C:1]=([O:3])[!#6&!-&!#1:2].[O:100]([H:102])[H:101]>>[C:1]([O-:3])([O:100][H:102])[*+:2][H:101]") libgen1.SetExplicitHydrogens(True) libgen1.SetValenceCorrection(False) libgen2.SetExplicitHydrogens(True) libgen2.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) mol.Clear() mol_wat.Clear() mol_hyd.Clear() title_list = [] 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) hydcooh = OESubSearch() hydcooh.Init('[O-][C&X4]([OH])[O-]') for products in libgen2.GetProducts(): if products.NumAtoms() < 76: if hydcooh.SingleMatch(products) != 1: 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_1.close() ofs_3.close() ifs.close()