Interesting hack. Well played. Thanks.
On 24 May 2011 04:44, Greg Landrum <[email protected]> wrote: > On Mon, May 23, 2011 at 12:28 PM, JP <[email protected]> wrote: >> How do you set a property (e.g. energy) for each conformer (instead of >> per molecule) ? >> >> What I am looking for is >> SetProp( (Mol)self, confId, (str)key, (str)val [, (bool)computed=False]) >> >> I want to write these values in an .sdf file. > > There's currently no way to associate properties with a particular conformer. > The most straightforward way to approximate this would be to combine > the values into one hidden property and then pull them out and set > them as the energy property before writing the SDF. > > Something like this (not tested): > > # setting properties: > if mol.HasProp("_ConfEnergies"): > > mol.SetProp("_ConfEnergies","%s|%d:%.4f"%(mol.GetProp("_ConfEnergies"),confId,confEnergy) > > # writing to the SDWriter writer : > confEs={} > vs = [x.split(":") for x in mol.GetProp("_ConfEnergies").split('|')] > for id,e in vs: > confEs[int(id)]=e > > for conf in mol.GetConformers: > mol.SetProp("Energy",confEs[conf.GetId()] > writer.write(mol) > > Hope this helps, > -greg > ------------------------------------------------------------------------------ vRanger cuts backup time in half-while increasing security. With the market-leading solution for virtual backup and recovery, you get blazing-fast, flexible, and affordable data protection. Download your free trial now. http://p.sf.net/sfu/quest-d2dcopy1 _______________________________________________ Rdkit-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

