From 7a4e342e8cedcfc514dd4d5b74af4d45c1930e1a Mon Sep 17 00:00:00 2001 From: Greg Landrum Date: Sat, 1 Nov 2014 04:03:38 +0100 Subject: [PATCH] basic smiles memory consumption --- Code/GraphMol/SmilesParse/SmilesParse.cpp | 1 + Code/GraphMol/SmilesParse/SmilesParseOps.cpp | 17 +++++++++++++++++ Code/GraphMol/SmilesParse/SmilesParseOps.h | 1 + 3 files changed, 19 insertions(+) diff --git a/Code/GraphMol/SmilesParse/SmilesParse.cpp b/Code/GraphMol/SmilesParse/SmilesParse.cpp index f04efb818..0106a25cc 100644 --- a/Code/GraphMol/SmilesParse/SmilesParse.cpp +++ b/Code/GraphMol/SmilesParse/SmilesParse.cpp @@ -153,6 +153,7 @@ namespace RDKit{ if(res->hasAtomBookmark(ci_RIGHTMOST_ATOM)){ res->clearAtomBookmark(ci_RIGHTMOST_ATOM); } + SmilesParseOps::CleanupAfterParsing(res); molVect[0]=0; // NOTE: to avoid leaks on failures, this should occur last in this if. } } catch (SmilesParseException &e) { diff --git a/Code/GraphMol/SmilesParse/SmilesParseOps.cpp b/Code/GraphMol/SmilesParse/SmilesParseOps.cpp index bc51077f6..882be8269 100644 --- a/Code/GraphMol/SmilesParse/SmilesParseOps.cpp +++ b/Code/GraphMol/SmilesParse/SmilesParseOps.cpp @@ -475,4 +475,21 @@ namespace SmilesParseOps{ } }; + void CleanupAfterParsing(RWMol *mol){ + PRECONDITION(mol,"no molecule"); + for(RWMol::AtomIterator atomIt=mol->beginAtoms(); + atomIt!=mol->endAtoms();++atomIt){ + if((*atomIt)->hasProp("_RingClosures")) + (*atomIt)->clearProp("_RingClosures"); + if((*atomIt)->hasProp("_SmilesStart")) + (*atomIt)->clearProp("_SmilesStart"); + } + for(RWMol::BondIterator bondIt=mol->beginBonds(); + bondIt!=mol->endBonds();++bondIt){ + if((*bondIt)->hasProp("_unspecifiedOrder")) + (*bondIt)->clearProp("_unspecifiedOrder"); + } + } + + } // end of namespace SmilesParseOps diff --git a/Code/GraphMol/SmilesParse/SmilesParseOps.h b/Code/GraphMol/SmilesParse/SmilesParseOps.h index 3ceab7b9f..f9c7ac768 100644 --- a/Code/GraphMol/SmilesParse/SmilesParseOps.h +++ b/Code/GraphMol/SmilesParse/SmilesParseOps.h @@ -27,6 +27,7 @@ namespace SmilesParseOps { const RDKit::Atom *atom2); void CloseMolRings(RDKit::RWMol *mol,bool toleratePartials); void AdjustAtomChiralityFlags(RDKit::RWMol *mol); + void CleanupAfterParsing(RDKit::RWMol *mol); }; #endif