#!/usr/local2/bin/python2.3 import os, string from openeye.oechem import * rxn = 7 ifs = oemolistream() ifs.open('b'+str(rxn)+'.1_ln.ism') ofs_1 = oemolostream() ofs_1.open('b'+str(rxn)+'_ln.ism') logfile = open('b'+str(rxn)+'_filter.log','w') #----------------------------------------------------------------------- # Check if wrong pattern (5-bonded Carbon from rxn 2) is found def get_arom_right(mol, log, ofs1): pat = OESubSearch() pat.Init('[r][r]([N])([O-])[r]') 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) log.write(mol.GetTitle()+' transformed!\n') else: OEWriteMolecule(ofs1, mol) log.write(mol.GetTitle()+' unchanged!\n') #------------------------------------------------------------------------- for molecule in ifs.GetOEMols(): get_arom_right(molecule, logfile, ofs_1) ofs_1.close() ifs.close()