Hi Paul, On Fri, Sep 10, 2010 at 7:29 PM, Paul Emsley <paul.ems...@bioch.ox.ac.uk> wrote: > > I've been tinkering a bit more with RDKit and having fun.
Glad to hear it. > I have hit a problem though. I am trying to reproduce Greg's "Generating > 3D coordinates" in RDKit-overview.pdf in C++: > > This is what I have (mostly via cut 'n paste): > > > > int > main(int argc, char **argv) { > > std::string smiles_string = "C1CCC1"; > > RDKit::RWMol *mol=new RDKit::RWMol(); > mol = RDKit::SmilesToMol(smiles_string); > RDDepict::compute2DCoords(*mol); > > double vdwThresh=10.0; > int confId = -1; > bool ignoreInterfragInteractions=true; > int maxIters = 200; > > ForceFields::ForceField *ff = > RDKit::UFF::constructForceField(*mol, > vdwThresh, confId, > ignoreInterfragInteractions); > ff->initialize(); > int res=ff->minimize(maxIters); > delete ff; > > std::cout << RDKit::MolToMolBlock(*mol, true, -1) << std::endl; > > return 0; > } > > > But I get 2D coordinates: > > > RDKit 2D > > 5 5 0 0 0 0 0 0 0 0999 V2000 > 1.2879 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 > 0.3980 1.2249 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 > -1.0419 0.7570 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 > -1.0419 -0.7570 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 > 0.3980 -1.2249 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 > 1 2 1 0 > 2 3 1 0 > 3 4 1 0 > 4 5 1 0 > 5 1 1 0 > M END > It's kind of interesting (and encouraging) that the optimizer doesn't completely freak out when you hand it a 2D conformer. :-) > What makes 3D coordinates? (I'm guessing it's a one-liner somewhere...) It is indeed a one-liner (two lines with a bit of error checking). To get a 3D conformer, you need to include <GraphMol/DistGeomHelpers/Embedder.h> and do the following: int cid = DGeomHelpers::EmbedMolecule(*m); if(cid<0) // embedding failed, do something There are a bunch of optional arguments to EmbedMolecule, but the defaults normally work reasonably well. Best Regards, -greg ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss