#!/usr/bin/env python # ch5-2.py from openeye.oechem import * import os, sys mol = OEGraphMol() OEParseSmiles(mol, "c1ccccc1") mol.SetTitle("benzene") # now set some tagged data OESetSDData(mol, 'color', 'brown') OESetSDData(mol, 'size', 'small') OESetSDData(mol, 'natoms', str(mol.NumAtoms())) # loop over data and print it out for dp in OEGetSDDataPairs(mol): sys.stdout.write('%s : %s\n' % (dp.GetTag(), dp.GetValue())) # check for existence of a field, then delete it if OEHasSDData(mol, 'color') == 1: OEDeleteSDData(mol, 'color') # one last loop shows no 'color' field for dp in OEGetSDDataPairs(mol): sys.stdout.write('%s : %s\n' % (dp.GetTag(), dp.GetValue()))