#!/usr/local2/bin/python2.3 from openeye.oechem import * import os, string # wie 1, aber =S dort vergessen! rxn = 13 ifs = oemolistream() ifs.open('a_kegg_filter_1.sdf') ofs_1 = oemolostream() ofs_1.open('b_react_ti_'+str(rxn)+'_ln.ism') ofs_2 = oemolostream() ofs_2.open('b_react_ti_'+str(rxn)+'_ln.sdf') ofs_3 = oemolostream() ofs_3.open('b_react_ti_'+str(rxn)+'_lp.ism') ofs_4 = oemolostream() ofs_4.open('b_react_ti_'+str(rxn)+'_lp.sdf') 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]=([S:3])[!#6&!-&!#1:2].[O:100][H:102]>>[*:4][C:1]([S:3][H:102])([O-:100])[*:2]") # leaving group protonated - will create attacked carboxylates! -> removing libgen2 = OELibraryGen("[C:1]=([S:3])[!#6&!-&!#1:2].[O:100]([H:102])[H:101]>>[C:1]([S:3][H:102])([O-:100])[*+: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) OEWriteMolecule(ofs_2, 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) OEWriteMolecule(ofs_4, products) ofs_1.close() ofs_2.close() ofs_3.close() ofs_4.close() ifs.close()