#!/usr/local2/bin/python2.3 # Just splits phosphat_ester in parts and marks the connecting atom to the phosphorus with a copper (will be removed later) from openeye.oechem import * import os, string, sys ifs = oemolistream() ifs.open('ORIGINAL_MOLS/a4_kegg_012506.ism') ofs = oemolostream() ofs.open('b8.1_parts_split_1_temp.ism') copper = OEGraphMol() OEParseSmiles(copper, '[Cu]') deprot = OEUniMolecularRxn("[P:1](=[O:2])([OH:3])>>[P:1](=[O:2])([O-:3])") # Can't handle Phosphates in rings yet! libgen1 = OELibraryGen("[O&!H1&!-,N&!-,S&!H1&!-:3][P&!r:2](=[O:1])([*:4])[*:5].[Cu:11].[Cu:12].[Cu:13]>>[Cu:11][A:3].[P:2]=[O:1].[Cu:12][*:4].[Cu:13][*:5]") for mol in ifs.GetOEMols(): deprot(mol) libgen1.AddStartingMaterial(mol, 0) libgen1.AddStartingMaterial(copper, 1) libgen1.AddStartingMaterial(copper, 2) libgen1.AddStartingMaterial(copper, 3) mol.Clear() copper.Clear() title_list = [] for products in libgen1.GetProducts(): if products.NumAtoms() < 76: num = 1 title = products.GetTitle()+'_Z'+str(num) while title in title_list: num+=1 title = products.GetTitle()+'_Z'+str(num) products.SetTitle(title) OEWriteMolecule(ofs, products) # print OECreateIsoSmiString(products) ofs.close() ifs.close() # Remove artefacts inf1 = open('b8.1_parts_split_1_temp.ism', 'r') outf1 = open('b8.1_parts_split_1.ism', 'w') for line in inf1.readlines(): newline = string.replace(line, '[OH-]','[O-]') outf1.write(newline) outf1.close() inf1.close() os.system('rm -f b8.1_parts_split_1_temp.ism')