#!/usr/local2/bin/python2.3 # 1) Create dictionaries; per possible leaving group with its ligands # {title_1:{leaving_group1: [ligands in triangular plane...], leaving_group2 (if existent): [ligands in triangular plane...]...} # 2) Dicitonary for chirality of the three ligands in plane (per leaving group) => are at least two of them identical => no chirality from openeye.oechem import * import os, string ifs = oemolistream() ifs.open('b_react_ti_9_parts_split_1.ism') outf1 = open('b_react_ti_9_parts_split_2_dicts1.txt', 'w') outf2 = open('b_react_ti_9_parts_split_2_dicts2.txt', 'w') leaving_group = OESubSearch() leaving_group.Init('[Cu][O&X2&!H1&!-,N&X2&!-,S&X1&!H1&!-]') phos_pat = OESubSearch() phos_pat.Init('[PX1]=[O]') leavings = {} for mol in ifs.GetOEMols(): title = mol.GetTitle() leavings[title] = {} count,parts = OEDetermineComponents(mol) pred = OEPartPred(parts) for i in xrange(1,count+1): pred.SelectPart(i) newlig = OEGraphMol() OESubsetMol(newlig, mol, pred) smiles = OECreateIsoSmiString(newlig) if phos_pat.SingleMatch(newlig) != 1 and leaving_group.SingleMatch(newlig) == 1: if smiles not in leavings[title].values(): leavings[title][smiles] = [] for j in xrange(i+1, count+1): pred.SelectPart(j) potlig = OEGraphMol() OESubsetMol(potlig, mol, pred) smiles2 = OECreateIsoSmiString(potlig) if phos_pat.SingleMatch(potlig) != 1: leavings[title][smiles].append(smiles2) for j in xrange(1, i): pred.SelectPart(j) potlig = OEGraphMol() OESubsetMol(potlig, mol, pred) smiles2 = OECreateIsoSmiString(potlig) if phos_pat.SingleMatch(newlig) != 1: leavings[title][smiles].append(smiles2) ifs.close() #print leavings ox_cop = OESubSearch() ox_cop.Init('[O-X1][Cu]') # have to write files for dicts, since command OEPartPred needs different OEchem-version than the rxn-commands (might be fixed in v1.3.3) title_list = [] for title in leavings.keys(): for key in leavings[title].keys(): num = 1 newtitle = title+'_1' while newtitle in title_list: num+=1 newtitle = title+'_'+str(num) title_list.append(newtitle) outf1.write(newtitle+' '+key+' '+leavings[title][key][0]+' '+leavings[title][key][1]+'\n') old_chiral = 0 for lig in leavings[title][key]: chiral = 0 for lig2 in leavings[title][key]: lig2_smi = OEGraphMol() OEParseSmiles(lig2_smi, lig2) # if ox_cop.SingleMatch(lig2_smi) == 1: # print OECreateIsoSmiString(lig2_smi) if lig2 == lig or ox_cop.SingleMatch(lig2_smi) == 1: chiral+=1 # print chiral, old_chiral if chiral > old_chiral: old_chiral = chiral outf2.write(newtitle+' '+key+' '+str(old_chiral)+'\n') outf1.close() outf2.close() print '************** DONE WITH b_react_ti_9_parts_split_2.py invoking b_react_ti_9_parts_connect_1.py *******************'