#!/usr/local2/bin/python2.3 import os, string from openeye.oechem import * rxn = 3 ifs = oemolistream() ifs.open('ORIGINAL_MOLS/a4_kegg_012506.ism') ofs_1 = oemolostream() ofs_2 = oemolostream() ofs_1.open('b'+str(rxn)+'_ln.ism') ofs_2.open('b'+str(rxn)+'_lp.ism') mol_hyd = OEGraphMol() OEParseSmiles(mol_hyd, "[OH-]") # Reaction 3: OH-H nucleophilic attack at N-C=X (X(not CvO) endocyclic or chain member) (amidine, guanidine) NON_AROMATIC # leaving amine not protonated libgen1 = OELibraryGen("[H,A:4][C:1]([N:2])=[!C&!O:3].[O-:100][H:99]>>[H,A:4][C:1]([N:2])([O-:100])[*:3][H:99]") 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 = [] rxn_n = 1 while rxn_n < rxn: old_title_file = open('b'+str(rxn_n)+'_ln.ism','r') for title in old_title_file.readlines(): title_list.append(string.split(title)[1]) old_title_file.close() old_title_file = open('b'+str(rxn_n)+'_lp.ism','r') for title in old_title_file.readlines(): title_list.append(string.split(title)[1]) old_title_file.close() rxn_n+=1 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) ofs_1.close() ifs.close() # Protonation Reaction 3: Protonation of all possible leaving groups (amines) of reaction 3 - not doable in one step, # because in case of 2 Ns each needs to be protonated one time # protonation of leaving amine - will generate identical molecules if similar N:2 twice bonded to C:4 ifs.open('b'+str(rxn)+'_ln.ism') mol_prot = OEGraphMol() OEParseSmiles(mol_prot, "[H+]") libgen2 = OELibraryGen("[CX4v4:1]([N:2])[O-:100].[H:99]>>[C:1]([N+:2][H:99])[O-:100]") for mol in ifs.GetOEMols(): libgen2.AddStartingMaterial(mol, 0) libgen2.AddStartingMaterial(mol_prot, 1) mol.Clear() mol_prot.Clear() product_smiles = [] for products in libgen2.GetProducts(): if OECreateIsoSmiString(products) in product_smiles: continue else: product_smiles.append(OECreateIsoSmiString(products)) 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) ofs_2.close() ifs.close()