#!/usr/bin/python from openeye.oechem import * import os, string, sys #os.putenv('LD_LIBRARY_PATH', '/raid1/people/xyz/dockenv /3rdparty/openeye/openeye/wrappers/libs/') #os.putenv('PYTHONPATH', '/usr/local2/lib/python2.3:/raid1/people/xyz/dockenv/3rdparty/openeye/openeye/wrappers/python') #p = os.getenv('PATH')+':/usr/local/bin:/raid1/people/xyz/dockenv/3rdparty/openeye/openeye/bin:/usr/local2/lib' #p = ':/usr/local/bin:/raid1/people/xyz/dockenv/3rdparty/openeye/openeye/bin:/usr/local2/lib' #os.putenv('PATH', p) #print os.getenv('PATH') ifs = oemolistream() ifs.open(sys.argv[1]) ofs_1 = oemolostream() ofs_1.open('temp.ism') # Reaction 1: S- addition to halogenated acidic C-alpha-carbonyl atom #Explicit hydrogens to avoid 5-bonded carbons and to prevent generation of identical copies in the case of attacked CH2 mol_sul = OEGraphMol() OEParseSmiles(mol_sul, "[SH]") libgen1 = OELibraryGen("[F,Cl,Br,I:1][C;!H0:2]([H:5])([*:7])[C:3](=[O,S:4]).[S:100][H:101]>>[*:1][C:2]([S-:100])([*:7])[*:3][*:4].[H:5][H:101]") libgen1.SetExplicitHydrogens(True) libgen1.SetValenceCorrection(False) for mol in ifs.GetOEMols(): libgen1.AddStartingMaterial(mol, 0) libgen1.AddStartingMaterial(mol_sul, 1) mol.Clear() mol_sul.Clear() title_list = [] for products in libgen1.GetProducts(): num = 1 prot = 0 title = products.GetTitle()+'cp_'+str(num) while title in title_list: num+=1 title = products.GetTitle()+'cp_'+str(num) title_list.append(title) products.SetTitle(title) OEWriteMolecule(ofs_1, products) ofs_1.close() ifs.close() #Remove doubles and H2 tempf = open('temp.ism', 'r') ismf = open('cysprot_01rxn_alphahalogencarbonyls_'+sys.argv[1][:string.find(sys.argv[1], '.')]+'.ism', 'w') smiles = {} for line in tempf.readlines(): newline1 = string.replace(line, '[HH].', '') newline2 = string.replace(newline1, '.[HH]', '') cols = string.split(newline2) if cols[1][:string.find(cols[1], '_')] not in smiles.keys(): smiles[cols[1][:string.find(cols[1], '_')]] = [cols[0]] else: if cols[0] not in smiles[cols[1][:string.find(cols[1], '_')]]: smiles[cols[1][:string.find(cols[1], '_')]].append(cols[0]) else: continue ismf.write(newline2) ismf.close() os.system('rm -f temp.ism')