Dear Paul, On Thu, Apr 12, 2012 at 1:05 PM, Paul Emsley <paul.ems...@bioch.ox.ac.uk> wrote: > > > When creating a 2d depiction, or otherwise, is there a way to turn a > carboxylate (with ONEANDAHALF bonds between the carbon and oxygens) into > something with a carbonyl oxygen (DOUBLE) and a hydroxyl oxygen (SINGLE)? >
There's good news and bad news. The good news: You can easily do this with either a reaction or replaceSubstructs(). The bad news: In either case you will need to construct the query molecules in your code manually since there's not currently a way to construct an RDKit molecule containing a ONEANDAHALF bond from a file/string. Here's some (untested) code showing how you might build a reaction that does what you want; I guess C++ is more useful to you than python, right?: // the reactant: RWMol *r1; Atom *at; at = new Atom(6); at->setProp("molAtomMapNumber",1); r1->addAtom(at); at = new Atom(8); at->setProp("molAtomMapNumber",2); r1->addAtom(at); at = new Atom(8); at->setProp("molAtomMapNumber",3); at->setFormalCharge(-1); r1->addAtom(at); r1->addBond(0,1,Bond::ONEANDAHALF); r1->addBond(0,2,Bond::ONEANDAHALF); // the product: RWMol *p1; at = new Atom(6); at->setProp("molAtomMapNumber",1); p1->addAtom(at); at = new Atom(8); at->setProp("molAtomMapNumber",2); p1->addAtom(at); at = new Atom(8); at->setProp("molAtomMapNumber",3); at->setFormalCharge(-1); p1->addAtom(at); p1->addBond(0,1,Bond::DOUBLE); p1->addBond(0,2,Bond::SINGLE); ChemicalReaction rxn2; ROMOL_SPTR rsptr(static_cast<ROMol *>(r1)); rxn2.addReactantTemplate(rsptr); ROMOL_SPTR psptr(static_cast<ROMol *>(p1)); rxn2.addProductTemplate(psptr); rxn2.initReactantMatchers(); Some notes: 1) the above snippet can only work as-is with the most recent version of the RDKit or svn versions starting last month (dating back to when I made the changes to the way atom-atom matches are handled) 2) this will only replace one group at a time. You'll need to call it multiple times, taking the first product each time, until isMoleculeReactantOfReaction(rxn2,mol,0) returns false. An easier approach, but one that will not respect isotopic labels in your input molecule (i.e. they will be lost when you do the transformation) uses replaceSubstructs(). Here's a (also untested) snippet for that: RWMol *r1; Atom *at; at = new Atom(6); r1->addAtom(at); at = new Atom(8); r1->addAtom(at); at = new Atom(8); at->setFormalCharge(-1); r1->addAtom(at); r1->addBond(0,1,Bond::ONEANDAHALF); r1->addBond(0,2,Bond::ONEANDAHALF); // the product: RWMol *p1; at = new Atom(6); p1->addAtom(at); at = new Atom(8); p1->addAtom(at); at = new Atom(8); at->setFormalCharge(-1); p1->addAtom(at); p1->addBond(0,1,Bond::DOUBLE); p1->addBond(0,2,Bond::SINGLE); std::vector<ROMOL_SPTR> nms; nms = replaceSubstructs(*mol1,*r1,*p1,true); Does this help at all? -greg ------------------------------------------------------------------------------ For Developers, A Lot Can Happen In A Second. Boundary is the first to Know...and Tell You. Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! http://p.sf.net/sfu/Boundary-d2dvs2 _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss