#!/usr/bin/python import os, string, sys from openeye.oechem import * #----------------------------------------------------------------------- # 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') #------------------------------------------------------------------------- ifs = oemolistream() ifs.open('b6.1'+sys.argv[1]+'_ln.ism') ofs_1 = oemolostream() ofs_1.open('b6.2'+sys.argv[1]+'_ln_out.ism') logfile = open('b6.2'+sys.argv[1]+'_filter.log','w') for molecule in ifs.GetOEMols(): get_arom_right(molecule, logfile, ofs_1) ofs_1.close() ifs.close() print '\nStarted b6.3_rxn_imin_aromatic.py\n' os.system('b6.3_rxn_imin_aromatic.py '+sys.argv[1])