#!/usr/local2/bin/python2.3 from openeye.oechem import * import os, string, sys try: ifs = oemolistream() ifs.open(sys.argv[1]) ofs_1 = oemolostream() ofs_2 = oemolostream() ofs_1.open('b2.1'+sys.argv[1][string.find(sys.argv[1], '_'):string.find(sys.argv[1], '_out')]+'_ln.ism') ofs_2.open('b2.1'+sys.argv[1][string.find(sys.argv[1], '_'):string.find(sys.argv[1], '_out')]+'_lp.ism') date = sys.argv[1][string.find(sys.argv[1], '_'):string.find(sys.argv[1], '_out')] except IndexError: print '\nUsage: b2.1_rxn_aromatic_cleav.py molfile\n' raise SystemExit() 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 = [] for title_file in os.listdir('.'): if title_file[-11:] == '_titles.txt': print 'Open & read '+title_file titlef = open(title_file, 'r') for line in titlef.readlines(): title_list.append(line[:-1]) titlef.close() title_f = open('b2_titles.txt', 'w') 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) title_f.write(title+'\n') ofs_1.close() ifs.close() # Protonation ifs.open('b2.1'+sys.argv[1][string.find(sys.argv[1], '_'):string.find(sys.argv[1], '_out')]+'_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) title_f.write(title+'\n') ofs_2.close() ifs.close() title_f.close() print '\nStart b2.2_rxn_aromatic_cleav.py\n' os.system('b2.2_rxn_aromatic_cleav.py '+date)