#!/usr/local2/bin/python2.3 import os, string from openeye.oechem import * rxn = 4 ifs = oemolistream() ifs.open('b_react_ti_3_ln.sdf') ofs_3 = oemolostream() ofs_3.open('b_react_ti_4_lp.ism') ofs_4 = oemolostream() ofs_4.open('b_react_ti_4_lp.sdf') mol_hyd = OEGraphMol() OEParseSmiles(mol_hyd, "[H]") # Reaction 3b: 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 libgen2 = OELibraryGen("[CX4v4:1]([N:2])[O-:100].[H:99]>>[C:1]([N+:2][H:99])[O-:100]") libgen2.SetExplicitHydrogens(True) libgen2.SetValenceCorrection(False) for mol in ifs.GetOEMols(): libgen2.AddStartingMaterial(mol, 0) libgen2.AddStartingMaterial(mol_hyd, 1) mol.Clear() mol_hyd.Clear() title_list = [] rxn_n = 1 while rxn_n < rxn: try: old_title_file = open('b_react_ti_'+str(rxn_n)+'_ln.ism','r') for title in old_title_file.readlines(): title_list.append(string.split(title)[1]) old_title_file.close() except IOError: pass try: old_title_file = open('b_react_ti_'+str(rxn_n)+'_lp.ism','r') for title in old_title_file.readlines(): title_list.append(string.split(title)[1]) old_title_file.close() except IOError: pass rxn_n+=1 for products in libgen2.GetProducts(): if products.NumAtoms() < 76: num = 1 title = products.GetTitle()[:6]+'_'+str(num) while title in title_list: num+=1 title = products.GetTitle()[:6]+'_'+str(num) title_list.append(title) products.SetTitle(title) OEWriteMolecule(ofs_3, products) OEWriteMolecule(ofs_4, products) ofs_3.close() ofs_4.close() ifs.close()