#!/usr/local2/bin/python import os, sys, string from openeye.oechem import * #---------------------------------------------- def a3_f2f(inf, outf): metal_list = [] ifs = oemolistream(inf) ofs = oemolostream(outf) ofs.SetFormat(OEFormat_ISM) for mol in ifs.GetOEMols(): metal = 0 carbon = 0 heavy_atom = 0 for atom in mol.GetAtoms(): if not atom.IsHydrogen(): heavy_atom+=1 if atom.IsMetal(): metal = 1 # elif not atom.IsHydrogen() and not atom.IsNitrogen() and not atom.IsCarbon and not atom.IsHalogen() and not atom.IsOxygen() and not atom.IsPhosphorus() and not atom.IsSulfur(): if atom.IsCarbon(): carbon = 1 if heavy_atom <= 48 and heavy_atom > 4 and carbon == 1 and string.find(OECreateAbsSmiString(mol), '*') == -1: OEWriteMolecule(ofs, mol) if metal == 1: print OECreateAbsSmiString(mol), mol.GetTitle() metal_list.append(mol.GetTitle()) else: pass print metal_list ifs.close() ofs.close() #---------------------------------------------- a3_f2f('ORIGINAL_MOLS/a3.2_kegg_012506.ism', 'ORIGINAL_MOLS/a3.3_kegg_012506.ism') #a3_f2f(sys.argv[1], sys.argv[2])