On 07/06/2010 19:12, Rob Soe wrote: > > I'd like to add information to this molecule, let's say, an arbitrary > floating number as its random ID. > > I saw OBMol class has SetData > <http://openbabel.org/dev-api/classOpenBabel_1_1OBBase.shtml#db6b0ec89bfea783825b3b466e4dbc00> > (OBGenericData > <http://openbabel.org/dev-api/classOpenBabel_1_1OBGenericData.shtml> *d) > and GetData() function but I couldn't find an example how to use such > function. > > May I know if there is a working example using such functions?
If your data can be represented by two strings - a name(aka key or attribute) and a value - the simplest way is to use OBPairData. This class derived from OBGenericData is used for the properties in SDF files. The code OpenBabel uses for reading them (in mdlformat.cpp near lines 558 and 824) provides a working example. Any OBPairData attached to a molecule would be written to an SDF output file, which may or may not be an advantage. In the next OB version, this can be suppressed by making the DataOrigin 'local'. Chris ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss