#!/usr/bin/python import os, string, sys from openeye.oechem import * try: ifs = oemolistream() ifs.open(sys.argv[1]) ofs_1 = oemolostream() ofs_1.open('b6.1'+sys.argv[1][string.find(sys.argv[1], '_'):string.find(sys.argv[1], '_out')]+'_ln.ism') date = sys.argv[1][string.find(sys.argv[1], '_'):string.find(sys.argv[1], '_out')] except IndexError: print '\nUsage: b6.1_rxn_amidine_aromatic.py molfile\n' raise SystemExit() mol_hyd = OEGraphMol() OEParseSmiles(mol_hyd, "[OH]") # Reaction 7: OH-H nucleophilic attack at x-c=n (x is not C) endocyclic or chain member) (Imine) (rxn6 - AROMATIC - wrong annot. in Kegg) # nothing protonated - will create doubles with rxn 4 # # NH # || # c #aromatisch in KEGG-sdf # / \ # 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]") 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 = [] 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('b6_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() title_f.close() print '\nStarted b6.2_rxn_imin_aromatic.py\n' os.system('b6.2_rxn_imin_aromatic.py '+date)