#!/usr/local2/bin/python2.3 import os, string from openeye.oechem import * rxn = 2 ifs = oemolistream() ofs_1 = oemolostream() ofs_1.open('b_react_ti_'+str(rxn)+'_ln.sdf') ofs_2 = oemolostream() ofs_2.open('b_react_ti_'+str(rxn)+'_ln.ism') ofs_3 = oemolostream() ofs_3.open('b_react_ti_'+str(rxn)+'_lp.sdf') ofs_4 = oemolostream() ofs_4.open('b_react_ti_'+str(rxn)+'_lp.ism') logfile = open('b_react_ti_'+str(rxn)+'_filter.log','w') #----------------------------------------------------------------------- # Check if wrong pattern (5-bonded Carbon from rxn 2) is found def get_arom_right(mol, log, ofs1, ofs2): pat = OESubSearch() pat.Init('[r]([OH])([O-])') if pat.SingleMatch(mol) == 1: for atom in mol.GetAtoms(): if atom.IsCarbon() == 1: if atom.GetExplicitValence() == 5: atom.SetAromatic(0) idx_five_valent = atom.GetIdx() for bond in mol.GetBonds(): begin = bond.GetBgn() end = bond.GetEnd() if begin.GetIdx() == idx_five_valent: begin.SetAromatic(0) end.SetAromatic(0) bond.SetOrder(1) elif end.GetIdx() == idx_five_valent: begin.SetAromatic(0) end.SetAromatic(0) bond.SetOrder(1) OEWriteMolecule(ofs1, mol) OEWriteMolecule(ofs2, mol) log.write(mol.GetTitle()+' transformed!\n') else: OEWriteMolecule(ofs1, mol) OEWriteMolecule(ofs2, mol) log.write(mol.GetTitle()+' unchanged!\n') #------------------------------------------------------------------------- ifs.open('b_react_ti_'+str(rxn)+'_not_filtered_ln.sdf') for molecule in ifs.GetOEMols(): get_arom_right(molecule, logfile, ofs_1, ofs_2) ofs_1.close() ofs_2.close() ifs.close() ifs.open('b_react_ti_'+str(rxn)+'_not_filtered_lp.sdf') for molecule in ifs.GetOEMols(): get_arom_right(molecule, logfile, ofs_3, ofs_4) logfile.close() ofs_3.close() ofs_4.close() ifs.close()