diff --git a/Code/Catalogs/Catalog.h b/Code/Catalogs/Catalog.h index a3054877f..492783f7b 100644 --- a/Code/Catalogs/Catalog.h +++ b/Code/Catalogs/Catalog.h @@ -82,7 +82,7 @@ class Catalog { //------------------------------------ //! sets our parameters by copying the \c params argument - virtual void setCatalogParams(paramType *params) { + virtual void setCatalogParams(const paramType *params) { PRECONDITION(params, "bad parameter object"); // if we already have a paramter object throw an exception PRECONDITION(!dp_cParams, @@ -255,6 +255,7 @@ class HierarchCatalog : public Catalog { paramType *params = new paramType(); params->initFromStream(ss); this->setCatalogParams(params); + delete params; // std::cout << "\tparams: " << getCatalogParams()->getLowerFragLength(); // std::cout << " " << getCatalogParams()->getUpperFragLength(); diff --git a/Code/DistGeom/testDistGeom.cpp b/Code/DistGeom/testDistGeom.cpp index 755498f12..a5f88e732 100644 --- a/Code/DistGeom/testDistGeom.cpp +++ b/Code/DistGeom/testDistGeom.cpp @@ -118,6 +118,9 @@ void testIssue216() { CHECK_INVARIANT(RDKit::feq(ptj.length(), 1.0, 0.02), ""); } } + for (int i = 0; i < 4; i++) { + delete pos[i]; + } } int main() { std::cout << "***********************************************************\n"; diff --git a/Code/ForceField/MMFF/Params.cpp b/Code/ForceField/MMFF/Params.cpp index ad510cec7..82d513c1f 100644 --- a/Code/ForceField/MMFF/Params.cpp +++ b/Code/ForceField/MMFF/Params.cpp @@ -28,19 +28,16 @@ typedef boost::tokenizer > tokenizer; namespace ForceFields { namespace MMFF { -class MMFFAromCollection *MMFFAromCollection::ds_instance = nullptr; +class std::unique_ptr MMFFAromCollection::ds_instance = nullptr; extern const boost::uint8_t defaultMMFFArom[]; MMFFAromCollection *MMFFAromCollection::getMMFFArom( const boost::uint8_t *mmffArom) { - if (!ds_instance) { - ds_instance = new MMFFAromCollection(mmffArom); - } else if (mmffArom) { - delete ds_instance; - ds_instance = new MMFFAromCollection(mmffArom); + if (!ds_instance || mmffArom) { + ds_instance.reset(new MMFFAromCollection(mmffArom)); } - return ds_instance; + return ds_instance.get(); } MMFFAromCollection::MMFFAromCollection(const boost::uint8_t *mmffArom) { @@ -55,18 +52,15 @@ MMFFAromCollection::MMFFAromCollection(const boost::uint8_t *mmffArom) { const boost::uint8_t defaultMMFFArom[] = {37, 38, 39, 44, 58, 59, 63, 64, 65, 66, 69, 76, 78, 79, 80, 81, 82}; -class MMFFDefCollection *MMFFDefCollection::ds_instance = nullptr; +class std::unique_ptr MMFFDefCollection::ds_instance = nullptr; extern const std::string defaultMMFFDef; MMFFDefCollection *MMFFDefCollection::getMMFFDef(const std::string &mmffDef) { - if (!ds_instance) { - ds_instance = new MMFFDefCollection(mmffDef); - } else if (!mmffDef.empty()) { - delete ds_instance; - ds_instance = new MMFFDefCollection(mmffDef); + if (!ds_instance || !mmffDef.empty()) { + ds_instance.reset(new MMFFDefCollection(mmffDef)); } - return ds_instance; + return ds_instance.get(); } MMFFDefCollection::MMFFDefCollection(std::string mmffDef) { @@ -449,19 +443,16 @@ const std::string defaultMMFFDef = "MG+2 99 99 99 99 99 DIPOSITIVE " "MAGNESIUM CATION\n"; -class MMFFPropCollection *MMFFPropCollection::ds_instance = nullptr; +class std::unique_ptr MMFFPropCollection::ds_instance = nullptr; extern const std::string defaultMMFFProp; MMFFPropCollection *MMFFPropCollection::getMMFFProp( const std::string &mmffProp) { - if (!ds_instance) { - ds_instance = new MMFFPropCollection(mmffProp); - } else if (!mmffProp.empty()) { - delete ds_instance; - ds_instance = new MMFFPropCollection(mmffProp); + if (!ds_instance || !mmffProp.empty()) { + ds_instance.reset(new MMFFPropCollection(mmffProp)); } - return ds_instance; + return ds_instance.get(); } MMFFPropCollection::MMFFPropCollection(std::string mmffProp) { @@ -621,19 +612,16 @@ const std::string defaultMMFFProp = "98 29 0 0 0 0 0 0 0\n" "99 12 0 0 0 0 0 0 0\n"; -class MMFFPBCICollection *MMFFPBCICollection::ds_instance = nullptr; +class std::unique_ptr MMFFPBCICollection::ds_instance = nullptr; extern const std::string defaultMMFFPBCI; MMFFPBCICollection *MMFFPBCICollection::getMMFFPBCI( const std::string &mmffPBCI) { - if (!ds_instance) { - ds_instance = new MMFFPBCICollection(mmffPBCI); - } else if (!mmffPBCI.empty()) { - delete ds_instance; - ds_instance = new MMFFPBCICollection(mmffPBCI); + if (!ds_instance || !mmffPBCI.empty()) { + ds_instance.reset(new MMFFPBCICollection(mmffPBCI)); } - return ds_instance; + return ds_instance.get(); } MMFFPBCICollection::MMFFPBCICollection(std::string mmffPBCI) { @@ -780,18 +768,15 @@ const std::string defaultMMFFPBCI = "0 98 2.000 0.000 Ionic charge\n" "0 99 2.000 0.000 Ionic charge\n"; -class MMFFChgCollection *MMFFChgCollection::ds_instance = nullptr; +class std::unique_ptr MMFFChgCollection::ds_instance = nullptr; extern const std::string defaultMMFFChg; MMFFChgCollection *MMFFChgCollection::getMMFFChg(const std::string &mmffChg) { - if (!ds_instance) { - ds_instance = new MMFFChgCollection(mmffChg); - } else if (!mmffChg.empty()) { - delete ds_instance; - ds_instance = new MMFFChgCollection(mmffChg); + if (!ds_instance || !mmffChg.empty()) { + ds_instance.reset(new MMFFChgCollection(mmffChg)); } - return ds_instance; + return ds_instance.get(); } MMFFChgCollection::MMFFChgCollection(std::string mmffChg) { @@ -1352,19 +1337,16 @@ const std::string defaultMMFFChg = "0 79 81 -0.0430 E94\n" "0 80 81 -0.4000 #C94\n"; -class MMFFBondCollection *MMFFBondCollection::ds_instance = nullptr; +class std::unique_ptr MMFFBondCollection::ds_instance = nullptr; extern const std::string defaultMMFFBond; MMFFBondCollection *MMFFBondCollection::getMMFFBond( const std::string &mmffBond) { - if (!ds_instance) { - ds_instance = new MMFFBondCollection(mmffBond); - } else if (!mmffBond.empty()) { - delete ds_instance; - ds_instance = new MMFFBondCollection(mmffBond); + if (!ds_instance || !mmffBond.empty()) { + ds_instance.reset(new MMFFBondCollection(mmffBond)); } - return ds_instance; + return ds_instance.get(); } MMFFBondCollection::MMFFBondCollection(std::string mmffBond) { @@ -1923,19 +1905,16 @@ const std::string defaultMMFFBond = "0 79 81 4.305 1.356 E94\n" "0 80 81 8.237 1.335 C94\n"; -class MMFFBndkCollection *MMFFBndkCollection::ds_instance = nullptr; +class std::unique_ptr MMFFBndkCollection::ds_instance = nullptr; extern const std::string defaultMMFFBndk; MMFFBndkCollection *MMFFBndkCollection::getMMFFBndk( const std::string &mmffBndk) { - if (!ds_instance) { - ds_instance = new MMFFBndkCollection(mmffBndk); - } else if (!mmffBndk.empty()) { - delete ds_instance; - ds_instance = new MMFFBndkCollection(mmffBndk); + if (!ds_instance || !mmffBndk.empty()) { + ds_instance.reset(new MMFFBndkCollection(mmffBndk)); } - return ds_instance; + return ds_instance.get(); } MMFFBndkCollection::MMFFBndkCollection(std::string mmffBndk) { @@ -2048,21 +2027,18 @@ const std::string defaultMMFFBndk = "35 35 2.28 2.4 E94\n" "53 53 2.67 1.6 E94\n"; -class MMFFHerschbachLaurieCollection - *MMFFHerschbachLaurieCollection::ds_instance = nullptr; +class std::unique_ptr + MMFFHerschbachLaurieCollection::ds_instance = nullptr; extern const std::string defaultMMFFHerschbachLaurie; MMFFHerschbachLaurieCollection * MMFFHerschbachLaurieCollection::getMMFFHerschbachLaurie( const std::string &mmffHerschbachLaurie) { - if (!ds_instance) { - ds_instance = new MMFFHerschbachLaurieCollection(mmffHerschbachLaurie); - } else if (!mmffHerschbachLaurie.empty()) { - delete ds_instance; - ds_instance = new MMFFHerschbachLaurieCollection(mmffHerschbachLaurie); + if (!ds_instance || !mmffHerschbachLaurie.empty()) { + ds_instance.reset(new MMFFHerschbachLaurieCollection(mmffHerschbachLaurie)); } - return ds_instance; + return ds_instance.get(); } MMFFHerschbachLaurieCollection::MMFFHerschbachLaurieCollection( @@ -2139,20 +2115,17 @@ const std::string defaultMMFFHerschbachLaurie = "4 4 2.85 1.62 1.62\n" "4 5 2.76 1.25 1.51\n"; -class MMFFCovRadPauEleCollection *MMFFCovRadPauEleCollection::ds_instance = +class std::unique_ptr MMFFCovRadPauEleCollection::ds_instance = nullptr; extern const std::string defaultMMFFCovRadPauEle; MMFFCovRadPauEleCollection *MMFFCovRadPauEleCollection::getMMFFCovRadPauEle( const std::string &mmffCovRadPauEle) { - if (!ds_instance) { - ds_instance = new MMFFCovRadPauEleCollection(mmffCovRadPauEle); - } else if (!mmffCovRadPauEle.empty()) { - delete ds_instance; - ds_instance = new MMFFCovRadPauEleCollection(mmffCovRadPauEle); + if (!ds_instance || !mmffCovRadPauEle.empty()) { + ds_instance.reset(new MMFFCovRadPauEleCollection(mmffCovRadPauEle)); } - return ds_instance; + return ds_instance.get(); } MMFFCovRadPauEleCollection::MMFFCovRadPauEleCollection( @@ -2211,19 +2184,16 @@ const std::string defaultMMFFCovRadPauEle = "35 1.15 2.74\n" "53 1.33 2.21\n"; -class MMFFAngleCollection *MMFFAngleCollection::ds_instance = nullptr; +class std::unique_ptr MMFFAngleCollection::ds_instance = nullptr; extern const std::string defaultMMFFAngleData[]; MMFFAngleCollection *MMFFAngleCollection::getMMFFAngle( const std::string &mmffAngle) { - if (!ds_instance) { - ds_instance = new MMFFAngleCollection(mmffAngle); - } else if (!mmffAngle.empty()) { - delete ds_instance; - ds_instance = new MMFFAngleCollection(mmffAngle); + if (!ds_instance || !mmffAngle.empty()) { + ds_instance.reset(new MMFFAngleCollection(mmffAngle)); } - return ds_instance; + return ds_instance.get(); } MMFFAngleCollection::MMFFAngleCollection(std::string mmffAngle) { @@ -4645,19 +4615,16 @@ const std::string defaultMMFFAngleData[] = { "0 64 82 65 1.281 112.955 E94\n", "EOS"}; -class MMFFStbnCollection *MMFFStbnCollection::ds_instance = nullptr; +class std::unique_ptr MMFFStbnCollection::ds_instance = nullptr; extern const std::string defaultMMFFStbn; MMFFStbnCollection *MMFFStbnCollection::getMMFFStbn( const std::string &mmffStbn) { - if (!ds_instance) { - ds_instance = new MMFFStbnCollection(mmffStbn); - } else if (!mmffStbn.empty()) { - delete ds_instance; - ds_instance = new MMFFStbnCollection(mmffStbn); + if (!ds_instance || !mmffStbn.empty()) { + ds_instance.reset(new MMFFStbnCollection(mmffStbn)); } - return ds_instance; + return ds_instance.get(); } MMFFStbnCollection::MMFFStbnCollection(std::string mmffStbn) { @@ -5008,19 +4975,16 @@ const std::string defaultMMFFStbn = "0 36 81 80 0.018 0.422 C94\n" "0 78 81 80 0.366 0.419 C94\n"; -class MMFFDfsbCollection *MMFFDfsbCollection::ds_instance = nullptr; +class std::unique_ptr MMFFDfsbCollection::ds_instance = nullptr; extern const std::string defaultMMFFDfsb; MMFFDfsbCollection *MMFFDfsbCollection::getMMFFDfsb( const std::string &mmffDfsb) { - if (!ds_instance) { - ds_instance = new MMFFDfsbCollection(mmffDfsb); - } else if (!mmffDfsb.empty()) { - delete ds_instance; - ds_instance = new MMFFDfsbCollection(mmffDfsb); + if (!ds_instance || !mmffDfsb.empty()) { + ds_instance.reset(new MMFFDfsbCollection(mmffDfsb)); } - return ds_instance; + return ds_instance.get(); } MMFFDfsbCollection::MMFFDfsbCollection(std::string mmffDfsb) { @@ -5091,7 +5055,7 @@ const std::string defaultMMFFDfsb = "3 2 4 0.25 0.25\n" "4 2 4 0.25 0.25\n"; -class MMFFOopCollection *MMFFOopCollection::ds_instance[2] = {nullptr, nullptr}; +class std::unique_ptr MMFFOopCollection::ds_instance[2] = {nullptr, nullptr}; extern const std::string defaultMMFFOop; extern const std::string defaultMMFFsOop; @@ -5099,13 +5063,10 @@ extern const std::string defaultMMFFsOop; MMFFOopCollection *MMFFOopCollection::getMMFFOop(const bool isMMFFs, const std::string &mmffOop) { unsigned int i = (isMMFFs ? 1 : 0); - if (!ds_instance[i]) { - ds_instance[i] = new MMFFOopCollection(isMMFFs, mmffOop); - } else if (!mmffOop.empty()) { - delete ds_instance[i]; - ds_instance[i] = new MMFFOopCollection(isMMFFs, mmffOop); + if (!ds_instance[i] || !mmffOop.empty()) { + ds_instance[i] = std::unique_ptr(new MMFFOopCollection(isMMFFs, mmffOop)); } - return ds_instance[i]; + return ds_instance[i].get(); } MMFFOopCollection::MMFFOopCollection(const bool isMMFFs, std::string mmffOop) { @@ -5417,7 +5378,7 @@ const std::string defaultMMFFsOop = "36 81 78 80 0.016 C94\n" "0 82 0 0 0.000 *-82-*-* E94 DEF\n"; -class MMFFTorCollection *MMFFTorCollection::ds_instance[2] = {nullptr, nullptr}; +class std::unique_ptr MMFFTorCollection::ds_instance[2] = {nullptr, nullptr}; extern const std::string defaultMMFFTor; extern const std::string defaultMMFFsTor; @@ -5425,13 +5386,10 @@ extern const std::string defaultMMFFsTor; MMFFTorCollection *MMFFTorCollection::getMMFFTor(const bool isMMFFs, const std::string &mmffTor) { unsigned int i = (isMMFFs ? 1 : 0); - if (!ds_instance[i]) { - ds_instance[i] = new MMFFTorCollection(isMMFFs, mmffTor); - } else if (!mmffTor.empty()) { - delete ds_instance[i]; - ds_instance[i] = new MMFFTorCollection(isMMFFs, mmffTor); + if (!ds_instance[i] || !mmffTor.empty()) { + ds_instance[i] = std::unique_ptr(new MMFFTorCollection(isMMFFs, mmffTor)); } - return ds_instance[i]; + return ds_instance[i].get(); } MMFFTorCollection::MMFFTorCollection(const bool isMMFFs, std::string mmffTor) { @@ -8429,18 +8387,15 @@ const std::string defaultMMFFsTor = "0 0 80 81 0 0.000 4.000 0.000 C94 " "0:*-80-81-* Def\n"; -class MMFFVdWCollection *MMFFVdWCollection::ds_instance = nullptr; +class std::unique_ptr MMFFVdWCollection::ds_instance = nullptr; extern const std::string defaultMMFFVdW; MMFFVdWCollection *MMFFVdWCollection::getMMFFVdW(const std::string &mmffVdW) { - if (!ds_instance) { - ds_instance = new MMFFVdWCollection(mmffVdW); - } else if (!mmffVdW.empty()) { - delete ds_instance; - ds_instance = new MMFFVdWCollection(mmffVdW); + if (!ds_instance || !mmffVdW.empty()) { + ds_instance.reset(new MMFFVdWCollection(mmffVdW)); } - return ds_instance; + return ds_instance.get(); } MMFFVdWCollection::MMFFVdWCollection(std::string mmffVdW) { diff --git a/Code/ForceField/MMFF/Params.h b/Code/ForceField/MMFF/Params.h index a90acf310..def69fc55 100644 --- a/Code/ForceField/MMFF/Params.h +++ b/Code/ForceField/MMFF/Params.h @@ -13,6 +13,7 @@ #ifndef __RD_MMFFPARAMS_H__ #define __RD_MMFFPARAMS_H__ +#include #include #include #include @@ -190,7 +191,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFAromCollection { private: //! to force this to be a singleton, the constructor must be private MMFFAromCollection(const boost::uint8_t mmffArom[]); - static class MMFFAromCollection *ds_instance; //!< the singleton + static class std::unique_ptr ds_instance; //!< the singleton std::vector d_params; //!< the aromatic type vector }; @@ -235,7 +236,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFDefCollection { private: //! to force this to be a singleton, the constructor must be private MMFFDefCollection(std::string mmffDef); - static class MMFFDefCollection *ds_instance; //!< the singleton + static class std::unique_ptr ds_instance; //!< the singleton #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map d_params; //!< the parameter map #else @@ -287,7 +288,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFPropCollection { private: //! to force this to be a singleton, the constructor must be private MMFFPropCollection(std::string mmffProp); - static class MMFFPropCollection *ds_instance; //!< the singleton + static class std::unique_ptr ds_instance; //!< the singleton #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map d_params; //!< the parameter map #else @@ -336,7 +337,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFPBCICollection { private: //! to force this to be a singleton, the constructor must be private MMFFPBCICollection(std::string mmffPBCI); - static class MMFFPBCICollection *ds_instance; //!< the singleton + static class std::unique_ptr ds_instance; //!< the singleton #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map d_params; //!< the parameter map #else @@ -420,7 +421,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFChgCollection { private: //! to force this to be a singleton, the constructor must be private MMFFChgCollection(std::string mmffChg); - static class MMFFChgCollection *ds_instance; //!< the singleton + static class std::unique_ptr ds_instance; //!< the singleton //!< the parameter 3D-map #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map< @@ -515,7 +516,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFBondCollection { private: //! to force this to be a singleton, the constructor must be private MMFFBondCollection(std::string mmffBond); - static class MMFFBondCollection *ds_instance; //!< the singleton + static class std::unique_ptr ds_instance; //!< the singleton #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map< const unsigned int, @@ -594,7 +595,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFBndkCollection { private: //! to force this to be a singleton, the constructor must be private MMFFBndkCollection(std::string mmffBndk); - static class MMFFBndkCollection *ds_instance; //!< the singleton + static class std::unique_ptr ds_instance; //!< the singleton #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map > d_params; //!< the parameter 2D-map @@ -673,7 +674,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFHerschbachLaurieCollection { private: //! to force this to be a singleton, the constructor must be private MMFFHerschbachLaurieCollection(std::string mmffHerschbachLaurie); - static class MMFFHerschbachLaurieCollection *ds_instance; //!< the singleton + static class std::unique_ptr ds_instance; //!< the singleton #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map > @@ -733,7 +734,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFCovRadPauEleCollection { private: //! to force this to be a singleton, the constructor must be private MMFFCovRadPauEleCollection(std::string mmffCovRadPauEle); - static class MMFFCovRadPauEleCollection *ds_instance; //!< the singleton + static class std::unique_ptr ds_instance; //!< the singleton #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map d_params; //!< the parameter map @@ -860,7 +861,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFAngleCollection { private: //! to force this to be a singleton, the constructor must be private MMFFAngleCollection(std::string mmffAngle); - static class MMFFAngleCollection *ds_instance; //!< the singleton + static class std::unique_ptr ds_instance; //!< the singleton #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map ds_instance; //!< the singleton #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map ds_instance; //!< the singleton std::map< const unsigned int, std::map > > @@ -1177,7 +1178,7 @@ class RDKIT_FORCEFIELD_EXPORT MMFFOopCollection { private: //! to force this to be a singleton, the constructor must be private MMFFOopCollection(const bool isMMFFs, std::string mmffOop); - static class MMFFOopCollection *ds_instance[2]; //!< the singleton + static class std::unique_ptr ds_instance[2]; //!< the singleton #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map ds_instance[2]; //!< the singleton #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map ds_instance; //!< the singleton #ifdef RDKIT_MMFF_PARAMS_USE_STD_MAP std::map d_params; //!< the parameter map #else diff --git a/Code/ForceField/MMFF/testMMFFForceField.cpp b/Code/ForceField/MMFF/testMMFFForceField.cpp index 8d6db32b6..17a465374 100644 --- a/Code/ForceField/MMFF/testMMFFForceField.cpp +++ b/Code/ForceField/MMFF/testMMFFForceField.cpp @@ -396,11 +396,15 @@ int mmffValidationSuite(int argc, char *argv[]) { sdfWriter->write(*mol); rdkFStream << "\nTOTAL MMFF ENERGY =" << std::right << std::setw(16) << std::fixed << std::setprecision(4) - << field->calcEnergy() << "\n\n" << std::endl; + << field->calcEnergy() << "\n\n" + << std::endl; delete field; } + delete mmffMolProperties; } + BOOST_FOREACH (ROMol *m, molVec) { delete m; } sdfWriter->close(); + delete sdfWriter; rdkFStream.close(); std::cerr << "Checking against " << ref << "..." << std::endl; rdkFStream.open(rdk.c_str(), std::fstream::in | std::fstream::binary); @@ -637,8 +641,9 @@ int mmffValidationSuite(int argc, char *argv[]) { std::stringstream diff; diff << "Bond stretching: found a difference\n"; if (haveLine) { - diff << "Expected:\n" << rdkLine << "\nFound:\n" << refLine - << "\n"; + diff << "Expected:\n" + << rdkLine << "\nFound:\n" + << refLine << "\n"; } errorMsg += diff.str(); } @@ -792,8 +797,9 @@ int mmffValidationSuite(int argc, char *argv[]) { std::stringstream diff; diff << "Angle bending: found a difference\n"; if (haveLine) { - diff << "Expected:\n" << rdkLine << "\nFound:\n" << refLine - << "\n"; + diff << "Expected:\n" + << rdkLine << "\nFound:\n" + << refLine << "\n"; } errorMsg += diff.str(); } @@ -952,8 +958,9 @@ int mmffValidationSuite(int argc, char *argv[]) { std::stringstream diff; diff << "Stretch-bending: found a difference\n"; if (haveLine) { - diff << "Expected:\n" << rdkLine << "\nFound:\n" << refLine - << "\n"; + diff << "Expected:\n" + << rdkLine << "\nFound:\n" + << refLine << "\n"; } errorMsg += diff.str(); } @@ -1108,8 +1115,9 @@ int mmffValidationSuite(int argc, char *argv[]) { std::stringstream diff; diff << "Out-of-plane bending: found a difference\n"; if (haveLine) { - diff << "Expected:\n" << rdkLine << "\nFound:\n" << refLine - << "\n"; + diff << "Expected:\n" + << rdkLine << "\nFound:\n" + << refLine << "\n"; } errorMsg += diff.str(); } @@ -1216,6 +1224,8 @@ int mmffValidationSuite(int argc, char *argv[]) { ForceFields::MMFF::isDoubleZero(refTorsionEnergy))) { fixTorsionInstance(torsionInstance); refTorsionInstanceVec.push_back(torsionInstance); + } else { + delete torsionInstance; } ++n; } @@ -1275,14 +1285,15 @@ int mmffValidationSuite(int argc, char *argv[]) { std::stringstream diff; diff << "Torsional: found a difference\n"; if (haveLine) { - diff << "Expected:\n" << rdkLine << "\nFound:\n" << refLine - << "\n"; + diff << "Expected:\n" + << rdkLine << "\nFound:\n" + << refLine << "\n"; } errorMsg += diff.str(); } - delete rdkTorsionInstanceVec[j]; - delete refTorsionInstanceVec[j]; } + for (auto &ti : rdkTorsionInstanceVec) { delete ti; } + for (auto &ti : refTorsionInstanceVec) { delete ti; } error = (fabs(rdkEnergy - refEnergy) > ENERGY_TOLERANCE); if (error && checkEnergy) { failed = true; diff --git a/Code/ForceField/UFF/Params.cpp b/Code/ForceField/UFF/Params.cpp index b87b4b49b..f465d0aa5 100644 --- a/Code/ForceField/UFF/Params.cpp +++ b/Code/ForceField/UFF/Params.cpp @@ -26,23 +26,19 @@ typedef boost::tokenizer > tokenizer; namespace ForceFields { namespace UFF { -class ParamCollection *ParamCollection::ds_instance = nullptr; +class std::unique_ptr ParamCollection::ds_instance = nullptr; extern const std::string defaultParamData; ParamCollection *ParamCollection::getParams(const std::string ¶mData) { - if (ds_instance == nullptr) { - ds_instance = new ParamCollection(paramData); - } else if (paramData != "") { - delete ds_instance; - ds_instance = nullptr; - ds_instance = new ParamCollection(paramData); + if (ds_instance == nullptr || !paramData.empty()) { + ds_instance.reset(new ParamCollection(paramData)); } - return ds_instance; + return ds_instance.get(); } ParamCollection::ParamCollection(std::string paramData) { - if (paramData == "") paramData = defaultParamData; + if (paramData.empty()) paramData = defaultParamData; std::istringstream inStream(paramData); std::string inLine = RDKit::getLine(inStream); diff --git a/Code/ForceField/UFF/Params.h b/Code/ForceField/UFF/Params.h index 411b1a01c..c076e9f90 100644 --- a/Code/ForceField/UFF/Params.h +++ b/Code/ForceField/UFF/Params.h @@ -11,6 +11,7 @@ #ifndef __RD_UFFPARAMS_H__ #define __RD_UFFPARAMS_H__ +#include #include #include #include @@ -145,7 +146,7 @@ class RDKIT_FORCEFIELD_EXPORT ParamCollection { private: //! to force this to be a singleton, the constructor must be private ParamCollection(std::string paramData); - static class ParamCollection *ds_instance; //!< the singleton + static class std::unique_ptr ds_instance; //!< the singleton std::map d_params; //!< the parameter map }; } diff --git a/Code/GraphMol/ChemReactions/DaylightParser.cpp b/Code/GraphMol/ChemReactions/DaylightParser.cpp index e67e04cce..a6a76d8dc 100644 --- a/Code/GraphMol/ChemReactions/DaylightParser.cpp +++ b/Code/GraphMol/ChemReactions/DaylightParser.cpp @@ -105,18 +105,18 @@ ROMol *constructMolFromString(const std::string &txt, ChemicalReaction *RxnSmartsToChemicalReaction( const std::string &text, std::map *replacements, bool useSmiles) { - std::size_t pos1 = text.find(">"); - std::size_t pos2 = text.rfind(">"); + std::size_t pos1 = text.find('>'); + std::size_t pos2 = text.rfind('>'); if (pos1 == std::string::npos) { throw ChemicalReactionParserException( "a reaction requires at least one reactant and one product"); } - if (text.find(">", pos1 + 1) != pos2) { + if (text.find('>', pos1 + 1) != pos2) { throw ChemicalReactionParserException("multi-step reactions not supported"); } std::string reactText = text.substr(0, pos1); - std::string agentText = ""; + std::string agentText; if (pos2 != pos1 + 1) { agentText = text.substr(pos1 + 1, (pos2 - pos1) - 1); } @@ -140,6 +140,7 @@ ChemicalReaction *RxnSmartsToChemicalReaction( if (!mol) { std::string errMsg = "Problems constructing reactant from SMARTS: "; errMsg += txt; + delete rxn; throw ChemicalReactionParserException(errMsg); } rxn->addReactantTemplate(ROMOL_SPTR(mol)); @@ -152,6 +153,7 @@ ChemicalReaction *RxnSmartsToChemicalReaction( if (!mol) { std::string errMsg = "Problems constructing product from SMARTS: "; errMsg += txt; + delete rxn; throw ChemicalReactionParserException(errMsg); } rxn->addProductTemplate(ROMOL_SPTR(mol)); @@ -166,6 +168,7 @@ ChemicalReaction *RxnSmartsToChemicalReaction( if (!agentMol) { std::string errMsg = "Problems constructing agent from SMARTS: "; errMsg += agentText; + delete rxn; throw ChemicalReactionParserException(errMsg); } std::vector agents = MolOps::getMolFrags(*agentMol, false); diff --git a/Code/GraphMol/ChemReactions/MDLParser.cpp b/Code/GraphMol/ChemReactions/MDLParser.cpp index 639746be5..fc1d0e624 100644 --- a/Code/GraphMol/ChemReactions/MDLParser.cpp +++ b/Code/GraphMol/ChemReactions/MDLParser.cpp @@ -66,13 +66,13 @@ void ParseV2000RxnBlock(std::istream &inStream, unsigned int &line, if (inStream.eof()) { throw ChemicalReactionParserException("premature EOF hit."); } - rxn = new ChemicalReaction(); unsigned int nReacts = 0, nProds = 0, nAgents = 0; unsigned int spos = 0; if (tempStr.size() < 6) { throw ChemicalReactionParserException("rxn counts line is too short"); } + rxn = new ChemicalReaction(); try { nReacts = FileParserUtils::stripSpacesAndCast(tempStr.substr(0, 3)); @@ -90,8 +90,6 @@ void ParseV2000RxnBlock(std::istream &inStream, unsigned int &line, } } } catch (boost::bad_lexical_cast &) { - delete rxn; - rxn = nullptr; std::ostringstream errout; errout << "Cannot convert " << tempStr.substr(spos, 3) << " to int"; throw ChemicalReactionParserException(errout.str()); @@ -178,8 +176,6 @@ void ParseV3000RxnBlock(std::istream &inStream, unsigned int &line, tempStr = getLine(inStream); line++; - rxn = new ChemicalReaction(); - tempStr = FileParserUtils::getV3000Line(&inStream, line); boost::to_upper(tempStr); tempStr = boost::trim_copy(tempStr); @@ -203,6 +199,7 @@ void ParseV3000RxnBlock(std::istream &inStream, unsigned int &line, if (tempStr.length() < 14 || tempStr.substr(0, 14) != "BEGIN REACTANT") { throw FileParseException("BEGIN REACTANT line not found"); } + rxn = new ChemicalReaction(); for (unsigned int i = 0; i < nReacts; ++i) { RWMol *react; unsigned int natoms, nbonds; @@ -214,11 +211,10 @@ void ParseV3000RxnBlock(std::istream &inStream, unsigned int &line, chiralityPossible, natoms, nbonds, true, false); } catch (FileParseException &e) { - delete react; - react = nullptr; std::ostringstream errout; errout << "Cannot parse reactant " << i << ". The error was:\n\t" << e.message(); + delete react; throw ChemicalReactionParserException(errout.str()); } if (!react) { @@ -229,11 +225,13 @@ void ParseV3000RxnBlock(std::istream &inStream, unsigned int &line, tempStr = FileParserUtils::getV3000Line(&inStream, line); boost::to_upper(tempStr); if (tempStr.length() < 12 || tempStr.substr(0, 12) != "END REACTANT") { + delete rxn; throw FileParseException("END REACTANT line not found"); } tempStr = FileParserUtils::getV3000Line(&inStream, line); boost::to_upper(tempStr); if (tempStr.length() < 13 || tempStr.substr(0, 13) != "BEGIN PRODUCT") { + delete rxn; throw FileParseException("BEGIN PRODUCT line not found"); } for (unsigned int i = 0; i < nProds; ++i) { @@ -247,11 +245,10 @@ void ParseV3000RxnBlock(std::istream &inStream, unsigned int &line, chiralityPossible, natoms, nbonds, true, false); } catch (FileParseException &e) { - delete prod; - prod = nullptr; std::ostringstream errout; errout << "Cannot parse product " << i << ". The error was:\n\t" << e.message(); + delete prod; throw ChemicalReactionParserException(errout.str()); } if (!prod) { @@ -262,6 +259,7 @@ void ParseV3000RxnBlock(std::istream &inStream, unsigned int &line, tempStr = FileParserUtils::getV3000Line(&inStream, line); boost::to_upper(tempStr); if (tempStr.length() < 11 || tempStr.substr(0, 11) != "END PRODUCT") { + delete rxn; throw FileParseException("END PRODUCT line not found"); } @@ -269,6 +267,7 @@ void ParseV3000RxnBlock(std::istream &inStream, unsigned int &line, tempStr = FileParserUtils::getV3000Line(&inStream, line); boost::to_upper(tempStr); if (tempStr.length() < 14 || tempStr.substr(0, 14) != "BEGIN AGENT") { + delete rxn; throw FileParseException("BEGIN AGENT line not found"); } } @@ -283,11 +282,10 @@ void ParseV3000RxnBlock(std::istream &inStream, unsigned int &line, chiralityPossible, natoms, nbonds, true, false); } catch (FileParseException &e) { - delete agent; - agent = nullptr; std::ostringstream errout; errout << "Cannot parse agent " << i << ". The error was:\n\t" << e.message(); + delete agent; throw ChemicalReactionParserException(errout.str()); } rxn->addAgentTemplate(ROMOL_SPTR(dynamic_cast(agent))); @@ -296,6 +294,7 @@ void ParseV3000RxnBlock(std::istream &inStream, unsigned int &line, tempStr = FileParserUtils::getV3000Line(&inStream, line); boost::to_upper(tempStr); if (tempStr.length() < 12 || tempStr.substr(0, 12) != "END AGENT") { + delete rxn; throw FileParseException("END AGENT line not found"); } } diff --git a/Code/GraphMol/ChemReactions/testReaction.cpp b/Code/GraphMol/ChemReactions/testReaction.cpp index ec8fd3d09..fc44dc8d3 100644 --- a/Code/GraphMol/ChemReactions/testReaction.cpp +++ b/Code/GraphMol/ChemReactions/testReaction.cpp @@ -745,6 +745,7 @@ void test8Validation() { TEST_ASSERT(rxn->validate(nWarn, nError, true)); TEST_ASSERT(nWarn == 0); TEST_ASSERT(nError == 0); + delete rxn; smi = "[C:1](=[O:2])[O:5].[N:3][C:4]>>[C:1](=[O:2])[N:3][C:4]"; rxn = RxnSmartsToChemicalReaction(smi); @@ -752,6 +753,7 @@ void test8Validation() { TEST_ASSERT(rxn->validate(nWarn, nError, true)); TEST_ASSERT(nWarn == 1); TEST_ASSERT(nError == 0); + delete rxn; smi = "[C:1](=[O:2])O.[N:1][C:4]>>[C:1](=[O:2])[N:3][C:4]"; rxn = RxnSmartsToChemicalReaction(smi); @@ -759,6 +761,7 @@ void test8Validation() { TEST_ASSERT(!rxn->validate(nWarn, nError, true)); TEST_ASSERT(nWarn == 1); TEST_ASSERT(nError == 1); + delete rxn; smi = "[C:1](=[O:2])O.[N:3][C:4]>>[C:1](=[O:2])[N:3][C:5]"; rxn = RxnSmartsToChemicalReaction(smi); @@ -766,6 +769,7 @@ void test8Validation() { TEST_ASSERT(rxn->validate(nWarn, nError, true)); TEST_ASSERT(nWarn == 2); TEST_ASSERT(nError == 0); + delete rxn; smi = "[C:1](=[O:2])O.[N:3][C:4]>>[C:1](=[O:2])[N:3][C:1]"; rxn = RxnSmartsToChemicalReaction(smi); @@ -2461,6 +2465,7 @@ void test23Pickling() { TEST_ASSERT(prods[0].size() == 1); TEST_ASSERT(prods[0][0]->getNumAtoms() == 8); TEST_ASSERT(MolToSmiles(*prods[0][0]) == "O=C1CNC(=O)CN1"); + delete rxn; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; @@ -2859,6 +2864,7 @@ void test27SmartsWriter() { TEST_ASSERT(rxn->validate(nWarn, nError, false)); TEST_ASSERT(nWarn == 0); TEST_ASSERT(nError == 0); + delete rxn; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; @@ -2908,6 +2914,7 @@ void test28RxnDepictor() { TEST_ASSERT((*templIt)->getNumConformers() == 1); TEST_ASSERT(!(*templIt)->getConformer().is3D()); } + delete rxn; } { // make sure the depiction doesn't screw up the reaction itself std::string rdbase = getenv("RDBASE"); @@ -2941,8 +2948,8 @@ void test28RxnDepictor() { TEST_ASSERT(prods[0].size() == 1); TEST_ASSERT(prods[0][0]->getNumAtoms() == 8); TEST_ASSERT(MolToSmiles(*prods[0][0]) == "O=C1CNC(=O)CN1"); + delete rxn; } - { std::string smi = "[#7;!H0:1]>>[#7:1]C"; ChemicalReaction *rxn = RxnSmartsToChemicalReaction(smi); @@ -3015,6 +3022,7 @@ void test29RxnWriter() { TEST_ASSERT(rxn->validate(nWarn, nError, false)); TEST_ASSERT(nWarn == 0); TEST_ASSERT(nError == 0); + delete rxn; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -3196,6 +3204,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 1); + delete rxn; } { // no changes std::string smi; @@ -3207,6 +3216,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 0); + delete rxn; } { // make sure atomic number queries work: std::string smi; @@ -3218,6 +3228,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 0); + delete rxn; } { // query in the reactants, dummy in product std::string smi; @@ -3229,8 +3240,8 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 0); + delete rxn; } - { // recursive query in the reactants without an atomic number query std::string smi; smi = "[$(O):1][C:2]>>[O:1][C:2]"; @@ -3241,6 +3252,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 1); + delete rxn; } { // recursive query with atomic number query std::string smi; @@ -3252,6 +3264,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 0); + delete rxn; } { // recursive query with atomic number query, alternate ordering // FIX: this returns a changed atom (since we don't know the atomic @@ -3265,6 +3278,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 1); + delete rxn; } { // recursive query in the reactants, dummy in products std::string smi; @@ -3276,6 +3290,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 0); + delete rxn; } { // query with degree/H info in the reactants: std::string smi; @@ -3287,6 +3302,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 0); + delete rxn; } { // dummy in the reactants, dummy in products std::string smi; @@ -3298,6 +3314,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 0); + delete rxn; } { // two reactants, one changes std::string smi; @@ -3310,6 +3327,7 @@ void test33ReactingAtoms1() { TEST_ASSERT(ratoms.size() == 2); TEST_ASSERT(ratoms[0].size() == 1); TEST_ASSERT(ratoms[1].size() == 0); + delete rxn; } { // two reactants, one changes, reordered std::string smi; @@ -3322,6 +3340,7 @@ void test33ReactingAtoms1() { TEST_ASSERT(ratoms.size() == 2); TEST_ASSERT(ratoms[0].size() == 1); TEST_ASSERT(ratoms[1].size() == 0); + delete rxn; } { // dummies for duplicating atom properties std::string smi; @@ -3334,6 +3353,7 @@ void test33ReactingAtoms1() { TEST_ASSERT(ratoms.size() == 2); TEST_ASSERT(ratoms[0].size() == 1); TEST_ASSERT(ratoms[1].size() == 0); + delete rxn; } { // query in the reactants, dummy in products std::string smi; @@ -3345,6 +3365,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 0); + delete rxn; } { // changed degree std::string smi; @@ -3357,6 +3378,7 @@ void test33ReactingAtoms1() { TEST_ASSERT(ratoms.size() == 2); TEST_ASSERT(ratoms[0].size() == 1); TEST_ASSERT(ratoms[1].size() == 1); + delete rxn; } { // unmapped atoms in reactants: std::string smi; @@ -3368,6 +3390,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 2); + delete rxn; } { // don't return info about unmapped atoms: std::string smi; @@ -3379,6 +3402,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn, true); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 1); + delete rxn; } { // changing atom order std::string smi; @@ -3390,6 +3414,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 0); + delete rxn; } { // changing bond order std::string smi; @@ -3401,6 +3426,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 2); + delete rxn; } { // changing bond orders std::string smi; @@ -3412,6 +3438,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 3); + delete rxn; } { // query bond order std::string smi; @@ -3423,6 +3450,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 0); + delete rxn; } { // changing connectivity std::string smi; @@ -3434,6 +3462,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 3); + delete rxn; } { // changing connectivity 2 std::string smi; @@ -3445,6 +3474,7 @@ void test33ReactingAtoms1() { VECT_INT_VECT ratoms = getReactingAtoms(*rxn); TEST_ASSERT(ratoms.size() == 1); TEST_ASSERT(ratoms[0].size() == 2); + delete rxn; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -3465,6 +3495,7 @@ void test34ReactingAtoms2() { TEST_ASSERT(ratoms.size() == 2); TEST_ASSERT(ratoms[0].size() == 2); TEST_ASSERT(ratoms[1].size() == 1); + delete rxn; } { std::string rdbase = getenv("RDBASE"); @@ -3478,6 +3509,7 @@ void test34ReactingAtoms2() { TEST_ASSERT(ratoms.size() == 2); TEST_ASSERT(ratoms[0].size() == 3); TEST_ASSERT(ratoms[1].size() == 3); + delete rxn; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; @@ -3547,36 +3579,40 @@ void test35ParensInReactants1() { rxn = nullptr; } TEST_ASSERT(!rxn); + delete rxn; } { std::string smi = "[C:1](=O)O.([C:2]>>[C:1][C:2]"; ChemicalReaction *rxn = nullptr; try { rxn = RxnSmartsToChemicalReaction(smi); + TEST_ASSERT(!rxn); } catch (const ChemicalReactionParserException &e) { - rxn = nullptr; + ; } - TEST_ASSERT(!rxn); + delete rxn; } { std::string smi = "[C:1](=O)O).[C:2]>>[C:1][C:2]"; ChemicalReaction *rxn = nullptr; try { rxn = RxnSmartsToChemicalReaction(smi); + TEST_ASSERT(!rxn); } catch (const ChemicalReactionParserException &e) { - rxn = nullptr; + ; } - TEST_ASSERT(!rxn); + delete rxn; } { std::string smi = "[C:1](=O)O.[C:2])>>[C:1][C:2]"; ChemicalReaction *rxn = nullptr; try { rxn = RxnSmartsToChemicalReaction(smi); + TEST_ASSERT(!rxn); } catch (const ChemicalReactionParserException &e) { - rxn = nullptr; + ; } - TEST_ASSERT(!rxn); + delete rxn; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; @@ -3939,6 +3975,7 @@ void test40AgentsInSmarts() { TEST_ASSERT(rxn); TEST_ASSERT(rxn->getNumReactantTemplates() == 2); TEST_ASSERT(rxn->getNumProductTemplates() == 1); + delete rxn; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -3973,6 +4010,7 @@ void test41Github233() { MolOps::sanitizeMol(*(static_cast(prods[0][0].get()))); smi = MolToSmiles(*prods[0][0], true); TEST_ASSERT(smi == "O[C@H](Br)CC(F)Cl"); + delete rxn; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -4167,8 +4205,8 @@ void test45SmilesWriter() { smi = ChemicalReactionToRxnSmiles(*rxn); TEST_ASSERT(smi == res) TEST_ASSERT(smi == "[C:1]=[O:2].[N:3]>>[C:1](=[O:2])~[N:3]"); - delete rxn; + rxn = RxnSmartsToChemicalReaction(smi, nullptr, true); TEST_ASSERT(rxn); TEST_ASSERT(rxn->getNumReactantTemplates() == 2); @@ -4177,6 +4215,7 @@ void test45SmilesWriter() { TEST_ASSERT(rxn->validate(nWarn, nError, false)); TEST_ASSERT(nWarn == 0); TEST_ASSERT(nError == 0); + delete rxn; } { std::string smi; @@ -4208,6 +4247,7 @@ void test45SmilesWriter() { TEST_ASSERT(rxn); TEST_ASSERT(rxn->getNumReactantTemplates() == 2); TEST_ASSERT(rxn->getNumProductTemplates() == 1); + delete rxn; } { std::string smi; @@ -4240,6 +4280,7 @@ void test45SmilesWriter() { TEST_ASSERT(rxn); TEST_ASSERT(rxn->getNumReactantTemplates() == 2); TEST_ASSERT(rxn->getNumProductTemplates() == 1); + delete rxn; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; @@ -4644,40 +4685,44 @@ void test48ParensInProducts1() { ChemicalReaction *rxn = nullptr; try { rxn = RxnSmartsToChemicalReaction(smi); + TEST_ASSERT(!rxn); } catch (const ChemicalReactionParserException &e) { - rxn = nullptr; + ; } - TEST_ASSERT(!rxn); + delete rxn; } { std::string smi = "[C:1](=O)O.[C:2]>>[C:1].([C:2]"; ChemicalReaction *rxn = nullptr; try { rxn = RxnSmartsToChemicalReaction(smi); + TEST_ASSERT(!rxn); } catch (const ChemicalReactionParserException &e) { - rxn = nullptr; + ; } - TEST_ASSERT(!rxn); + delete rxn; } { std::string smi = "[C:1](=O)O.[C:2]>>[C:1][C:2])"; ChemicalReaction *rxn = nullptr; try { rxn = RxnSmartsToChemicalReaction(smi); + TEST_ASSERT(!rxn); } catch (const ChemicalReactionParserException &e) { - rxn = nullptr; + ; } - TEST_ASSERT(!rxn); + delete rxn; } { std::string smi = "[C:1](=O)O.[C:2]>>[C:1]).[C:2]"; ChemicalReaction *rxn = nullptr; try { rxn = RxnSmartsToChemicalReaction(smi); + TEST_ASSERT(!rxn); } catch (const ChemicalReactionParserException &e) { - rxn = nullptr; + ; } - TEST_ASSERT(!rxn); + delete rxn; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; @@ -5067,6 +5112,7 @@ void test54RedundantProductMappingNumbersAndRSChirality() { TEST_ASSERT(prod->getAtomWithIdx(4)->hasProp(common_properties::_CIPCode)); prod->getAtomWithIdx(4)->getProp(common_properties::_CIPCode, cip); TEST_ASSERT(cip == "S"); + delete rxn; } { // invert the stereo chemistry of one carbon of the reactant in the product @@ -5109,6 +5155,7 @@ void test54RedundantProductMappingNumbersAndRSChirality() { TEST_ASSERT(prod->getAtomWithIdx(4)->hasProp(common_properties::_CIPCode)); prod->getAtomWithIdx(4)->getProp(common_properties::_CIPCode, cip); TEST_ASSERT(cip == "R"); + delete rxn; } { // Both carbons in the product (mapped with #2), should be (S) @@ -5735,6 +5782,7 @@ void test60RunSingleReactant() { ROMol *sidechain = reduceProductToSideChains(prod[prodidx]); std::string smi = MolToSmiles(*sidechain, isomericSmiles); TEST_ASSERT(smi == expected_sidechain); + delete sidechain; } } @@ -5760,6 +5808,7 @@ void test60RunSingleReactant() { ROMol *sidechain = reduceProductToSideChains(prod[prodidx]); std::string smi = MolToSmiles(*sidechain, isomericSmiles); TEST_ASSERT(smi == expected_sidechain); + delete sidechain; } } @@ -6639,8 +6688,8 @@ void testGithub1950() { smi = MolToSmiles(*prods[0][0]); TEST_ASSERT(smi == "CCOc1ccccc1"); + delete rxn; } - { // a modification using MRV SMA auto fName = rdbase + "/Code/GraphMol/ChemReactions/testData/github1950_2.rxn"; @@ -6669,6 +6718,7 @@ void testGithub1950() { smi = MolToSmiles(*prods[0][0]); std::cerr << smi << std::endl; TEST_ASSERT(smi == "CCOc1ccccc1"); + delete rxn; } { // make sure we didn't break anything, @@ -6698,6 +6748,7 @@ void testGithub1950() { smi = MolToSmiles(*prods[0][0]); TEST_ASSERT(smi == "CCOc1ccccc1"); + delete rxn; } BOOST_LOG(rdInfoLog) << "Done" << std::endl; } diff --git a/Code/GraphMol/ChemTransforms/ChemTransforms.cpp b/Code/GraphMol/ChemTransforms/ChemTransforms.cpp index 6b443170c..2d6b1b2f8 100644 --- a/Code/GraphMol/ChemTransforms/ChemTransforms.cpp +++ b/Code/GraphMol/ChemTransforms/ChemTransforms.cpp @@ -58,9 +58,7 @@ ROMol *deleteSubstructs(const ROMol &mol, const ROMol &query, bool onlyFrags, RWMol *res = static_cast(new ROMol(mol, false)); std::vector fgpMatches; std::vector::const_iterator mati; - std::pair amat; - VECT_INT_VECT - matches; // all matches on the molecule - list of list of atom ids + VECT_INT_VECT matches; // all matches on the molecule - list of list of atom ids MatchVectType::const_iterator mi; // do the substructure matching and get the atoms that match the query const bool uniquify = true; @@ -701,8 +699,9 @@ void addRecursiveQueries( if (!at->hasQuery()) { QueryAtom qAt(*at); - static_cast(mol).replaceAtom(at->getIdx(), &qAt); - at = mol.getAtomWithIdx(at->getIdx()); + unsigned int idx = at->getIdx(); + static_cast(mol).replaceAtom(idx, &qAt); + at = mol.getAtomWithIdx(idx); } at->expandQuery(qToAdd, Queries::COMPOSITE_AND); } diff --git a/Code/GraphMol/ChemTransforms/testChemTransforms.cpp b/Code/GraphMol/ChemTransforms/testChemTransforms.cpp index 591247ef8..a1744c9c8 100644 --- a/Code/GraphMol/ChemTransforms/testChemTransforms.cpp +++ b/Code/GraphMol/ChemTransforms/testChemTransforms.cpp @@ -39,38 +39,41 @@ void testDeleteSubstruct() { sma = "C=O"; matcher1 = SmartsToMol(sma); TEST_ASSERT(matcher1); - mol2 = deleteSubstructs(*mol1, *matcher1, 0); + delete mol1; TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 2) - mol2 = deleteSubstructs(*mol2, *matcher1, 0); + mol1 = deleteSubstructs(*mol2, *matcher1, 0); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 2) - delete matcher1; + delete mol1; + delete mol2; + sma = "[Cl;H1&X1,-]"; matcher1 = SmartsToMol(sma); sma = "[Na+]"; matcher2 = SmartsToMol(sma); sma = "[O;H2,H1&-,X0&-2]"; matcher3 = SmartsToMol(sma); - delete mol1; mol1 = SmilesToMol("CCO.Cl"); TEST_ASSERT(mol1); TEST_ASSERT(mol1->getNumAtoms() == 4); - - delete mol2; mol2 = deleteSubstructs(*mol1, *matcher1, true); - TEST_ASSERT(mol2); - TEST_ASSERT(mol2->getNumAtoms() == 3); - mol2 = deleteSubstructs(*mol2, *matcher2, true); - TEST_ASSERT(mol2); - TEST_ASSERT(mol2->getNumAtoms() == 3); - mol2 = deleteSubstructs(*mol2, *matcher3, true); - TEST_ASSERT(mol2); - TEST_ASSERT(mol2->getNumAtoms() == 3); - delete mol1; + TEST_ASSERT(mol2); + TEST_ASSERT(mol2->getNumAtoms() == 3); + mol1 = deleteSubstructs(*mol2, *matcher2, true); + delete mol1; + TEST_ASSERT(mol2); + TEST_ASSERT(mol2->getNumAtoms() == 3); + mol1 = deleteSubstructs(*mol2, *matcher3, true); + delete mol1; + TEST_ASSERT(mol2); + TEST_ASSERT(mol2->getNumAtoms() == 3); + delete mol2; + delete matcher3; + mol1 = SmilesToMol("CC(=O)[O-].[Na+]"); TEST_ASSERT(mol1); TEST_ASSERT(mol1->getNumAtoms() == 5); @@ -81,16 +84,20 @@ void testDeleteSubstruct() { matcher2 = SmartsToMol("[Na+]"); mol2 = deleteSubstructs(*mol1, *matcher1, true); + delete mol1; TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 5); - - mol2 = deleteSubstructs(*mol2, *matcher2, true); - TEST_ASSERT(mol2); - TEST_ASSERT(mol2->getNumAtoms() == 4); - - mol2 = deleteSubstructs(*mol2, *matcher1, true); - TEST_ASSERT(mol2); - TEST_ASSERT(mol2->getNumAtoms() == 4); + mol1 = deleteSubstructs(*mol2, *matcher2, true); + delete mol2; + TEST_ASSERT(mol1); + TEST_ASSERT(mol1->getNumAtoms() == 4); + mol2 = deleteSubstructs(*mol1, *matcher1, true); + TEST_ASSERT(mol1); + TEST_ASSERT(mol1->getNumAtoms() == 4); + delete mol2; + delete mol1; + delete matcher1; + delete matcher2; // test chiralty smi = "CCO[C@H](N)(P)"; @@ -107,6 +114,7 @@ void testDeleteSubstruct() { smi1 = MolToSmiles(*mol2, true); std::cerr << "1 smi: " << smi1 << std::endl; TEST_ASSERT(smi1 == "CC"); + delete mol2; delete matcher1; matcher1 = SmartsToMol("O[C@@H](N)(P)"); @@ -227,6 +235,7 @@ void testReplaceSubstructs() { TEST_ASSERT(vect.size() == 1); smi1 = MolToSmiles(*vect[0], true); TEST_ASSERT(smi1 == "CCNCC"); + delete mol1; smi = "CCP([C@@H](N)O)CC"; mol1 = SmilesToMol(smi); @@ -243,7 +252,10 @@ void testReplaceSubstructs() { TEST_ASSERT(vect.size() == 1); smi1 = MolToSmiles(*vect[0], true); std::cerr << "replaceSub smi1:" << smi1 << std::endl; - ; + delete mol1; + delete frag; + delete matcher1; + // no change TEST_ASSERT(smi1 == "CCNCC"); @@ -285,6 +297,7 @@ void testReplaceSubstructs2() { std::string csmi2 = MolToSmiles(*vect[0], true); TEST_ASSERT(csmi2 == csmi1); delete mol1; + delete frag; delete matcher1; } @@ -309,37 +322,36 @@ void testReplaceSidechains() { mol2 = replaceSidechains(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 6); - + delete mol2; delete mol1; + smi = "ClC1C(F)C1"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); mol2 = replaceSidechains(*mol1, *matcher1); TEST_ASSERT(!mol2); + delete mol1; + delete mol2; delete matcher1; sma = "C=O"; matcher1 = SmartsToMol(sma); TEST_ASSERT(matcher1); - delete mol1; smi = "CC=O"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - - delete mol2; mol2 = replaceSidechains(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 3); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*]C=O"); - delete mol1; + delete mol2; + smi = "CC(C)=O"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - - delete mol2; mol2 = replaceSidechains(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 4); @@ -389,86 +401,79 @@ void testReplaceCore() { TEST_ASSERT(matcher1); mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(!mol2); + delete mol1; + delete mol2; + delete matcher1; smi = "ClC1CC(F)C1"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - sma = "C1CCC1"; matcher1 = SmartsToMol(sma); TEST_ASSERT(matcher1); - mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 4); smi = MolToSmiles(*mol2, true); // there's no way to guarantee the order here: TEST_ASSERT(smi == "[1*]Cl.[2*]F" || smi == "[2*]Cl.[1*]F"); - delete mol1; + delete mol2; + delete matcher1; + smi = "CCC=O"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - - delete matcher1; sma = "C=O"; matcher1 = SmartsToMol(sma); TEST_ASSERT(matcher1); - - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 3); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*]CC"); - delete mol1; + delete mol2; + delete matcher1; + smi = "C1C(=O)CC1"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - - delete matcher1; sma = "C=O"; matcher1 = SmartsToMol(sma); TEST_ASSERT(matcher1); - - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 5); smi = MolToSmiles(*mol2, true); // there's no way to guarantee the order here: TEST_ASSERT(smi == "[1*]CCC[2*]" || smi == "[1*]CCC[2*]"); - delete mol1; + delete mol2; + delete matcher1; + smi = "CNC"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - - delete matcher1; sma = "N"; matcher1 = SmartsToMol(sma); TEST_ASSERT(matcher1); - - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 4); smi = MolToSmiles(*mol2, true); // there's no way to guarantee the order here: TEST_ASSERT(smi == "[1*]C.[2*]C" || smi == "[2*]C.[1*]C"); - delete mol1; + delete mol2; + delete matcher1; + smi = "OC1CCC1"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - - delete matcher1; sma = "[CH2][CH2][CH2]"; matcher1 = SmartsToMol(sma); TEST_ASSERT(matcher1); - - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); smi = MolToSmiles(*mol2, true); @@ -476,18 +481,16 @@ void testReplaceCore() { smi = MolToSmiles(*mol2, true); // there's no way to guarantee the order here: TEST_ASSERT(smi == "[2*]C([1*])O" || smi == "[1*]C([2*])O"); - delete mol1; + delete mol2; + delete matcher1; + smi = "C/C=C/CN/C=C/O"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - - delete matcher1; sma = "N"; matcher1 = SmartsToMol(sma); TEST_ASSERT(matcher1); - - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 9); @@ -495,146 +498,149 @@ void testReplaceCore() { // there's no way to guarantee the order here: TEST_ASSERT(smi == "[1*]C/C=C/C.[2*]/C=C/O" || smi == "[1*]/C=C/O.[2*]C/C=C/C"); - delete mol1; + delete mol2; + delete matcher1; + smi = "C[C@](F)(Cl)N"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - delete matcher1; sma = "N"; matcher1 = SmartsToMol(sma); TEST_ASSERT(matcher1); - - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 5); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*][C@@](C)(F)Cl"); delete mol1; + delete mol2; + smi = "C[C@](F)(N)Cl"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 5); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*][C@](C)(F)Cl"); delete mol1; + delete mol2; + smi = "N[C@](C)(F)Cl"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 5); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*][C@](C)(F)Cl"); - delete mol1; + delete mol2; + delete matcher1; + smi = "C[C@@](F)(Cl)N"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - delete matcher1; sma = "N"; matcher1 = SmartsToMol(sma); TEST_ASSERT(matcher1); - - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 5); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*][C@](C)(F)Cl"); delete mol1; + delete mol2; + smi = "C[C@@](F)(N)Cl"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 5); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*][C@@](C)(F)Cl"); smi = "C[C@@](N)(Cl)F"; + delete mol1; + delete mol2; + mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 5); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*][C@@](C)(F)Cl"); - delete mol1; + delete mol2; + delete matcher1; + smi = "C[C@H](F)N"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - delete matcher1; sma = "N"; matcher1 = SmartsToMol(sma); TEST_ASSERT(matcher1); - - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 4); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*][C@H](C)F"); delete mol1; + delete mol2; + smi = "C[C@H](N)F"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 4); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*][C@@H](C)F"); - delete mol1; + delete mol2; + smi = "N[C@H](C)F"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 4); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*][C@H](C)F"); delete mol1; + delete mol2; + smi = "F[C@H](C)N"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 4); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*][C@@H](C)F"); - delete mol1; + delete mol2; + smi = "N[C@H]1CCCO1"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - delete mol2; mol2 = replaceCore(*mol1, *matcher1); TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 6); smi = MolToSmiles(*mol2, true); TEST_ASSERT(smi == "[1*][C@H]1CCCO1"); - delete mol1; + delete mol2; + delete matcher1; + smi = "ClC1CC(F)C1"; mol1 = SmilesToMol(smi); TEST_ASSERT(mol1); - - delete matcher1; sma = "*C1CC(*)C1"; matcher1 = SmartsToMol(sma); TEST_ASSERT(matcher1); - mol2 = replaceCore(*mol1, *matcher1, false); TEST_ASSERT(mol2); smi = MolToSmiles(*mol2, true); @@ -883,6 +889,10 @@ void testReplaceCoreCrash() { TEST_ASSERT(mol2); TEST_ASSERT(mol2->getNumAtoms() == 6); smi = MolToSmiles(*mol2, true); + delete mol1; + delete mol2; + delete matcher1; + // there's no way to guarantee the order here: TEST_ASSERT(smi == "[1*]CC.[2*]CC" || smi == "[2*]CC.[1*]CC"); BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; @@ -932,6 +942,9 @@ void testReplaceCorePositions() { TEST_ASSERT(feq(op.x, np.x)); TEST_ASSERT(feq(op.y, np.y)); TEST_ASSERT(feq(op.z, np.z)); + delete mol1; + delete mol2; + delete matcher1; BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -1184,6 +1197,9 @@ void testIssue3453144() { TEST_ASSERT(feq(op.x, np.x)); TEST_ASSERT(feq(op.y, np.y)); TEST_ASSERT(feq(op.z, np.z)); + delete mol1; + delete matcher1; + delete replacement; BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -1233,8 +1249,10 @@ void testCombineMols() { (mol1->getNumAtoms() + mol2->getNumAtoms())); MolOps::findSSSR(*mol3); TEST_ASSERT(mol3->getRingInfo()->numRings() == 2); + delete mol1; + delete mol2; + delete mol3; } - { std::string pathName = getenv("RDBASE"); pathName += "/Code/GraphMol/ChemTransforms/testData/ethanol.mol"; @@ -1266,6 +1284,9 @@ void testCombineMols() { mol3->getConformer().getAtomPos(3).y)); TEST_ASSERT(feq(mol3->getConformer().getAtomPos(0).z, mol3->getConformer().getAtomPos(3).z)); + delete mol1; + delete mol2; + delete mol3; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; @@ -2002,6 +2023,7 @@ void testGithub1734() { smi = MolToSmiles(*nmol, true); TEST_ASSERT(smi == "[16*]c1ccccc1.[4*][C@]([8*])(C)I.[5*]NC"); delete mol; + delete nmol; } { // The original example std::string smi = "c1ccccc1[C@H](C)NC"; @@ -2014,6 +2036,7 @@ void testGithub1734() { smi = MolToSmiles(*nmol, true); TEST_ASSERT(smi == "[16*]c1ccccc1.[4*][C@H]([8*])C.[5*]NC"); delete mol; + delete nmol; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } diff --git a/Code/GraphMol/Depictor/testDepictor.cpp b/Code/GraphMol/Depictor/testDepictor.cpp index 1a8ea917b..6222f1fdb 100644 --- a/Code/GraphMol/Depictor/testDepictor.cpp +++ b/Code/GraphMol/Depictor/testDepictor.cpp @@ -190,6 +190,7 @@ void test2() { // wmol = static_cast(mol); RDDepict::compute2DCoords(*mol); writer.write(*mol); + delete mol; } catch (FileParseException &) { break; } @@ -213,6 +214,7 @@ void test3() { // wmol = static_cast(mol); RDDepict::compute2DCoords(*mol); writer.write(*mol); + delete mol; } catch (FileParseException &) { break; } diff --git a/Code/GraphMol/Descriptors/EEM.cpp b/Code/GraphMol/Descriptors/EEM.cpp index ba4e6f26f..8d2a94406 100644 --- a/Code/GraphMol/Descriptors/EEM.cpp +++ b/Code/GraphMol/Descriptors/EEM.cpp @@ -42,11 +42,6 @@ namespace RDKit { namespace Descriptors { namespace { -struct EEM_arrays { - unsigned int *Atomindex; - unsigned int *EEMatomtype; -}; - // Those Parameters change to adapted to the molecule dataset using the // optimization method: The best parameters published in the NEEMP article // (https://jcheminf.springeropen.com/articles/10.1186/s13321-016-0171-1), are @@ -127,7 +122,7 @@ unsigned int getAtomtype(const ROMol &mol, const RDKit::Atom *atom) { } std::unique_ptr getEEMMatrix(double *dist3D, unsigned int n, - EEM_arrays EEMatoms) { + const EEM_arrays& EEMatoms) { PRECONDITION(dist3D != nullptr, "bad dist3D argument") int sizeArray = (n + 1) * (n + 1); double *EEM = @@ -184,22 +179,29 @@ std::unique_ptr getBVector(const ROMol &mol, unsigned int n, return std::unique_ptr(b); } -EEM_arrays calculate_EEM_parameters(ROMol mol, unsigned int n) { +EEM_arrays::EEM_arrays(const ROMol &mol, unsigned int sz) : n(sz) { /* Fill vector b i.e. -A */ - unsigned int *a = new unsigned int[n]; - unsigned int *b = new unsigned int[n]; + Atomindex = new unsigned int[n]; + EEMatomtype = new unsigned int[n]; for (unsigned int j = 0; j < n; j++) { - b[j] = getAtomtype(mol, mol.getAtomWithIdx(j)); - a[j] = mol.getAtomWithIdx(j)->getAtomicNum(); + EEMatomtype[j] = getAtomtype(mol, mol.getAtomWithIdx(j)); + Atomindex[j] = mol.getAtomWithIdx(j)->getAtomicNum(); } +} - return EEM_arrays{a, b}; +EEM_arrays::~EEM_arrays() { + if (Atomindex != nullptr) { + delete[] Atomindex; + } + if (EEMatomtype != nullptr) { + delete[] EEMatomtype; + } } /* Calculate charges for a particular kappa_data structure */ void calculate_charges(ROMol mol, double *dist3D, unsigned int numAtoms, - EEM_arrays EEMatoms, std::vector &res) { + const EEM_arrays& EEMatoms, std::vector &res) { std::unique_ptr A = getEEMMatrix(dist3D, numAtoms, EEMatoms); std::unique_ptr b = getBVector(mol, numAtoms, EEMatoms); @@ -220,7 +222,7 @@ void getEEMs(const ROMol &mol, std::vector &result, unsigned int numAtoms, int confId) { // 3D distance matrix double *dist3D = MolOps::get3DDistanceMat(mol, confId, false, true); - EEM_arrays EEMatoms = calculate_EEM_parameters(mol, numAtoms); + EEM_arrays EEMatoms(mol, numAtoms); result.clear(); result.resize(numAtoms); diff --git a/Code/GraphMol/Descriptors/EEM.h b/Code/GraphMol/Descriptors/EEM.h index 8b0a5770a..c22bb9140 100644 --- a/Code/GraphMol/Descriptors/EEM.h +++ b/Code/GraphMol/Descriptors/EEM.h @@ -34,9 +34,26 @@ namespace RDKit { class ROMol; namespace Descriptors { + + namespace { + class EEM_arrays { + public: + unsigned int n; + unsigned int *Atomindex; + unsigned int *EEMatomtype; + + EEM_arrays() = delete; + EEM_arrays(const EEM_arrays&) = delete; + void operator=(const EEM_arrays&) = delete; + + EEM_arrays(const ROMol &mol, unsigned int n); + ~EEM_arrays(); + }; + } + const std::string EEMVersion = "1.0.0"; void RDKIT_DESCRIPTORS_EXPORT EEM(ROMol &mol, std::vector &res, int confId); } } #endif -#endif \ No newline at end of file +#endif diff --git a/Code/GraphMol/Descriptors/test.cpp b/Code/GraphMol/Descriptors/test.cpp index c01776004..85cb26303 100644 --- a/Code/GraphMol/Descriptors/test.cpp +++ b/Code/GraphMol/Descriptors/test.cpp @@ -210,6 +210,8 @@ void test3() { mol = SmilesToMol("C[2H]"); TEST_ASSERT(mol); amw = calcAMW(*mol); + delete mol; + TEST_ASSERT(feq(amw, 17.0, .1)); BOOST_LOG(rdErrorLog) << " done" << std::endl; @@ -813,6 +815,7 @@ void testIssue3433771() { TEST_ASSERT(mol); calcCrippenDescriptors(*mol, logp, mr); TEST_ASSERT(feq(logp, 1.806, .001)); + delete mol; BOOST_LOG(rdErrorLog) << " done" << std::endl; } @@ -1529,6 +1532,7 @@ void testMQNs() { ROMol *test_mol = SmilesToMol("CC(C)(C)c1cc(O)c(cc1O)C(C)(C)C", 0, sanitize); if (calcNumRotatableBonds(*test_mol) == 2) tgt[18] = 26; + delete test_mol; } std::vector accum(42, 0); @@ -1901,6 +1905,7 @@ void testProperties() { sink.annotateProperties(*mol); TEST_ASSERT(mol->getProp("NumSpiroAtoms") == 1.); TEST_ASSERT(mol->getProp("NumBridgeheadAtoms") == 2.); + delete mol; } { @@ -1931,16 +1936,20 @@ void testPropertyQueries() { } { - // these leak.. - TEST_ASSERT( - makePropertyQuery("exactmw", calcExactMW(*mol)) - ->Match(*mol)); - TEST_ASSERT(makePropertyQuery("NumHBA", calcNumHBA(*mol)) - ->Match(*mol)); - TEST_ASSERT(makePropertyQuery("lipinskiHBA", - calcLipinskiHBA(*mol)) - ->Match(*mol)); + auto pq = std::unique_ptr( + makePropertyQuery("exactmw", calcExactMW(*mol))); + TEST_ASSERT(pq->Match(*mol)); + + pq = std::unique_ptr( + makePropertyQuery("NumHBA", calcNumHBA(*mol))); + TEST_ASSERT(pq->Match(*mol)); + + pq = + std::unique_ptr(makePropertyQuery( + "lipinskiHBA", calcLipinskiHBA(*mol))); + TEST_ASSERT(pq->Match(*mol)); } + delete mol; } void testStereoCounting() { @@ -1966,6 +1975,7 @@ void testStereoCounting() { std::vector res = prop.computeProperties(*m); TEST_ASSERT(res[0] == 1); TEST_ASSERT(res[1] == 1); + delete m; } void testUSRDescriptor() { @@ -1981,6 +1991,7 @@ void testUSRDescriptor() { } catch (ConformerException &e) { ok = true; } + delete mol; TEST_ASSERT(ok); // number of atoms < 3 @@ -1991,6 +2002,7 @@ void testUSRDescriptor() { } catch (ValueErrorException &e) { ok = true; } + delete mol; TEST_ASSERT(ok); // DESCRIPTOR @@ -2010,6 +2022,7 @@ void testUSRDescriptor() { for (unsigned int i = 0; i < myUSR.size(); ++i) { TEST_ASSERT(feq(myUSR[i], refUSR[i])); } + delete mol; BOOST_LOG(rdErrorLog) << " done" << std::endl; } diff --git a/Code/GraphMol/Descriptors/test3D.cpp b/Code/GraphMol/Descriptors/test3D.cpp index 3dc73948c..a5dd5caf7 100644 --- a/Code/GraphMol/Descriptors/test3D.cpp +++ b/Code/GraphMol/Descriptors/test3D.cpp @@ -188,12 +188,14 @@ void testPMIEdges() { { RDKit::RWMol m; - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); + bool updateLabel = true; + bool takeOwnership = true; + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); m.addConformer(new RDKit::Conformer(m.getNumAtoms())); double val = RDKit::Descriptors::PMI1(m); TEST_ASSERT(fabs(val) < 1e-4); @@ -353,12 +355,14 @@ void testNPREdges() { } { RDKit::RWMol m; - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); + bool updateLabel = true; + bool takeOwnership = true; + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); m.addConformer(new RDKit::Conformer(m.getNumAtoms())); double val = RDKit::Descriptors::NPR1(m); TEST_ASSERT(fabs(val) < 1e-4); @@ -437,12 +441,14 @@ void test3DEdges() { BOOST_LOG(rdErrorLog) << " 3D descriptor edge cases." << std::endl; { // octahedron RDKit::RWMol m; - m.addAtom(new RDKit::Atom(1)); - m.addAtom(new RDKit::Atom(1)); - m.addAtom(new RDKit::Atom(1)); - m.addAtom(new RDKit::Atom(1)); - m.addAtom(new RDKit::Atom(1)); - m.addAtom(new RDKit::Atom(1)); + bool updateLabel = true; + bool takeOwnership = true; + m.addAtom(new RDKit::Atom(1), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(1), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(1), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(1), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(1), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(1), updateLabel, takeOwnership); m.addConformer(new RDKit::Conformer(m.getNumAtoms())); m.getConformer().setAtomPos(0, RDGeom::Point3D(1, 0, 0)); m.getConformer().setAtomPos(1, RDGeom::Point3D(-1, 0, 0)); @@ -463,12 +469,14 @@ void test3DEdges() { { RDKit::RWMol m; - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); + bool updateLabel = true; + bool takeOwnership = true; + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); m.addConformer(new RDKit::Conformer(m.getNumAtoms())); double val; val = RDKit::Descriptors::radiusOfGyration(m); diff --git a/Code/GraphMol/Descriptors/testPBF.cpp b/Code/GraphMol/Descriptors/testPBF.cpp index ca27cfe4e..8d4f88cf0 100644 --- a/Code/GraphMol/Descriptors/testPBF.cpp +++ b/Code/GraphMol/Descriptors/testPBF.cpp @@ -98,12 +98,14 @@ void testPBFEdges(){ } { RDKit::RWMol m; - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); - m.addAtom(new RDKit::Atom(6)); + bool updateLabel = true; + bool takeOwnership = true; + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); + m.addAtom(new RDKit::Atom(6), updateLabel, takeOwnership); m.addConformer(new RDKit::Conformer(m.getNumAtoms())); double dpbf=RDKit::Descriptors::PBF(m); TEST_ASSERT(dpbf<=1e-4); diff --git a/Code/GraphMol/DistGeomHelpers/testDgeomHelpers.cpp b/Code/GraphMol/DistGeomHelpers/testDgeomHelpers.cpp index 59ed83b31..8c84c43f1 100644 --- a/Code/GraphMol/DistGeomHelpers/testDgeomHelpers.cpp +++ b/Code/GraphMol/DistGeomHelpers/testDgeomHelpers.cpp @@ -368,6 +368,7 @@ void test3() { ""); } } + delete mol; } } @@ -565,6 +566,7 @@ void testMultipleConfs() { TEST_ASSERT(energy < 300.0); delete ff; } + delete m; } void testMultipleConfsExpTors() { @@ -587,6 +589,7 @@ void testMultipleConfsExpTors() { TEST_ASSERT(energy < 300.0); delete ff; } + delete m; } void testOrdering() { @@ -646,6 +649,7 @@ void testIssue236() { DGeomHelpers::setTopolBounds(*m, bm); bool ok = DistGeom::triangleSmoothBounds(bm); TEST_ASSERT(ok); + delete m; smi = "Cc1cccc2c1c(C3=CCC3)c(C)cc2"; m = SmilesToMol(smi, 0, 1); @@ -1017,6 +1021,7 @@ void testConstrainedEmbedding() { TEST_ASSERT(ssd < 0.1); delete test; } + delete ref; } void testIssue2091864() { @@ -1400,7 +1405,8 @@ void testGithub256() { #ifdef RDK_TEST_MULTITHREADED void testMultiThreadMultiConf() { boost::char_separator sep("|"); - tokenizer tokens(std::string(RDKit::rdkitBuild), sep); + auto bldString = std::string(RDKit::rdkitBuild); + tokenizer tokens(bldString, sep); std::vector tokenVect(tokens.begin(), tokens.end()); const double ENERGY_TOLERANCE = ((tokenVect[2] != "MINGW") ? 1.0e-6 : 1.0); const double MSD_TOLERANCE = ((tokenVect[2] != "MINGW") ? 1.0e-6 : 1.0e-5); @@ -1439,6 +1445,7 @@ void testMultiThreadMultiConf() { delete ff; delete ff2; } + delete m; } #endif @@ -1450,10 +1457,12 @@ void testGithub563() { std::cerr << csmi << std::endl; for (unsigned int i = 1; i < 100; ++i) { ROMol m2 = ROMol(*m); - MolOps::addHs(m2); + auto *tmpMol = MolOps::addHs(m2); + delete tmpMol; DGeomHelpers::EmbedMolecule(m2, 50, i); MolOps::assignChiralTypesFrom3D(m2); - MolOps::removeHs(m2); + auto *tmp = MolOps::removeHs(m2); + delete tmp; std::string smi = MolToSmiles(m2, true); TEST_ASSERT(smi == csmi); } diff --git a/Code/GraphMol/FMCS/Test/testFMCS.cpp b/Code/GraphMol/FMCS/Test/testFMCS.cpp index f4429e59a..6eae54fde 100644 --- a/Code/GraphMol/FMCS/Test/testFMCS.cpp +++ b/Code/GraphMol/FMCS/Test/testFMCS.cpp @@ -872,6 +872,7 @@ void testChEMBL_TxtALL_chembl_II_sets(double th = 1.0) { testsmi.c_str(), "chembl_II_sets.P.res.csv"); // command for the same Python test } + fclose(fcmd); } void testChEMBL_TxtSLOW_chembl_II_sets(double th = 1.0) { @@ -1220,11 +1221,15 @@ void testFileSDF_RandomSet(const char* test = "chembl13-10000-random-pairs.sdf", } catch (...) { std::cout << "ERROR: RDKit could not load input file" << "\n"; + fclose(fcsv); + fclose(fcmd); return; } if (!suppl) { std::cout << "ERROR: unsupported input file format" << "\n"; + fclose(fcsv); + fclose(fcmd); return; } // commands for prepare Python test: @@ -1246,6 +1251,9 @@ void testFileSDF_RandomSet(const char* test = "chembl13-10000-random-pairs.sdf", FILE* fsmi = fopen(smiName, "wt"); if (!fsmi) { std::cout << "ERROR: could not create SMI file " << smiName << "\n"; + delete suppl; + fclose(fcsv); + fclose(fcmd); return; } ROMol* m = nullptr; diff --git a/Code/GraphMol/FileParsers/MaeMolSupplier.cpp b/Code/GraphMol/FileParsers/MaeMolSupplier.cpp index 6f30faf40..32eaaa96c 100644 --- a/Code/GraphMol/FileParsers/MaeMolSupplier.cpp +++ b/Code/GraphMol/FileParsers/MaeMolSupplier.cpp @@ -43,7 +43,7 @@ MaeMolSupplier::MaeMolSupplier(const std::string &fileName, bool sanitize, bool errout << "Bad input file " << fileName; throw BadFileException(errout.str()); } - dp_inStream = (std::istream *)ifs; + dp_inStream = static_cast(ifs); df_sanitize = sanitize; df_removeHs = removeHs; diff --git a/Code/GraphMol/FileParsers/MolFileParser.cpp b/Code/GraphMol/FileParsers/MolFileParser.cpp index aa2a2407d..654014fa8 100644 --- a/Code/GraphMol/FileParsers/MolFileParser.cpp +++ b/Code/GraphMol/FileParsers/MolFileParser.cpp @@ -956,7 +956,7 @@ void ParseNewAtomList(RWMol *mol, const std::string &text, unsigned int line) { } std::string atSymb = text.substr(pos, 4); - atSymb.erase(atSymb.find(" "), atSymb.size()); + atSymb.erase(atSymb.find(' '), atSymb.size()); int atNum = PeriodicTable::getTable()->getAtomicNumber(atSymb); if (!i) { a = new QueryAtom(*(mol->getAtomWithIdx(idx))); @@ -980,10 +980,12 @@ void ParseNewAtomList(RWMol *mol, const std::string &text, unsigned int line) { std::ostringstream errout; errout << "Unrecognized atom-list query modifier: " << text[14] << " on line " << line; + delete a; throw FileParseException(errout.str()); } mol->replaceAtom(idx, a); + delete a; }; void ParseV3000RGroups(RWMol *mol, Atom *&atom, const std::string &text, @@ -1145,7 +1147,6 @@ void ParseAtomValue(RWMol *mol, std::string text, unsigned int line) { Atom *ParseMolFileAtomLine(const std::string text, RDGeom::Point3D &pos, unsigned int line) { - auto *res = new Atom; std::string symb; int massDiff, chg, hCount; @@ -1201,6 +1202,7 @@ Atom *ParseMolFileAtomLine(const std::string text, RDGeom::Point3D &pos, throw FileParseException(errout.str()); } } + auto *res = new Atom; if (symb == "L" || symb == "A" || symb == "Q" || symb == "*" || symb == "LP" || symb == "R" || symb == "R#" || (symb[0] == 'R' && symb >= "R0" && symb <= "R99")) { @@ -1277,6 +1279,7 @@ Atom *ParseMolFileAtomLine(const std::string text, RDGeom::Point3D &pos, std::ostringstream errout; errout << "Cannot convert " << text.substr(39, 3) << " to int on line " << line; + delete res; throw FileParseException(errout.str()); } res->setProp(common_properties::molParity, parity); @@ -1290,6 +1293,7 @@ Atom *ParseMolFileAtomLine(const std::string text, RDGeom::Point3D &pos, std::ostringstream errout; errout << "Cannot convert " << text.substr(45, 3) << " to int on line " << line; + delete res; throw FileParseException(errout.str()); } res->setProp("molStereoCare", stereoCare); @@ -1302,6 +1306,7 @@ Atom *ParseMolFileAtomLine(const std::string text, RDGeom::Point3D &pos, std::ostringstream errout; errout << "Cannot convert " << text.substr(48, 3) << " to int on line " << line; + delete res; throw FileParseException(errout.str()); } if (totValence != 0) { @@ -1317,6 +1322,7 @@ Atom *ParseMolFileAtomLine(const std::string text, RDGeom::Point3D &pos, std::ostringstream errout; errout << "Cannot convert " << text.substr(54, 3) << " to int on line " << line; + delete res; throw FileParseException(errout.str()); } if (rxnRole != 0) { @@ -1332,6 +1338,7 @@ Atom *ParseMolFileAtomLine(const std::string text, RDGeom::Point3D &pos, std::ostringstream errout; errout << "Cannot convert " << text.substr(57, 3) << " to int on line " << line; + delete res; throw FileParseException(errout.str()); } if (rxnComponent != 0) { @@ -1347,6 +1354,7 @@ Atom *ParseMolFileAtomLine(const std::string text, RDGeom::Point3D &pos, std::ostringstream errout; errout << "Cannot convert " << text.substr(60, 3) << " to int on line " << line; + delete res; throw FileParseException(errout.str()); } res->setProp(common_properties::molAtomMapNumber, atomMapNumber); @@ -1359,6 +1367,7 @@ Atom *ParseMolFileAtomLine(const std::string text, RDGeom::Point3D &pos, std::ostringstream errout; errout << "Cannot convert " << text.substr(63, 3) << " to int on line " << line; + delete res; throw FileParseException(errout.str()); } res->setProp(common_properties::molInversionFlag, inversionFlag); @@ -1371,6 +1380,7 @@ Atom *ParseMolFileAtomLine(const std::string text, RDGeom::Point3D &pos, std::ostringstream errout; errout << "Cannot convert " << text.substr(66, 3) << " to int on line " << line; + delete res; throw FileParseException(errout.str()); } res->setProp("molExactChangeFlag", exactChangeFlag); diff --git a/Code/GraphMol/FileParsers/MolWriters.h b/Code/GraphMol/FileParsers/MolWriters.h index 89bf60353..6e8af619a 100644 --- a/Code/GraphMol/FileParsers/MolWriters.h +++ b/Code/GraphMol/FileParsers/MolWriters.h @@ -90,12 +90,11 @@ class RDKIT_FILEPARSERS_EXPORT SmilesWriter : public MolWriter { //! \brief close our stream (the writer cannot be used again) void close() { flush(); - std::ostream *tmp_ostream = dp_ostream; - dp_ostream = NULL; if (df_owner) { + delete dp_ostream; df_owner = false; - delete tmp_ostream; } + dp_ostream = nullptr; }; //! \brief get the number of molecules written so far @@ -167,12 +166,11 @@ class RDKIT_FILEPARSERS_EXPORT SDWriter : public MolWriter { //! \brief close our stream (the writer cannot be used again) void close() { flush(); - std::ostream *tmp_ostream = dp_ostream; - dp_ostream = NULL; if (df_owner) { + delete dp_ostream; df_owner = false; - delete tmp_ostream; } + dp_ostream = nullptr; }; //! \brief get the number of molecules written so far @@ -236,13 +234,16 @@ class RDKIT_FILEPARSERS_EXPORT TDTWriter : public MolWriter { //! \brief close our stream (the writer cannot be used again) void close() { - flush(); - std::ostream *tmp_ostream = dp_ostream; - dp_ostream = NULL; - if (df_owner) { - df_owner = false; - delete tmp_ostream; + // if we've written any mols, finish with a "|" line + if (dp_ostream && d_molid > 0) { + *dp_ostream << "|\n"; } + flush(); + if (df_owner) { + delete dp_ostream; + df_owner = false; + } + dp_ostream = nullptr; }; //! \brief get the number of molecules written so far @@ -300,12 +301,11 @@ class RDKIT_FILEPARSERS_EXPORT PDBWriter : public MolWriter { //! \brief close our stream (the writer cannot be used again) void close() { flush(); - std::ostream *tmp_ostream = dp_ostream; - dp_ostream = NULL; if (df_owner) { + delete dp_ostream; df_owner = false; - delete tmp_ostream; } + dp_ostream = nullptr; }; //! \brief get the number of molecules written so far @@ -317,6 +317,6 @@ class RDKIT_FILEPARSERS_EXPORT PDBWriter : public MolWriter { unsigned int d_count; bool df_owner; }; -} +} // namespace RDKit #endif diff --git a/Code/GraphMol/FileParsers/PDBWriter.cpp b/Code/GraphMol/FileParsers/PDBWriter.cpp index 88ae38054..5a6d68baf 100644 --- a/Code/GraphMol/FileParsers/PDBWriter.cpp +++ b/Code/GraphMol/FileParsers/PDBWriter.cpp @@ -115,15 +115,16 @@ std::string GetPDBAtomLine(const Atom *atom, const Conformer *conf, if (conf) { const RDGeom::Point3D pos = conf->getAtomPos(atom->getIdx()); ss << boost::format("%8.3f%8.3f%8.3f") % pos.x % pos.y % pos.z; - } else + } else { ss << " 0.000 0.000 0.000"; + } if (info) { - ss << boost::format("%6.2f%6.2f") % info->getOccupancy() % - info->getTempFactor(); + ss << boost::format("%6.2f%6.2f") % info->getOccupancy() % info->getTempFactor(); ss << " "; - } else + } else { ss << " 1.00 0.00 "; + } ss << at1; ss << at2; diff --git a/Code/GraphMol/FileParsers/SDMolSupplier.cpp b/Code/GraphMol/FileParsers/SDMolSupplier.cpp index 6537e45ae..f030b04a5 100644 --- a/Code/GraphMol/FileParsers/SDMolSupplier.cpp +++ b/Code/GraphMol/FileParsers/SDMolSupplier.cpp @@ -37,6 +37,7 @@ SDMolSupplier::SDMolSupplier(const std::string &fileName, bool sanitize, if (!tmpStream || (!(*tmpStream)) || (tmpStream->bad())) { std::ostringstream errout; errout << "Bad input file " << fileName; + if (tmpStream) { delete tmpStream; } throw BadFileException(errout.str()); } diff --git a/Code/GraphMol/FileParsers/SDWriter.cpp b/Code/GraphMol/FileParsers/SDWriter.cpp index 69ee7e783..67fcd07d7 100644 --- a/Code/GraphMol/FileParsers/SDWriter.cpp +++ b/Code/GraphMol/FileParsers/SDWriter.cpp @@ -136,7 +136,7 @@ void _MolToSDStream(std::ostream *dp_ostream, const ROMol &mol, int confId, // add the $$$$ that marks the end of a molecule (*dp_ostream) << "$$$$\n"; } -} +} // namespace std::string SDWriter::getText(const ROMol &mol, int confId, bool kekulize, bool forceV3000, int molid, STR_VECT *propNames) { @@ -157,4 +157,4 @@ void SDWriter::writeProperty(const ROMol &mol, const std::string &name) { _writePropToStream(dp_ostream, mol, name, d_molid); } -} +} // namespace RDKit diff --git a/Code/GraphMol/FileParsers/SmilesMolSupplier.cpp b/Code/GraphMol/FileParsers/SmilesMolSupplier.cpp index 3d7be7359..31f9610d0 100644 --- a/Code/GraphMol/FileParsers/SmilesMolSupplier.cpp +++ b/Code/GraphMol/FileParsers/SmilesMolSupplier.cpp @@ -41,6 +41,7 @@ SmilesMolSupplier::SmilesMolSupplier(const std::string &fileName, if (!tmpStream || (!(*tmpStream)) || (tmpStream->bad())) { std::ostringstream errout; errout << "Bad input file " << fileName; + delete tmpStream; throw BadFileException(errout.str()); } dp_inStream = static_cast(tmpStream); diff --git a/Code/GraphMol/FileParsers/SmilesWriter.cpp b/Code/GraphMol/FileParsers/SmilesWriter.cpp index 539ebfeff..dc8286f4d 100644 --- a/Code/GraphMol/FileParsers/SmilesWriter.cpp +++ b/Code/GraphMol/FileParsers/SmilesWriter.cpp @@ -101,13 +101,8 @@ void SmilesWriter::dumpHeader() const { } SmilesWriter::~SmilesWriter() { - if (df_owner) { - // this has to be froma ofstream - // cast it back to fstream and clsoe it - // std::ofstream *tmpStream = static_cast(dp_ostream); - // tmpStream->close(); - delete dp_ostream; - } + // close the writer if it's still open: + if (dp_ostream != nullptr) close(); } void SmilesWriter::write(const ROMol &mol, int confId) { @@ -146,4 +141,4 @@ void SmilesWriter::write(const ROMol &mol, int confId) { (*dp_ostream) << "\n"; d_molid++; } -} +} // namespace RDKit diff --git a/Code/GraphMol/FileParsers/TDTMolSupplier.cpp b/Code/GraphMol/FileParsers/TDTMolSupplier.cpp index 46cf75b2b..e31559d9c 100644 --- a/Code/GraphMol/FileParsers/TDTMolSupplier.cpp +++ b/Code/GraphMol/FileParsers/TDTMolSupplier.cpp @@ -89,6 +89,7 @@ TDTMolSupplier::TDTMolSupplier(const std::string &fileName, if (!tmpStream || (!(*tmpStream)) || (tmpStream->bad())) { std::ostringstream errout; errout << "Bad input file " << fileName; + delete tmpStream; throw BadFileException(errout.str()); } @@ -424,4 +425,4 @@ bool TDTMolSupplier::atEnd() { PRECONDITION(dp_inStream, "no stream"); return df_end; } -} \ No newline at end of file +} diff --git a/Code/GraphMol/FileParsers/TDTWriter.cpp b/Code/GraphMol/FileParsers/TDTWriter.cpp index a2d29a00a..242614f27 100644 --- a/Code/GraphMol/FileParsers/TDTWriter.cpp +++ b/Code/GraphMol/FileParsers/TDTWriter.cpp @@ -59,16 +59,8 @@ TDTWriter::TDTWriter(std::ostream *outStream, bool takeOwnership) { } TDTWriter::~TDTWriter() throw() { - // if we've written any mols, finish with a "|" line - if (d_molid > 0) { - CHECK_INVARIANT(dp_ostream, - "null outstream even though molecules were written"); - (*dp_ostream) << "|\n"; - } - - if (df_owner) { - delete dp_ostream; - } + // close the writer if it's still open: + if (dp_ostream != nullptr) close(); } void TDTWriter::setProps(const STR_VECT &propNames) { diff --git a/Code/GraphMol/FileParsers/testMolSupplier.cpp b/Code/GraphMol/FileParsers/testMolSupplier.cpp index d95f5f284..843da9290 100644 --- a/Code/GraphMol/FileParsers/testMolSupplier.cpp +++ b/Code/GraphMol/FileParsers/testMolSupplier.cpp @@ -295,15 +295,16 @@ void testSmilesSup() { nSup = new SmilesMolSupplier(fname, ",", 1, 0, false); unsigned int nRead = 0; while (!nSup->atEnd()) { + delete mol; mol = nSup->next(); TEST_ASSERT(mol); - delete mol; nRead++; } TEST_ASSERT(nSup->length() == 10); TEST_ASSERT(nRead == 10); delete nSup; + delete mol; } void testSmilesSupFromText() { @@ -329,14 +330,19 @@ void testSmilesSupFromText() { // BOOST_LOG(rdErrorLog) << "SIZE: " << nSup2.length() << std::endl; mol = nSup2.next(); nAts = mol->getNumAtoms(); + delete mol; TEST_ASSERT(nAts == 2); + mol = nSup2[3]; nAts = mol->getNumAtoms(); + delete mol; TEST_ASSERT(nAts == 6); TEST_ASSERT(nSup2.length() == 4); + failed = false; try { mol = nSup2[4]; + delete mol; } catch (FileParseException &) { failed = true; } @@ -347,6 +353,7 @@ void testSmilesSupFromText() { TEST_ASSERT(mol->hasProp(common_properties::_Name)); mol->getProp(common_properties::_Name, mname); TEST_ASSERT(mname == "2"); + delete mol; } { nSup2.setData(text, " ", 0, -1, false, true); @@ -357,6 +364,8 @@ void testSmilesSupFromText() { TEST_ASSERT(mol->hasProp(common_properties::_Name)); mol->getProp(common_properties::_Name, mname); TEST_ASSERT(mname == "2"); + delete mol; + mol = nSup2[3]; TEST_ASSERT(mol); nAts = mol->getNumAtoms(); @@ -364,6 +373,7 @@ void testSmilesSupFromText() { TEST_ASSERT(mol->hasProp(common_properties::_Name)); mol->getProp(common_properties::_Name, mname); TEST_ASSERT(mname == "3"); + delete mol; } { nSup2.setData(text, " ", 0, -1, false, true); @@ -374,6 +384,8 @@ void testSmilesSupFromText() { TEST_ASSERT(mol->hasProp(common_properties::_Name)); mol->getProp(common_properties::_Name, mname); TEST_ASSERT(mname == "3"); + + delete mol; mol = nSup2[2]; TEST_ASSERT(mol); nAts = mol->getNumAtoms(); @@ -381,6 +393,7 @@ void testSmilesSupFromText() { TEST_ASSERT(mol->hasProp(common_properties::_Name)); mol->getProp(common_properties::_Name, mname); TEST_ASSERT(mname == "2"); + delete mol; } // -------------- // basics: @@ -399,6 +412,7 @@ void testSmilesSupFromText() { TEST_ASSERT(mname == "mol-4"); mol->getProp("Column_2", mname); TEST_ASSERT(mname == "16.0"); + delete mol; // ensure that we can call setData a second time: text = @@ -413,6 +427,7 @@ void testSmilesSupFromText() { TEST_ASSERT(mname == "mol-3"); mol->getProp("Column_2", mname); TEST_ASSERT(mname == "9.0"); + delete mol; // now test for failure handling: text = @@ -429,10 +444,14 @@ void testSmilesSupFromText() { TEST_ASSERT(mname == "mol-4"); mol->getProp("Column_2", mname); TEST_ASSERT(mname == "16.0"); + delete mol; + // failures should give null molecules: mol = nSup2[2]; TEST_ASSERT(!mol); + delete mol; #endif + // issue 114, no \n at EOF: text = "Id SMILES Column_2\n" @@ -449,6 +468,7 @@ void testSmilesSupFromText() { mol->getProp("Column_2", mname); TEST_ASSERT(mname == "16.0"); TEST_ASSERT(nSup2.atEnd()); + delete mol; text = "Id SMILES Column_2\n" @@ -465,9 +485,11 @@ void testSmilesSupFromText() { mol->getProp("Column_2", mname); TEST_ASSERT(mname == "16.0"); TEST_ASSERT(nSup2.atEnd()); + delete mol; try { mol = nSup2[3]; + delete mol; } catch (FileParseException &) { failed = true; } @@ -486,6 +508,7 @@ void testSmilesSupFromText() { TEST_ASSERT(mname == "mol-4"); mol->getProp("Column_2", mname); TEST_ASSERT(mname == "16.0"); + delete mol; text = "C\n" @@ -497,6 +520,7 @@ void testSmilesSupFromText() { mol = nSup2[2]; TEST_ASSERT(mol); TEST_ASSERT(mol->getNumAtoms() == 4); + delete mol; // this was a delightful boundary condition: BOOST_LOG(rdErrorLog) @@ -508,12 +532,17 @@ void testSmilesSupFromText() { "CCCCOC"; nSup2.setData(text, " ", 0, -1, false, true); // BOOST_LOG(rdErrorLog) << "SIZE: " << nSup2.length() << std::endl; - nSup2.next(); + mol = nSup2.next(); + delete mol; + mol = nSup2[3]; TEST_ASSERT(nSup2.length() == 4); + delete mol; + failed = false; try { mol = nSup2[4]; + delete mol; } catch (FileParseException &) { failed = true; } @@ -532,6 +561,7 @@ void testSmilesSupFromText() { failed = false; try { mol = nSup2[4]; + delete mol; } catch (FileParseException &) { failed = true; } @@ -565,11 +595,14 @@ void testSmilesSupFromText() { TEST_ASSERT(mname == "mol-3"); mol->getProp("Column_2", mname); TEST_ASSERT(mname == "9.0"); + delete mol; + mol = nSup2[1]; mol->getProp(common_properties::_Name, mname); TEST_ASSERT(mname == "mol-2"); mol->getProp("Column_2", mname); TEST_ASSERT(mname == "4.0"); + delete mol; // this was a delightful boundary condition: text = @@ -598,7 +631,7 @@ void testSmilesWriter() { // std::string fname = "../test_data/fewSmi.csv"; SmilesMolSupplier *nSup = new SmilesMolSupplier(fname, ",", 1, 0, false); std::string oname = - rdbase + "/Code/GraphMol/FileParsers/test_data/outSmiles.csv"; + rdbase + "/Code/GraphMol/FileParsers/test_data/outSmiles_molsupplier.csv"; // std::string oname = "../test_data/outSmiles.csv"; STR_VECT propNames; @@ -626,7 +659,6 @@ void testSmilesWriter() { } } writer->flush(); - delete writer; delete nSup; // now read the molecules back in a check if we have the same properties etc @@ -647,6 +679,10 @@ void testSmilesWriter() { break; } } + TEST_ASSERT(nSup->length() == writer->numMols()); + writer->close(); + delete writer; + delete nSup; } void testSDWriter() { @@ -656,7 +692,8 @@ void testSDWriter() { SDMolSupplier sdsup(fname); std::string ofile = - rdbase + "/Code/GraphMol/FileParsers/test_data/outNCI_few.sdf"; + rdbase + + "/Code/GraphMol/FileParsers/test_data/outNCI_few_molsupplier.sdf"; auto *writer = new SDWriter(ofile); @@ -673,6 +710,7 @@ void testSDWriter() { } writer->flush(); CHECK_INVARIANT(writer->numMols() == 16, ""); + writer->close(); delete writer; // now read in the file we just finished writing @@ -689,6 +727,7 @@ void testSDWriter() { delete mol; i++; } + BOOST_LOG(rdInfoLog) << i << "\n"; /* // now read in a file with aromatic information on the bonds @@ -818,7 +857,7 @@ void testCisTrans() { SmilesMolSupplier smiSup; smiSup.setData(text, " ", 1, 0, false, true); - std::string ofile = "cisTrans.sdf"; + std::string ofile = "cisTrans_molsupplier.sdf"; SDWriter writer(ofile); while (!smiSup.atEnd()) { ROMol *mol = smiSup.next(); @@ -827,12 +866,13 @@ void testCisTrans() { writer.write(*mol); delete mol; } - // do the round test + writer.close(); + // do the round t;est // parse the sd file and write it out to smiles SDMolSupplier *reader; try { - reader = new SDMolSupplier("cisTrans.sdf"); + reader = new SDMolSupplier("cisTrans_molsupplier.sdf"); } catch (FileParseException &) { reader = nullptr; } @@ -865,7 +905,8 @@ void testStereoRound() { TEST_ASSERT(smiSup) std::map nameSmi; std::string ofile = - rdbase + "/Code/GraphMol/FileParsers/test_data/cdk2_stereo.sdf"; + rdbase + + "/Code/GraphMol/FileParsers/test_data/cdk2_stereo_molsupplier.sdf"; auto *writer = new SDWriter(ofile); int count = 0; @@ -895,6 +936,7 @@ void testStereoRound() { BOOST_LOG(rdInfoLog) << count << " " << mname << "\n"; } } + writer->close(); delete smiSup; delete writer; @@ -918,6 +960,7 @@ void testStereoRound() { BOOST_LOG(rdInfoLog) << mname << " " << nameSmi[mname] << " " << smiles << "\n"; } + delete mol; count++; } delete reader; @@ -936,10 +979,12 @@ void testIssue226() { TEST_ASSERT(mol->hasProp("E1")); TEST_ASSERT(mol->hasProp("E2")); delete mol; + mol = sdsup.next(); TEST_ASSERT(mol); TEST_ASSERT(mol->hasProp("E1")); TEST_ASSERT(mol->hasProp("E2")); + delete mol; } int testTDTSupplier1() { @@ -1491,6 +1536,7 @@ void testSDErrorHandling() { TEST_ASSERT(nmol); TEST_ASSERT(!nmol->hasProp("ID")); delete sdsup; + delete nmol; // case 2: can't be sanitized fname = rdbase + "/Code/GraphMol/FileParsers/test_data/sdErrors2.sdf"; @@ -1500,6 +1546,7 @@ void testSDErrorHandling() { TEST_ASSERT(!nmol); TEST_ASSERT(sdsup->atEnd()); delete sdsup; + delete nmol; // entry 3: bad number of atoms fname = rdbase + "/Code/GraphMol/FileParsers/test_data/sdErrors3.sdf"; @@ -1509,6 +1556,7 @@ void testSDErrorHandling() { TEST_ASSERT(!nmol); TEST_ASSERT(sdsup->atEnd()); delete sdsup; + delete nmol; // entry 4: bad number of bonds fname = rdbase + "/Code/GraphMol/FileParsers/test_data/sdErrors4.sdf"; @@ -1518,6 +1566,7 @@ void testSDErrorHandling() { TEST_ASSERT(!nmol); TEST_ASSERT(sdsup->atEnd()); delete sdsup; + delete nmol; } void testIssue381() { @@ -1724,15 +1773,21 @@ int testMixIterAndRandom() { TEST_ASSERT(mol->getNumAtoms() == 9); TEST_ASSERT(tSup->length() == 10); delete mol; + mol = (*tSup)[0]; TEST_ASSERT(mol); TEST_ASSERT(mol->getNumAtoms() == 9); TEST_ASSERT(tSup->length() == 10); delete mol; + mol = tSup->next(); TEST_ASSERT(mol); + delete mol; + mol = tSup->next(); TEST_ASSERT(mol); + delete mol; + mol = tSup->next(); TEST_ASSERT(mol); TEST_ASSERT(mol->getNumAtoms() == 10); @@ -1744,6 +1799,7 @@ int testMixIterAndRandom() { mol = nullptr; try { mol = (*tSup)[20]; + delete mol; ok = false; } catch (FileParseException &) { ok = true; @@ -2150,7 +2206,8 @@ void testMissingCRSDSupplier() { std::string infile = rdbase + "/Code/GraphMol/FileParsers/test_data/missingCR.sdf"; SDMolSupplier reader(infile); - reader.next(); + auto *mol = reader.next(); + delete mol; TEST_ASSERT(reader.atEnd()); } @@ -2248,7 +2305,8 @@ void testSkipLines() { void testGitHub23() { std::string rdbase = getenv("RDBASE"); - std::string ofile = rdbase + "/Code/GraphMol/FileParsers/test_data/blah.sdf"; + std::string ofile = + rdbase + "/Code/GraphMol/FileParsers/test_data/blah_molsupplier.sdf"; auto *writer = new SDWriter(ofile); ROMol *mol = SmilesToMol("CCCC"); @@ -2259,7 +2317,7 @@ void testGitHub23() { writer->write(*mol); delete mol; - writer->flush(); + writer->close(); delete writer; } diff --git a/Code/GraphMol/FileParsers/testMolWriter.cpp b/Code/GraphMol/FileParsers/testMolWriter.cpp index 8f82b57ef..9ce179e6b 100644 --- a/Code/GraphMol/FileParsers/testMolWriter.cpp +++ b/Code/GraphMol/FileParsers/testMolWriter.cpp @@ -55,7 +55,7 @@ void testSmilesWriter() { break; } } - writer->flush(); + writer->close(); delete writer; delete nSup; @@ -96,7 +96,7 @@ void testSmilesWriter2() { mol = SmilesToMol("F[C@H](Cl)Br"); writer->write(*mol); delete mol; - writer->flush(); + writer->close(); TEST_ASSERT(ss.str() == "c1ccccc1 0\nFC(Cl)Br 1\n"); delete writer; } @@ -115,7 +115,7 @@ void testSmilesWriter2() { mol = SmilesToMol("F[C@H](Cl)Br"); writer->write(*mol); delete mol; - writer->flush(); + writer->close(); TEST_ASSERT(ss.str() == "C1=CC=CC=C1 0\nF[C@H](Cl)Br 1\n"); delete writer; } @@ -127,7 +127,7 @@ void testSmilesWriterNoNames() { rdbase + "/Code/GraphMol/FileParsers/test_data/fewSmi.csv"; SmilesMolSupplier *nSup = new SmilesMolSupplier(fname, ",", 1, 0, false); std::string oname = - rdbase + "/Code/GraphMol/FileParsers/test_data/outSmiles.csv"; + rdbase + "/Code/GraphMol/FileParsers/test_data/outSmiles_molwriter.csv"; STR_VECT propNames; propNames.push_back(std::string("Column_2")); @@ -150,27 +150,29 @@ void testSmilesWriterNoNames() { } } writer->flush(); - delete writer; delete nSup; // now read the molecules back in a check if we have the same properties etc - nSup = new SmilesMolSupplier(oname, ",", 0, -1); + nSup = new SmilesMolSupplier(oname, " ", 0, -1); int i = 0; mol = nSup->next(); while (mol) { std::string mname, pval; mol->getProp(common_properties::_Name, mname); - TEST_ASSERT(mname != "bogus"); mol->getProp("Column_2", pval); + delete mol; + TEST_ASSERT(mname != "bogus"); TEST_ASSERT(pval == props[i]); i++; - delete mol; try { mol = nSup->next(); } catch (FileParseException &) { break; } } + TEST_ASSERT(writer->numMols() == nSup->length()); + writer->close(); + delete writer; delete nSup; } @@ -180,7 +182,7 @@ void testSmilesWriterClose() { rdbase + "/Code/GraphMol/FileParsers/test_data/fewSmi.csv"; SmilesMolSupplier *nSup = new SmilesMolSupplier(fname, ",", 1, 0, false); std::string oname = - rdbase + "/Code/GraphMol/FileParsers/test_data/outSmiles.csv"; + rdbase + "/Code/GraphMol/FileParsers/test_data/outSmiles_molwriter.csv"; STR_VECT propNames; propNames.push_back(std::string("Column_2")); @@ -202,30 +204,31 @@ void testSmilesWriterClose() { break; } } - writer->close(); + writer->flush(); delete nSup; - delete writer; - writer = nullptr; // now read the molecules back in a check if we have the same properties etc - nSup = new SmilesMolSupplier(oname, ",", 0, -1); + nSup = new SmilesMolSupplier(oname, " ", 0, -1); int i = 0; mol = nSup->next(); while (mol) { std::string mname, pval; mol->getProp(common_properties::_Name, mname); - TEST_ASSERT(mname != "bogus"); mol->getProp("Column_2", pval); + delete mol; + TEST_ASSERT(mname != "bogus"); TEST_ASSERT(pval == props[i]); i++; - delete mol; try { mol = nSup->next(); } catch (FileParseException &) { break; } } + TEST_ASSERT(writer->numMols() == nSup->length()); + writer->close(); delete nSup; + delete writer; } void testSDWriter() { @@ -235,7 +238,8 @@ void testSDWriter() { SDMolSupplier sdsup(fname); std::string ofile = - rdbase + "/Code/GraphMol/FileParsers/test_data/outNCI_few.sdf"; + rdbase + + "/Code/GraphMol/FileParsers/test_data/outNCI_few.sdf_molwriter.sdf"; auto *writer = new SDWriter(ofile); STR_VECT names; @@ -254,7 +258,6 @@ void testSDWriter() { // make sure we can close() the writer and delete it: writer->close(); - delete writer; // now read in the file we just finished writing @@ -293,11 +296,10 @@ void testTDTWriter() { SDMolSupplier sdsup(fname); std::string ofile = - rdbase + "/Code/GraphMol/FileParsers/test_data/outNCI_few.tdt"; + rdbase + "/Code/GraphMol/FileParsers/test_data/outNCI_few_molwriter.tdt"; auto *writer = new TDTWriter(ofile); STR_VECT names; - while (!sdsup.atEnd()) { ROMol *mol = sdsup.next(); std::string mname; @@ -307,8 +309,8 @@ void testTDTWriter() { writer->write(*mol); delete mol; } - writer->flush(); TEST_ASSERT(writer->numMols() == 16); + writer->close(); delete writer; // now read in the file we just finished writing @@ -333,7 +335,7 @@ void testSmilesWriterStrm() { rdbase + "/Code/GraphMol/FileParsers/test_data/fewSmi.csv"; SmilesMolSupplier *nSup = new SmilesMolSupplier(fname, ",", 1, 0, false); std::string oname = - rdbase + "/Code/GraphMol/FileParsers/test_data/outSmiles.csv"; + rdbase + "/Code/GraphMol/FileParsers/test_data/outSmiles_molwriter.csv"; auto *oStream = new std::ofstream(oname.c_str()); STR_VECT propNames; @@ -358,7 +360,7 @@ void testSmilesWriterStrm() { break; } } - writer->flush(); + writer->close(); delete writer; delete nSup; delete oStream; @@ -392,7 +394,8 @@ void testSDWriterStrm() { SDMolSupplier sdsup(fname); std::string ofile = - rdbase + "/Code/GraphMol/FileParsers/test_data/outNCI_few.sdf"; + rdbase + + "/Code/GraphMol/FileParsers/test_data/outNCI_few_molwriter.sdf"; auto *oStream = new std::ofstream(ofile.c_str()); auto *writer = new SDWriter(oStream); @@ -410,6 +413,7 @@ void testSDWriterStrm() { } writer->flush(); CHECK_INVARIANT(writer->numMols() == 16, ""); + writer->close(); delete writer; delete oStream; @@ -450,7 +454,7 @@ void testTDTWriterStrm() { SDMolSupplier sdsup(fname); std::string ofile = - rdbase + "/Code/GraphMol/FileParsers/test_data/outNCI_few.tdt"; + rdbase + "/Code/GraphMol/FileParsers/test_data/outNCI_few_molwriter.tdt"; auto *oStream = new std::ofstream(ofile.c_str()); auto *writer = new TDTWriter(oStream); @@ -467,6 +471,7 @@ void testTDTWriterStrm() { } writer->flush(); TEST_ASSERT(writer->numMols() == 16); + writer->close(); delete writer; delete oStream; @@ -490,9 +495,9 @@ void testSDMemoryCorruption() { std::string rdbase = getenv("RDBASE"); std::string fname = rdbase + "/Data/NCI/first_200.props.sdf"; SDMolSupplier sdsup(fname, true); - std::string ofile = - rdbase + - "/Code/GraphMol/FileParsers/test_data/outNCI_first_200.props.sdf"; + std::string ofile = rdbase + + "/Code/GraphMol/FileParsers/test_data/" + "outNCI_first_200.props_molwriter.sdf"; std::ostream *os = new std::ofstream(ofile.c_str()); // std::ostream *os=new std::stringstream(); auto *writer = new SDWriter(os, false); @@ -527,6 +532,7 @@ void testSDMemoryCorruption() { CHECK_INVARIANT(nDone == 200, ""); writer->flush(); CHECK_INVARIANT(writer->numMols() == 200, ""); + writer->close(); delete writer; delete os; @@ -676,9 +682,9 @@ void testIssue265() { std::stringstream sstream; TDTWriter writer(&sstream); writer.write(*m1); - writer.flush(); std::string otext = sstream.str(); TEST_ASSERT(otext == "$SMI\n3D<0,0,0,0,1,0,1,0,0;>\n"); + writer.close(); delete m1; } } @@ -831,6 +837,7 @@ void testSDWriterOptions() { delete mol; writer.flush(); CHECK_INVARIANT(writer.numMols() == 1, ""); + writer.close(); std::string txt = ss.str(); TEST_ASSERT(txt.find("V2000") != std::string::npos); @@ -845,6 +852,7 @@ void testSDWriterOptions() { delete mol; writer.flush(); CHECK_INVARIANT(writer.numMols() == 1, ""); + writer.close(); std::string txt = ss.str(); TEST_ASSERT(txt.find("V2000") == std::string::npos); @@ -860,6 +868,7 @@ void testSDWriterOptions() { delete mol; writer.flush(); CHECK_INVARIANT(writer.numMols() == 2, ""); + writer.close(); std::string txt = ss.str(); TEST_ASSERT(txt.find("V2000") != std::string::npos); @@ -877,6 +886,7 @@ void testSDWriterOptions() { delete mol; writer.flush(); CHECK_INVARIANT(writer.numMols() == 2, ""); + writer.close(); std::string txt = ss.str(); TEST_ASSERT(txt.find("V2000") != std::string::npos); @@ -892,6 +902,7 @@ void testSDWriterOptions() { delete mol; writer.flush(); CHECK_INVARIANT(writer.numMols() == 1, ""); + writer.close(); std::string txt = ss.str(); TEST_ASSERT(txt.find(" 1 2 2") != std::string::npos); @@ -907,6 +918,7 @@ void testSDWriterOptions() { delete mol; writer.flush(); CHECK_INVARIANT(writer.numMols() == 1, ""); + writer.close(); std::string txt = ss.str(); TEST_ASSERT(txt.find(" 1 2 2") == std::string::npos); @@ -923,6 +935,7 @@ void testSDWriterOptions() { delete mol; writer.flush(); CHECK_INVARIANT(writer.numMols() == 2, ""); + writer.close(); std::string txt = ss.str(); TEST_ASSERT(txt.find(" 1 2 2") != std::string::npos); @@ -941,6 +954,7 @@ void testSDWriterOptions() { delete mol; writer.flush(); CHECK_INVARIANT(writer.numMols() == 2, ""); + writer.close(); std::string txt = ss.str(); TEST_ASSERT(txt.find(" 1 2 2") != std::string::npos); @@ -1232,6 +1246,7 @@ void testGithub266() { "BondOr"); delete m; + delete m2; } { @@ -1260,6 +1275,7 @@ void testGithub266() { "SingleOrAromaticBond"); delete m; + delete m2; } { @@ -1287,6 +1303,7 @@ void testGithub266() { "BondOr"); delete m; + delete m2; } { diff --git a/Code/GraphMol/FilterCatalog/FilterCatalog.cpp b/Code/GraphMol/FilterCatalog/FilterCatalog.cpp index 19e65f937..248439d80 100644 --- a/Code/GraphMol/FilterCatalog/FilterCatalog.cpp +++ b/Code/GraphMol/FilterCatalog/FilterCatalog.cpp @@ -58,7 +58,7 @@ bool FilterCatalogParams::addCatalog(FilterCatalogs catalog) { return addedCatalog; } -void FilterCatalogParams::fillCatalog(FilterCatalog &catalog) { +void FilterCatalogParams::fillCatalog(FilterCatalog &catalog) const { for (auto catalogToAdd : getCatalogs()) { const unsigned int entries = GetNumEntries(catalogToAdd); const unsigned int propEntries = GetNumPropertyEntries(catalogToAdd); @@ -185,7 +185,7 @@ unsigned int FilterCatalog::getIdxForEntry(CONST_SENTRY entry) const { return UINT_MAX; } -void FilterCatalog::setCatalogParams(paramType_t *params) { +void FilterCatalog::setCatalogParams(const paramType_t *params) { Clear(); FCatalog::setCatalogParams(params); params->fillCatalog(*this); diff --git a/Code/GraphMol/FilterCatalog/FilterCatalog.h b/Code/GraphMol/FilterCatalog/FilterCatalog.h index 74edb1d7d..18e369da3 100644 --- a/Code/GraphMol/FilterCatalog/FilterCatalog.h +++ b/Code/GraphMol/FilterCatalog/FilterCatalog.h @@ -83,7 +83,7 @@ class RDKIT_FILTERCATALOG_EXPORT FilterCatalogParams : public RDCatalog::Catalog //! Returns the existing list of FilterCatalogs to be used. const std::vector &getCatalogs() const { return d_catalogs; } //! Fill a catalog with the appropriate entries - virtual void fillCatalog(FilterCatalog &catalog); + virtual void fillCatalog(FilterCatalog &catalog) const; //! serializes (pickles) to a stream virtual void toStream(std::ostream &ss) const; @@ -129,11 +129,12 @@ class RDKIT_FILTERCATALOG_EXPORT FilterCatalog : public FCatalog { FilterCatalog(FilterCatalogParams::FilterCatalogs catalogs) : FCatalog(), d_entries() { - setCatalogParams(new paramType_t(catalogs)); + paramType_t temp_params(catalogs); + setCatalogParams(&temp_params); } FilterCatalog(const FilterCatalogParams ¶ms) : FCatalog(), d_entries() { - setCatalogParams(new paramType_t(params)); + setCatalogParams(¶ms); } FilterCatalog(const FilterCatalog &rhs) @@ -206,7 +207,7 @@ class RDKIT_FILTERCATALOG_EXPORT FilterCatalog : public FCatalog { \param params The new FilterCatalogParams specifying the new state of the catalog */ - virtual void setCatalogParams(FilterCatalogParams *params); + virtual void setCatalogParams(const FilterCatalogParams *params); //------------------------------------ //! Returns true if the molecule matches any entry in the catalog diff --git a/Code/GraphMol/Fingerprints/AtomPairs.cpp b/Code/GraphMol/Fingerprints/AtomPairs.cpp index 679df9a63..d1dd0263f 100644 --- a/Code/GraphMol/Fingerprints/AtomPairs.cpp +++ b/Code/GraphMol/Fingerprints/AtomPairs.cpp @@ -146,10 +146,15 @@ SparseIntVect *getHashedAtomPairFingerprint( } auto *res = new SparseIntVect(nBits); const double *dm; - if (use2D) { - dm = MolOps::getDistanceMat(*lmol); - } else { - dm = MolOps::get3DDistanceMat(*lmol, confId); + try { + if (use2D) { + dm = MolOps::getDistanceMat(*lmol); + } else { + dm = MolOps::get3DDistanceMat(*lmol, confId); + } + } catch (const ConformerException &) { + delete res; + throw; } const unsigned int nAtoms = lmol->getNumAtoms(); diff --git a/Code/GraphMol/Fingerprints/MACCS.cpp b/Code/GraphMol/Fingerprints/MACCS.cpp index e47514098..ffbe55b37 100644 --- a/Code/GraphMol/Fingerprints/MACCS.cpp +++ b/Code/GraphMol/Fingerprints/MACCS.cpp @@ -22,307 +22,299 @@ namespace { struct Patterns { - RDKit::ROMol *bit_8; - RDKit::ROMol *bit_11; - RDKit::ROMol *bit_13; - RDKit::ROMol *bit_14; - RDKit::ROMol *bit_15; - RDKit::ROMol *bit_16; - RDKit::ROMol *bit_17; - RDKit::ROMol *bit_19; - RDKit::ROMol *bit_20; - RDKit::ROMol *bit_21; - RDKit::ROMol *bit_22; - RDKit::ROMol *bit_23; - RDKit::ROMol *bit_24; - RDKit::ROMol *bit_25; - RDKit::ROMol *bit_26; - RDKit::ROMol *bit_28; - RDKit::ROMol *bit_30; - RDKit::ROMol *bit_31; - RDKit::ROMol *bit_32; - RDKit::ROMol *bit_33; - RDKit::ROMol *bit_34; - RDKit::ROMol *bit_36; - RDKit::ROMol *bit_37; - RDKit::ROMol *bit_38; - RDKit::ROMol *bit_39; - RDKit::ROMol *bit_40; - RDKit::ROMol *bit_41; - RDKit::ROMol *bit_43; - RDKit::ROMol *bit_44; - RDKit::ROMol *bit_45; - RDKit::ROMol *bit_47; - RDKit::ROMol *bit_48; - RDKit::ROMol *bit_49; - RDKit::ROMol *bit_50; - RDKit::ROMol *bit_51; - RDKit::ROMol *bit_52; - RDKit::ROMol *bit_53; - RDKit::ROMol *bit_54; - RDKit::ROMol *bit_55; - RDKit::ROMol *bit_56; - RDKit::ROMol *bit_57; - RDKit::ROMol *bit_58; - RDKit::ROMol *bit_59; - RDKit::ROMol *bit_60; - RDKit::ROMol *bit_61; - RDKit::ROMol *bit_62; - RDKit::ROMol *bit_63; - RDKit::ROMol *bit_64; - RDKit::ROMol *bit_65; - RDKit::ROMol *bit_66; - RDKit::ROMol *bit_67; - RDKit::ROMol *bit_68; - RDKit::ROMol *bit_69; - RDKit::ROMol *bit_70; - RDKit::ROMol *bit_71; - RDKit::ROMol *bit_72; - RDKit::ROMol *bit_73; - RDKit::ROMol *bit_74; - RDKit::ROMol *bit_75; - RDKit::ROMol *bit_76; - RDKit::ROMol *bit_77; - RDKit::ROMol *bit_78; - RDKit::ROMol *bit_79; - RDKit::ROMol *bit_80; - RDKit::ROMol *bit_81; - RDKit::ROMol *bit_82; - RDKit::ROMol *bit_83; - RDKit::ROMol *bit_84; - RDKit::ROMol *bit_85; - RDKit::ROMol *bit_86; - RDKit::ROMol *bit_87; - RDKit::ROMol *bit_89; - RDKit::ROMol *bit_90; - RDKit::ROMol *bit_91; - RDKit::ROMol *bit_92; - RDKit::ROMol *bit_93; - RDKit::ROMol *bit_94; - RDKit::ROMol *bit_95; - RDKit::ROMol *bit_96; - RDKit::ROMol *bit_97; - RDKit::ROMol *bit_98; - RDKit::ROMol *bit_99; - RDKit::ROMol *bit_100; - RDKit::ROMol *bit_101; - RDKit::ROMol *bit_102; - RDKit::ROMol *bit_104; - RDKit::ROMol *bit_105; - RDKit::ROMol *bit_106; - RDKit::ROMol *bit_107; - RDKit::ROMol *bit_108; - RDKit::ROMol *bit_109; - RDKit::ROMol *bit_110; - RDKit::ROMol *bit_111; - RDKit::ROMol *bit_112; - RDKit::ROMol *bit_113; - RDKit::ROMol *bit_114; - RDKit::ROMol *bit_115; - RDKit::ROMol *bit_116; - RDKit::ROMol *bit_117; - RDKit::ROMol *bit_118; - RDKit::ROMol *bit_119; - RDKit::ROMol *bit_120; - RDKit::ROMol *bit_121; - RDKit::ROMol *bit_122; - RDKit::ROMol *bit_123; - RDKit::ROMol *bit_124; - RDKit::ROMol *bit_126; - RDKit::ROMol *bit_127; - RDKit::ROMol *bit_128; - RDKit::ROMol *bit_129; - RDKit::ROMol *bit_131; - RDKit::ROMol *bit_132; - RDKit::ROMol *bit_133; - RDKit::ROMol *bit_135; - RDKit::ROMol *bit_136; - RDKit::ROMol *bit_137; - RDKit::ROMol *bit_138; - RDKit::ROMol *bit_139; - RDKit::ROMol *bit_140; - RDKit::ROMol *bit_141; - RDKit::ROMol *bit_142; - RDKit::ROMol *bit_144; - RDKit::ROMol *bit_145; - RDKit::ROMol *bit_147; - RDKit::ROMol *bit_148; - RDKit::ROMol *bit_149; - RDKit::ROMol *bit_150; - RDKit::ROMol *bit_151; - RDKit::ROMol *bit_152; - RDKit::ROMol *bit_154; - RDKit::ROMol *bit_155; - RDKit::ROMol *bit_156; - RDKit::ROMol *bit_157; - RDKit::ROMol *bit_158; - RDKit::ROMol *bit_162; - RDKit::ROMol *bit_165; - Patterns() - : bit_8(RDKit::SmartsToMol("[!#6!#1]1~*~*~*~1")), - bit_11(RDKit::SmartsToMol("*1~*~*~*~1")), - bit_13(RDKit::SmartsToMol("[#8]~[#7](~[#6])~[#6]")), - bit_14(RDKit::SmartsToMol("[#16]-[#16]")), - bit_15(RDKit::SmartsToMol("[#8]~[#6](~[#8])~[#8]")), - bit_16(RDKit::SmartsToMol("[!#6!#1]1~*~*~1")), - bit_17(RDKit::SmartsToMol("[#6]#[#6]")), - bit_19(RDKit::SmartsToMol("*1~*~*~*~*~*~*~1")), - bit_20(RDKit::SmartsToMol("[#14]")), - bit_21(RDKit::SmartsToMol("[#6]=[#6](~[!#6!#1])~[!#6!#1]")), - bit_22(RDKit::SmartsToMol("*1~*~*~1")), - bit_23(RDKit::SmartsToMol("[#7]~[#6](~[#8])~[#8]")), - bit_24(RDKit::SmartsToMol("[#7]-[#8]")), - bit_25(RDKit::SmartsToMol("[#7]~[#6](~[#7])~[#7]")), - bit_26(RDKit::SmartsToMol("[#6]=@[#6](@*)@*")), - bit_28(RDKit::SmartsToMol("[!#6!#1]~[CH2]~[!#6!#1]")), - bit_30(RDKit::SmartsToMol("[#6]~[!#6!#1](~[#6])(~[#6])~*")), - bit_31(RDKit::SmartsToMol("[!#6!#1]~[F,Cl,Br,I]")), - bit_32(RDKit::SmartsToMol("[#6]~[#16]~[#7]")), - bit_33(RDKit::SmartsToMol("[#7]~[#16]")), - bit_34(RDKit::SmartsToMol("[CH2]=*")), - bit_36(RDKit::SmartsToMol("[#16R]")), - bit_37(RDKit::SmartsToMol("[#7]~[#6](~[#8])~[#7]")), - bit_38(RDKit::SmartsToMol("[#7]~[#6](~[#6])~[#7]")), - bit_39(RDKit::SmartsToMol("[#8]~[#16](~[#8])~[#8]")), - bit_40(RDKit::SmartsToMol("[#16]-[#8]")), - bit_41(RDKit::SmartsToMol("[#6]#[#7]")), - bit_43(RDKit::SmartsToMol("[!#6!#1!H0]~*~[!#6!#1!H0]")), - bit_44(RDKit::SmartsToMol( - "[!#1;!#6;!#7;!#8;!#9;!#14;!#15;!#16;!#17;!#35;!#53]")), - bit_45(RDKit::SmartsToMol("[#6]=[#6]~[#7]")), - bit_47(RDKit::SmartsToMol("[#16]~*~[#7]")), - bit_48(RDKit::SmartsToMol("[#8]~[!#6!#1](~[#8])~[#8]")), - bit_49(RDKit::SmartsToMol("[!+0]")), - bit_50(RDKit::SmartsToMol("[#6]=[#6](~[#6])~[#6]")), - bit_51(RDKit::SmartsToMol("[#6]~[#16]~[#8]")), - bit_52(RDKit::SmartsToMol("[#7]~[#7]")), - bit_53(RDKit::SmartsToMol("[!#6!#1!H0]~*~*~*~[!#6!#1!H0]")), - bit_54(RDKit::SmartsToMol("[!#6!#1!H0]~*~*~[!#6!#1!H0]")), - bit_55(RDKit::SmartsToMol("[#8]~[#16]~[#8]")), - bit_56(RDKit::SmartsToMol("[#8]~[#7](~[#8])~[#6]")), - bit_57(RDKit::SmartsToMol("[#8R]")), - bit_58(RDKit::SmartsToMol("[!#6!#1]~[#16]~[!#6!#1]")), - bit_59(RDKit::SmartsToMol("[#16]!:*:*")), - bit_60(RDKit::SmartsToMol("[#16]=[#8]")), - bit_61(RDKit::SmartsToMol("*~[#16](~*)~*")), - bit_62(RDKit::SmartsToMol("*@*!@*@*")), - bit_63(RDKit::SmartsToMol("[#7]=[#8]")), - bit_64(RDKit::SmartsToMol("*@*!@[#16]")), - bit_65(RDKit::SmartsToMol("c:n")), - bit_66(RDKit::SmartsToMol("[#6]~[#6](~[#6])(~[#6])~*")), - bit_67(RDKit::SmartsToMol("[!#6!#1]~[#16]")), - bit_68(RDKit::SmartsToMol("[!#6!#1!H0]~[!#6!#1!H0]")), - bit_69(RDKit::SmartsToMol("[!#6!#1]~[!#6!#1!H0]")), - bit_70(RDKit::SmartsToMol("[!#6!#1]~[#7]~[!#6!#1]")), - bit_71(RDKit::SmartsToMol("[#7]~[#8]")), - bit_72(RDKit::SmartsToMol("[#8]~*~*~[#8]")), - bit_73(RDKit::SmartsToMol("[#16]=*")), - bit_74(RDKit::SmartsToMol("[CH3]~*~[CH3]")), - bit_75(RDKit::SmartsToMol("*!@[#7]@*")), - bit_76(RDKit::SmartsToMol("[#6]=[#6](~*)~*")), - bit_77(RDKit::SmartsToMol("[#7]~*~[#7]")), - bit_78(RDKit::SmartsToMol("[#6]=[#7]")), - bit_79(RDKit::SmartsToMol("[#7]~*~*~[#7]")), - bit_80(RDKit::SmartsToMol("[#7]~*~*~*~[#7]")), - bit_81(RDKit::SmartsToMol("[#16]~*(~*)~*")), - bit_82(RDKit::SmartsToMol("*~[CH2]~[!#6!#1!H0]")), - bit_83(RDKit::SmartsToMol("[!#6!#1]1~*~*~*~*~1")), - bit_84(RDKit::SmartsToMol("[NH2]")), - bit_85(RDKit::SmartsToMol("[#6]~[#7](~[#6])~[#6]")), - bit_86(RDKit::SmartsToMol("[C;H2,H3][!#6!#1][C;H2,H3]")), - bit_87(RDKit::SmartsToMol("[F,Cl,Br,I]!@*@*")), - bit_89(RDKit::SmartsToMol("[#8]~*~*~*~[#8]")), - bit_90(RDKit::SmartsToMol( - "[$([!#6!#1!H0]~*~*~[CH2]~*),$([!#6!#1!H0R]1@[R]@[R]@[CH2R]1),$([!#" - "6!#1!H0]~[R]1@[R]@[CH2R]1)]")), - bit_91(RDKit::SmartsToMol( - "[$([!#6!#1!H0]~*~*~*~[CH2]~*),$([!#6!#1!H0R]1@[R]@[R]@[R]@[CH2R]1)" - ",$([!#6!#1!H0]~[R]1@[R]@[R]@[CH2R]1),$([!#6!#1!H0]~*~[R]1@[R]@[" - "CH2R]1)]")), - bit_92(RDKit::SmartsToMol("[#8]~[#6](~[#7])~[#6]")), - bit_93(RDKit::SmartsToMol("[!#6!#1]~[CH3]")), - bit_94(RDKit::SmartsToMol("[!#6!#1]~[#7]")), - bit_95(RDKit::SmartsToMol("[#7]~*~*~[#8]")), - bit_96(RDKit::SmartsToMol("*1~*~*~*~*~1")), - bit_97(RDKit::SmartsToMol("[#7]~*~*~*~[#8]")), - bit_98(RDKit::SmartsToMol("[!#6!#1]1~*~*~*~*~*~1")), - bit_99(RDKit::SmartsToMol("[#6]=[#6]")), - bit_100(RDKit::SmartsToMol("*~[CH2]~[#7]")), - bit_101(RDKit::SmartsToMol( - "[$([R]1@[R]@[R]@[R]@[R]@[R]@[R]@[R]@1),$([R]1@[R]@[R]@[R]@[R]@[R]@" - "[R]@[R]@[R]@1),$([R]1@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@1),$([R]" - "1@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@1),$([R]1@[R]@[R]@[R]@[" - "R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@1),$([R]1@[R]@[R]@[R]@[R]@[R]@[R]@[" - "R]@[R]@[R]@[R]@[R]@[R]@1),$([R]1@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[" - "R]@[R]@[R]@[R]@[R]@1)]")), - bit_102(RDKit::SmartsToMol("[!#6!#1]~[#8]")), - bit_104(RDKit::SmartsToMol("[!#6!#1!H0]~*~[CH2]~*")), - bit_105(RDKit::SmartsToMol("*@*(@*)@*")), - bit_106(RDKit::SmartsToMol("[!#6!#1]~*(~[!#6!#1])~[!#6!#1]")), - bit_107(RDKit::SmartsToMol("[F,Cl,Br,I]~*(~*)~*")), - bit_108(RDKit::SmartsToMol("[CH3]~*~*~*~[CH2]~*")), - bit_109(RDKit::SmartsToMol("*~[CH2]~[#8]")), - bit_110(RDKit::SmartsToMol("[#7]~[#6]~[#8]")), - bit_111(RDKit::SmartsToMol("[#7]~*~[CH2]~*")), - bit_112(RDKit::SmartsToMol("*~*(~*)(~*)~*")), - bit_113(RDKit::SmartsToMol("[#8]!:*:*")), - bit_114(RDKit::SmartsToMol("[CH3]~[CH2]~*")), - bit_115(RDKit::SmartsToMol("[CH3]~*~[CH2]~*")), - bit_116( - RDKit::SmartsToMol("[$([CH3]~*~*~[CH2]~*),$([CH3]~*1~*~[CH2]1)]")), - bit_117(RDKit::SmartsToMol("[#7]~*~[#8]")), - bit_118(RDKit::SmartsToMol("[$(*~[CH2]~[CH2]~*),$(*1~[CH2]~[CH2]1)]")), - bit_119(RDKit::SmartsToMol("[#7]=*")), - bit_120(RDKit::SmartsToMol("[!#6R]")), - bit_121(RDKit::SmartsToMol("[#7R]")), - bit_122(RDKit::SmartsToMol("*~[#7](~*)~*")), - bit_123(RDKit::SmartsToMol("[#8]~[#6]~[#8]")), - bit_124(RDKit::SmartsToMol("[!#6!#1]~[!#6!#1]")), - bit_126(RDKit::SmartsToMol("*!@[#8]!@*")), - bit_127(RDKit::SmartsToMol("*@*!@[#8]")), - bit_128(RDKit::SmartsToMol( - "[$(*~[CH2]~*~*~*~[CH2]~*),$([R]1@[CH2R]@[R]@[R]@[R]@[CH2R]1),$(*~[" - "CH2]~[R]1@[R]@[R]@[CH2R]1),$(*~[CH2]~*~[R]1@[R]@[CH2R]1)]")), - bit_129(RDKit::SmartsToMol( - "[$(*~[CH2]~*~*~[CH2]~*),$([R]1@[CH2]@[R]@[R]@[CH2R]1),$(*~[CH2]~[" - "R]1@[R]@[CH2R]1)]")), - bit_131(RDKit::SmartsToMol("[!#6!#1!H0]")), - bit_132(RDKit::SmartsToMol("[#8]~*~[CH2]~*")), - bit_133(RDKit::SmartsToMol("*@*!@[#7]")), - bit_135(RDKit::SmartsToMol("[#7]!:*:*")), - bit_136(RDKit::SmartsToMol("[#8]=*")), - bit_137(RDKit::SmartsToMol("[!C!cR]")), - bit_138(RDKit::SmartsToMol("[!#6!#1]~[CH2]~*")), - bit_139(RDKit::SmartsToMol("[O!H0]")), - bit_140(RDKit::SmartsToMol("[#8]")), - bit_141(RDKit::SmartsToMol("[CH3]")), - bit_142(RDKit::SmartsToMol("[#7]")), - bit_144(RDKit::SmartsToMol("*!:*:*!:*")), - bit_145(RDKit::SmartsToMol("*1~*~*~*~*~*~1")), - bit_147( - RDKit::SmartsToMol("[$(*~[CH2]~[CH2]~*),$([R]1@[CH2R]@[CH2R]1)]")), - bit_148(RDKit::SmartsToMol("*~[!#6!#1](~*)~*")), - bit_149(RDKit::SmartsToMol("[C;H3,H4]")), - bit_150(RDKit::SmartsToMol("*!@*@*!@*")), - bit_151(RDKit::SmartsToMol("[#7!H0]")), - bit_152(RDKit::SmartsToMol("[#8]~[#6](~[#6])~[#6]")), - bit_154(RDKit::SmartsToMol("[#6]=[#8]")), - bit_155(RDKit::SmartsToMol("*!@[CH2]!@*")), - bit_156(RDKit::SmartsToMol("[#7]~*(~*)~*")), - bit_157(RDKit::SmartsToMol("[#6]-[#8]")), - bit_158(RDKit::SmartsToMol("[#6]-[#7]")), - bit_162(RDKit::SmartsToMol("a")), - bit_165(RDKit::SmartsToMol("[R]")) {} + std::unique_ptr bit_8 = + std::unique_ptr(RDKit::SmartsToMol("[!#6!#1]1~*~*~*~1")); + std::unique_ptr bit_11 = + std::unique_ptr(RDKit::SmartsToMol("*1~*~*~*~1")); + std::unique_ptr bit_13 = std::unique_ptr( + RDKit::SmartsToMol("[#8]~[#7](~[#6])~[#6]")); + std::unique_ptr bit_14 = + std::unique_ptr(RDKit::SmartsToMol("[#16]-[#16]")); + std::unique_ptr bit_15 = std::unique_ptr( + RDKit::SmartsToMol("[#8]~[#6](~[#8])~[#8]")); + std::unique_ptr bit_16 = + std::unique_ptr(RDKit::SmartsToMol("[!#6!#1]1~*~*~1")); + std::unique_ptr bit_17 = + std::unique_ptr(RDKit::SmartsToMol("[#6]#[#6]")); + std::unique_ptr bit_19 = + std::unique_ptr(RDKit::SmartsToMol("*1~*~*~*~*~*~*~1")); + std::unique_ptr bit_20 = + std::unique_ptr(RDKit::SmartsToMol("[#14]")); + std::unique_ptr bit_21 = std::unique_ptr( + RDKit::SmartsToMol("[#6]=[#6](~[!#6!#1])~[!#6!#1]")); + std::unique_ptr bit_22 = + std::unique_ptr(RDKit::SmartsToMol("*1~*~*~1")); + std::unique_ptr bit_23 = std::unique_ptr( + RDKit::SmartsToMol("[#7]~[#6](~[#8])~[#8]")); + std::unique_ptr bit_24 = + std::unique_ptr(RDKit::SmartsToMol("[#7]-[#8]")); + std::unique_ptr bit_25 = std::unique_ptr( + RDKit::SmartsToMol("[#7]~[#6](~[#7])~[#7]")); + std::unique_ptr bit_26 = + std::unique_ptr(RDKit::SmartsToMol("[#6]=@[#6](@*)@*")); + std::unique_ptr bit_28 = std::unique_ptr( + RDKit::SmartsToMol("[!#6!#1]~[CH2]~[!#6!#1]")); + std::unique_ptr bit_30 = std::unique_ptr( + RDKit::SmartsToMol("[#6]~[!#6!#1](~[#6])(~[#6])~*")); + std::unique_ptr bit_31 = + std::unique_ptr(RDKit::SmartsToMol("[!#6!#1]~[F,Cl,Br,I]")); + std::unique_ptr bit_32 = + std::unique_ptr(RDKit::SmartsToMol("[#6]~[#16]~[#7]")); + std::unique_ptr bit_33 = + std::unique_ptr(RDKit::SmartsToMol("[#7]~[#16]")); + std::unique_ptr bit_34 = + std::unique_ptr(RDKit::SmartsToMol("[CH2]=*")); + std::unique_ptr bit_36 = + std::unique_ptr(RDKit::SmartsToMol("[#16R]")); + std::unique_ptr bit_37 = std::unique_ptr( + RDKit::SmartsToMol("[#7]~[#6](~[#8])~[#7]")); + std::unique_ptr bit_38 = std::unique_ptr( + RDKit::SmartsToMol("[#7]~[#6](~[#6])~[#7]")); + std::unique_ptr bit_39 = std::unique_ptr( + RDKit::SmartsToMol("[#8]~[#16](~[#8])~[#8]")); + std::unique_ptr bit_40 = + std::unique_ptr(RDKit::SmartsToMol("[#16]-[#8]")); + std::unique_ptr bit_41 = + std::unique_ptr(RDKit::SmartsToMol("[#6]#[#7]")); + std::unique_ptr bit_43 = std::unique_ptr( + RDKit::SmartsToMol("[!#6!#1!H0]~*~[!#6!#1!H0]")); + std::unique_ptr bit_44 = + std::unique_ptr(RDKit::SmartsToMol( + "[!#1;!#6;!#7;!#8;!#9;!#14;!#15;!#16;!#17;!#35;!#53]")); + std::unique_ptr bit_45 = + std::unique_ptr(RDKit::SmartsToMol("[#6]=[#6]~[#7]")); + std::unique_ptr bit_47 = + std::unique_ptr(RDKit::SmartsToMol("[#16]~*~[#7]")); + std::unique_ptr bit_48 = std::unique_ptr( + RDKit::SmartsToMol("[#8]~[!#6!#1](~[#8])~[#8]")); + std::unique_ptr bit_49 = + std::unique_ptr(RDKit::SmartsToMol("[!+0]")); + std::unique_ptr bit_50 = std::unique_ptr( + RDKit::SmartsToMol("[#6]=[#6](~[#6])~[#6]")); + std::unique_ptr bit_51 = + std::unique_ptr(RDKit::SmartsToMol("[#6]~[#16]~[#8]")); + std::unique_ptr bit_52 = + std::unique_ptr(RDKit::SmartsToMol("[#7]~[#7]")); + std::unique_ptr bit_53 = std::unique_ptr( + RDKit::SmartsToMol("[!#6!#1!H0]~*~*~*~[!#6!#1!H0]")); + std::unique_ptr bit_54 = std::unique_ptr( + RDKit::SmartsToMol("[!#6!#1!H0]~*~*~[!#6!#1!H0]")); + std::unique_ptr bit_55 = + std::unique_ptr(RDKit::SmartsToMol("[#8]~[#16]~[#8]")); + std::unique_ptr bit_56 = std::unique_ptr( + RDKit::SmartsToMol("[#8]~[#7](~[#8])~[#6]")); + std::unique_ptr bit_57 = + std::unique_ptr(RDKit::SmartsToMol("[#8R]")); + std::unique_ptr bit_58 = std::unique_ptr( + RDKit::SmartsToMol("[!#6!#1]~[#16]~[!#6!#1]")); + std::unique_ptr bit_59 = + std::unique_ptr(RDKit::SmartsToMol("[#16]!:*:*")); + std::unique_ptr bit_60 = + std::unique_ptr(RDKit::SmartsToMol("[#16]=[#8]")); + std::unique_ptr bit_61 = + std::unique_ptr(RDKit::SmartsToMol("*~[#16](~*)~*")); + std::unique_ptr bit_62 = + std::unique_ptr(RDKit::SmartsToMol("*@*!@*@*")); + std::unique_ptr bit_63 = + std::unique_ptr(RDKit::SmartsToMol("[#7]=[#8]")); + std::unique_ptr bit_64 = + std::unique_ptr(RDKit::SmartsToMol("*@*!@[#16]")); + std::unique_ptr bit_65 = + std::unique_ptr(RDKit::SmartsToMol("c:n")); + std::unique_ptr bit_66 = std::unique_ptr( + RDKit::SmartsToMol("[#6]~[#6](~[#6])(~[#6])~*")); + std::unique_ptr bit_67 = + std::unique_ptr(RDKit::SmartsToMol("[!#6!#1]~[#16]")); + std::unique_ptr bit_68 = std::unique_ptr( + RDKit::SmartsToMol("[!#6!#1!H0]~[!#6!#1!H0]")); + std::unique_ptr bit_69 = + std::unique_ptr(RDKit::SmartsToMol("[!#6!#1]~[!#6!#1!H0]")); + std::unique_ptr bit_70 = std::unique_ptr( + RDKit::SmartsToMol("[!#6!#1]~[#7]~[!#6!#1]")); + std::unique_ptr bit_71 = + std::unique_ptr(RDKit::SmartsToMol("[#7]~[#8]")); + std::unique_ptr bit_72 = + std::unique_ptr(RDKit::SmartsToMol("[#8]~*~*~[#8]")); + std::unique_ptr bit_73 = + std::unique_ptr(RDKit::SmartsToMol("[#16]=*")); + std::unique_ptr bit_74 = + std::unique_ptr(RDKit::SmartsToMol("[CH3]~*~[CH3]")); + std::unique_ptr bit_75 = + std::unique_ptr(RDKit::SmartsToMol("*!@[#7]@*")); + std::unique_ptr bit_76 = + std::unique_ptr(RDKit::SmartsToMol("[#6]=[#6](~*)~*")); + std::unique_ptr bit_77 = + std::unique_ptr(RDKit::SmartsToMol("[#7]~*~[#7]")); + std::unique_ptr bit_78 = + std::unique_ptr(RDKit::SmartsToMol("[#6]=[#7]")); + std::unique_ptr bit_79 = + std::unique_ptr(RDKit::SmartsToMol("[#7]~*~*~[#7]")); + std::unique_ptr bit_80 = + std::unique_ptr(RDKit::SmartsToMol("[#7]~*~*~*~[#7]")); + std::unique_ptr bit_81 = + std::unique_ptr(RDKit::SmartsToMol("[#16]~*(~*)~*")); + std::unique_ptr bit_82 = + std::unique_ptr(RDKit::SmartsToMol("*~[CH2]~[!#6!#1!H0]")); + std::unique_ptr bit_83 = + std::unique_ptr(RDKit::SmartsToMol("[!#6!#1]1~*~*~*~*~1")); + std::unique_ptr bit_84 = + std::unique_ptr(RDKit::SmartsToMol("[NH2]")); + std::unique_ptr bit_85 = std::unique_ptr( + RDKit::SmartsToMol("[#6]~[#7](~[#6])~[#6]")); + std::unique_ptr bit_86 = std::unique_ptr( + RDKit::SmartsToMol("[C;H2,H3][!#6!#1][C;H2,H3]")); + std::unique_ptr bit_87 = + std::unique_ptr(RDKit::SmartsToMol("[F,Cl,Br,I]!@*@*")); + std::unique_ptr bit_89 = + std::unique_ptr(RDKit::SmartsToMol("[#8]~*~*~*~[#8]")); + std::unique_ptr bit_90 = std::unique_ptr( + RDKit::SmartsToMol("[$([!#6!#1!H0]~*~*~[CH2]~*),$([!#6!#1!H0R]1@[R]@[R]@[" + "CH2R]1),$([!#6!#1!H0]~[R]1@[R]@[CH2R]1)]")); + std::unique_ptr bit_91 = std::unique_ptr< + RDKit::ROMol>(RDKit::SmartsToMol( + "[$([!#6!#1!H0]~*~*~*~[CH2]~*),$([!#6!#1!H0R]1@[R]@[R]@[R]@[CH2R]1),$([!#" + "6!#1!H0]~[R]1@[R]@[R]@[CH2R]1),$([!#6!#1!H0]~*~[R]1@[R]@[CH2R]1)]")); + std::unique_ptr bit_92 = std::unique_ptr( + RDKit::SmartsToMol("[#8]~[#6](~[#7])~[#6]")); + std::unique_ptr bit_93 = + std::unique_ptr(RDKit::SmartsToMol("[!#6!#1]~[CH3]")); + std::unique_ptr bit_94 = + std::unique_ptr(RDKit::SmartsToMol("[!#6!#1]~[#7]")); + std::unique_ptr bit_95 = + std::unique_ptr(RDKit::SmartsToMol("[#7]~*~*~[#8]")); + std::unique_ptr bit_96 = + std::unique_ptr(RDKit::SmartsToMol("*1~*~*~*~*~1")); + std::unique_ptr bit_97 = + std::unique_ptr(RDKit::SmartsToMol("[#7]~*~*~*~[#8]")); + std::unique_ptr bit_98 = std::unique_ptr( + RDKit::SmartsToMol("[!#6!#1]1~*~*~*~*~*~1")); + std::unique_ptr bit_99 = + std::unique_ptr(RDKit::SmartsToMol("[#6]=[#6]")); + std::unique_ptr bit_100 = + std::unique_ptr(RDKit::SmartsToMol("*~[CH2]~[#7]")); + std::unique_ptr bit_101 = std::unique_ptr< + RDKit::ROMol>(RDKit::SmartsToMol( + "[$([R]1@[R]@[R]@[R]@[R]@[R]@[R]@[R]@1),$([R]1@[R]@[R]@[R]@[R]@[R]@[R]@[" + "R]@[R]@1),$([R]1@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@1),$([R]1@[R]@[R]@[" + "R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@1),$([R]1@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]" + "@[R]@[R]@[R]@1),$([R]1@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@" + "1),$([R]1@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@[R]@1)]")); + std::unique_ptr bit_102 = + std::unique_ptr(RDKit::SmartsToMol("[!#6!#1]~[#8]")); + std::unique_ptr bit_104 = std::unique_ptr( + RDKit::SmartsToMol("[!#6!#1!H0]~*~[CH2]~*")); + std::unique_ptr bit_105 = + std::unique_ptr(RDKit::SmartsToMol("*@*(@*)@*")); + std::unique_ptr bit_106 = std::unique_ptr( + RDKit::SmartsToMol("[!#6!#1]~*(~[!#6!#1])~[!#6!#1]")); + std::unique_ptr bit_107 = + std::unique_ptr(RDKit::SmartsToMol("[F,Cl,Br,I]~*(~*)~*")); + std::unique_ptr bit_108 = + std::unique_ptr(RDKit::SmartsToMol("[CH3]~*~*~*~[CH2]~*")); + std::unique_ptr bit_109 = + std::unique_ptr(RDKit::SmartsToMol("*~[CH2]~[#8]")); + std::unique_ptr bit_110 = + std::unique_ptr(RDKit::SmartsToMol("[#7]~[#6]~[#8]")); + std::unique_ptr bit_111 = + std::unique_ptr(RDKit::SmartsToMol("[#7]~*~[CH2]~*")); + std::unique_ptr bit_112 = + std::unique_ptr(RDKit::SmartsToMol("*~*(~*)(~*)~*")); + std::unique_ptr bit_113 = + std::unique_ptr(RDKit::SmartsToMol("[#8]!:*:*")); + std::unique_ptr bit_114 = + std::unique_ptr(RDKit::SmartsToMol("[CH3]~[CH2]~*")); + std::unique_ptr bit_115 = + std::unique_ptr(RDKit::SmartsToMol("[CH3]~*~[CH2]~*")); + std::unique_ptr bit_116 = std::unique_ptr( + RDKit::SmartsToMol("[$([CH3]~*~*~[CH2]~*),$([CH3]~*1~*~[CH2]1)]")); + std::unique_ptr bit_117 = + std::unique_ptr(RDKit::SmartsToMol("[#7]~*~[#8]")); + std::unique_ptr bit_118 = std::unique_ptr( + RDKit::SmartsToMol("[$(*~[CH2]~[CH2]~*),$(*1~[CH2]~[CH2]1)]")); + std::unique_ptr bit_119 = + std::unique_ptr(RDKit::SmartsToMol("[#7]=*")); + std::unique_ptr bit_120 = + std::unique_ptr(RDKit::SmartsToMol("[!#6R]")); + std::unique_ptr bit_121 = + std::unique_ptr(RDKit::SmartsToMol("[#7R]")); + std::unique_ptr bit_122 = + std::unique_ptr(RDKit::SmartsToMol("*~[#7](~*)~*")); + std::unique_ptr bit_123 = + std::unique_ptr(RDKit::SmartsToMol("[#8]~[#6]~[#8]")); + std::unique_ptr bit_124 = + std::unique_ptr(RDKit::SmartsToMol("[!#6!#1]~[!#6!#1]")); + std::unique_ptr bit_126 = + std::unique_ptr(RDKit::SmartsToMol("*!@[#8]!@*")); + std::unique_ptr bit_127 = + std::unique_ptr(RDKit::SmartsToMol("*@*!@[#8]")); + std::unique_ptr bit_128 = + std::unique_ptr(RDKit::SmartsToMol( + "[$(*~[CH2]~*~*~*~[CH2]~*),$([R]1@[CH2R]@[R]@[R]@[R]@[CH2R]1),$(*~[" + "CH2]~[R]1@[R]@[R]@[CH2R]1),$(*~[CH2]~*~[R]1@[R]@[CH2R]1)]")); + std::unique_ptr bit_129 = std::unique_ptr( + RDKit::SmartsToMol("[$(*~[CH2]~*~*~[CH2]~*),$([R]1@[CH2]@[R]@[R]@[CH2R]1)" + ",$(*~[CH2]~[R]1@[R]@[CH2R]1)]")); + std::unique_ptr bit_131 = + std::unique_ptr(RDKit::SmartsToMol("[!#6!#1!H0]")); + std::unique_ptr bit_132 = + std::unique_ptr(RDKit::SmartsToMol("[#8]~*~[CH2]~*")); + std::unique_ptr bit_133 = + std::unique_ptr(RDKit::SmartsToMol("*@*!@[#7]")); + std::unique_ptr bit_135 = + std::unique_ptr(RDKit::SmartsToMol("[#7]!:*:*")); + std::unique_ptr bit_136 = + std::unique_ptr(RDKit::SmartsToMol("[#8]=*")); + std::unique_ptr bit_137 = + std::unique_ptr(RDKit::SmartsToMol("[!C!cR]")); + std::unique_ptr bit_138 = + std::unique_ptr(RDKit::SmartsToMol("[!#6!#1]~[CH2]~*")); + std::unique_ptr bit_139 = + std::unique_ptr(RDKit::SmartsToMol("[O!H0]")); + std::unique_ptr bit_140 = + std::unique_ptr(RDKit::SmartsToMol("[#8]")); + std::unique_ptr bit_141 = + std::unique_ptr(RDKit::SmartsToMol("[CH3]")); + std::unique_ptr bit_142 = + std::unique_ptr(RDKit::SmartsToMol("[#7]")); + std::unique_ptr bit_144 = + std::unique_ptr(RDKit::SmartsToMol("*!:*:*!:*")); + std::unique_ptr bit_145 = + std::unique_ptr(RDKit::SmartsToMol("*1~*~*~*~*~*~1")); + std::unique_ptr bit_147 = std::unique_ptr( + RDKit::SmartsToMol("[$(*~[CH2]~[CH2]~*),$([R]1@[CH2R]@[CH2R]1)]")); + std::unique_ptr bit_148 = + std::unique_ptr(RDKit::SmartsToMol("*~[!#6!#1](~*)~*")); + std::unique_ptr bit_149 = + std::unique_ptr(RDKit::SmartsToMol("[C;H3,H4]")); + std::unique_ptr bit_150 = + std::unique_ptr(RDKit::SmartsToMol("*!@*@*!@*")); + std::unique_ptr bit_151 = + std::unique_ptr(RDKit::SmartsToMol("[#7!H0]")); + std::unique_ptr bit_152 = std::unique_ptr( + RDKit::SmartsToMol("[#8]~[#6](~[#6])~[#6]")); + std::unique_ptr bit_154 = + std::unique_ptr(RDKit::SmartsToMol("[#6]=[#8]")); + std::unique_ptr bit_155 = + std::unique_ptr(RDKit::SmartsToMol("*!@[CH2]!@*")); + std::unique_ptr bit_156 = + std::unique_ptr(RDKit::SmartsToMol("[#7]~*(~*)~*")); + std::unique_ptr bit_157 = + std::unique_ptr(RDKit::SmartsToMol("[#6]-[#8]")); + std::unique_ptr bit_158 = + std::unique_ptr(RDKit::SmartsToMol("[#6]-[#7]")); + std::unique_ptr bit_162 = + std::unique_ptr(RDKit::SmartsToMol("a")); + std::unique_ptr bit_165 = + std::unique_ptr(RDKit::SmartsToMol("[R]")); }; -boost::flyweight, boost::flyweights::no_tracking> gpats; +boost::flyweight, boost::flyweights::no_tracking> + gpats; void GenerateFP(const RDKit::ROMol &mol, ExplicitBitVect &fp) { - if (gpats.get().size() == 0) { - std::vector ps; - ps.push_back(new Patterns()); - gpats = ps; + if (!gpats.get()) { + gpats = std::unique_ptr(new Patterns()); } - const Patterns &pats = *(gpats.get().front()); + const Patterns &pats = *(gpats.get()); PRECONDITION(fp.size() == 167, "bad fingerprint"); fp.clearBits(); @@ -651,7 +643,7 @@ void GenerateFP(const RDKit::ROMol &mol, ExplicitBitVect &fp) { std::vector mapping; if (RDKit::MolOps::getMolFrags(mol, mapping) > 1) fp.setBit(166); } -} // end of local anonymous namespace +} // namespace namespace RDKit { namespace MACCSFingerprints { @@ -660,5 +652,5 @@ ExplicitBitVect *getFingerprintAsBitVect(const ROMol &mol) { GenerateFP(mol, *fp); return fp; } -} -} +} // namespace MACCSFingerprints +} // namespace RDKit diff --git a/Code/GraphMol/Fingerprints/test1.cpp b/Code/GraphMol/Fingerprints/test1.cpp index 7ff91d6a4..9b6778dcd 100644 --- a/Code/GraphMol/Fingerprints/test1.cpp +++ b/Code/GraphMol/Fingerprints/test1.cpp @@ -114,6 +114,8 @@ void test1() { delete m2; delete fp2; } + delete m1; + delete fp1; } { std::string smi = "Oc1cc2[nH]cnc2c(O)n1"; @@ -1194,6 +1196,8 @@ void test4MorganFPs() { TEST_ASSERT(invars[1] == invars[2]); TEST_ASSERT(invars[0] == invars[7]); delete mol; + delete patterns[0]; + delete patterns[1]; } BOOST_LOG(rdErrorLog) << " done" << std::endl; } @@ -1284,6 +1288,7 @@ void test5MorganFPs() { delete m1; delete m2; + delete m3; } BOOST_LOG(rdErrorLog) << " done" << std::endl; @@ -1452,6 +1457,8 @@ void testAtomPairs2() { fp = AtomPairs::getAtomPairFingerprint(*mol, 2, 2); TEST_ASSERT(fp->getTotalVal() == 1); TEST_ASSERT(fp->getNonzeroElements().size() == 1); + delete fp; + delete mol; } BOOST_LOG(rdErrorLog) << " done" << std::endl; @@ -2644,6 +2651,8 @@ void testGitHubIssue151() { TEST_ASSERT(SubstructMatch(*m, *qm, mv)); TEST_ASSERT(AllProbeBitsMatch(*qbv, *mbv)); + delete qbv; + delete mbv; delete qm; delete m; } @@ -2659,6 +2668,8 @@ void testGitHubIssue151() { TEST_ASSERT(SubstructMatch(*m, *qm, mv)); TEST_ASSERT(AllProbeBitsMatch(*qbv, *mbv)); + delete qbv; + delete mbv; delete qm; delete m; } @@ -2673,6 +2684,8 @@ void testGitHubIssue151() { TEST_ASSERT(SubstructMatch(*m, *qm, mv)); TEST_ASSERT(AllProbeBitsMatch(*qbv, *mbv)); + delete qbv; + delete mbv; delete qm; delete m; } @@ -2688,6 +2701,8 @@ void testGitHubIssue151() { TEST_ASSERT(SubstructMatch(*m, *qm, mv)); TEST_ASSERT(AllProbeBitsMatch(*qbv, *mbv)); + delete qbv; + delete mbv; delete qm; delete m; } @@ -2718,6 +2733,7 @@ void test3DAtomPairs() { TEST_ASSERT(fp->getTotalVal() == 3); TEST_ASSERT(fp->getNonzeroElements().size() == 1); delete fp; + fp = nullptr; // we should get a conformer exception if there are no conformers: mol->clearConformers(); @@ -2730,7 +2746,9 @@ void test3DAtomPairs() { ok = true; } TEST_ASSERT(ok); - + if (fp != nullptr) { + delete fp; + } delete mol; } { @@ -2765,7 +2783,7 @@ void testGitHubIssue195() { auto *m1 = new ROMol(); ExplicitBitVect *fp1 = MACCSFingerprints::getFingerprintAsBitVect(*m1); TEST_ASSERT(fp1->getNumOnBits() == 0); - + delete fp1; delete m1; } BOOST_LOG(rdErrorLog) << " done" << std::endl; @@ -3203,7 +3221,6 @@ void testRDKFPUnfolded() { fp1 = getUnfoldedRDKFingerprintMol(*m1); TEST_ASSERT(fp1); - #if 0 for (iter = fp1->getNonzeroElements().begin(); iter != fp1->getNonzeroElements().end(); ++iter) { @@ -3224,7 +3241,7 @@ void testRDKFPUnfolded() { TEST_ASSERT(iter != fp1->getNonzeroElements().end() && iter->second == 1); iter = fp1->getNonzeroElements().find(3826517238); TEST_ASSERT(iter != fp1->getNonzeroElements().end() && iter->second == 2); - + delete fp1; delete m1; } { @@ -3236,7 +3253,7 @@ void testRDKFPUnfolded() { fp1 = getUnfoldedRDKFingerprintMol(*m1); TEST_ASSERT(fp1); TEST_ASSERT(fp1->getNonzeroElements().size() == 0); - + delete fp1; delete m1; } { @@ -3305,7 +3322,7 @@ void testRDKFPUnfolded() { iter2->second[0][0] == 1); TEST_ASSERT(iter2 != bitInfo.end() && iter2->second[0].size() == 2 && iter2->second[0][1] == 2); - + delete fp1; delete m1; } } @@ -3360,7 +3377,7 @@ void testRDKFPBitInfo() { iter2->second[0][0] == 1); TEST_ASSERT(iter2 != bitInfo.end() && iter2->second[0].size() == 2 && iter2->second[0][1] == 2); - + delete fp1; delete m1; } } diff --git a/Code/GraphMol/Fingerprints/testFingerprintGenerators.cpp b/Code/GraphMol/Fingerprints/testFingerprintGenerators.cpp index e3ba34dca..05e311888 100644 --- a/Code/GraphMol/Fingerprints/testFingerprintGenerators.cpp +++ b/Code/GraphMol/Fingerprints/testFingerprintGenerators.cpp @@ -138,6 +138,9 @@ void testAtomPairArgs() { TEST_ASSERT(fp->getVal(AtomPair::getAtomPairCode(c1, c2, 1, true)) == 2); TEST_ASSERT(fp->getVal(AtomPair::getAtomPairCode(c1, c3, 2, true)) == 1); + delete fp; + delete atomPairGenerator; + atomPairGenerator = AtomPair::getAtomPairGenerator( 1, 30, false, true, nullptr, false); fp = atomPairGenerator->getSparseCountFingerprint(*mol); @@ -218,11 +221,10 @@ void testAtomPairNonSparseBitvector() { fp2 = atomPairGenerator->getFingerprint(*mol); std::map nz = fp1->getNonzeroElements(); - for (std::map::iterator it = nz.begin(); it != nz.end(); - it++) { - for (unsigned int i = 0; i < defaultCountBounds.size(); i++) { - bool isSet = fp2->getBit(it->first * defaultCountBounds.size() + i); - TEST_ASSERT(isSet == (it->second >= defaultCountBounds[i])); + for (const auto& it : nz) { + for (unsigned int i = 0; i < defaultCountBounds.size(); ++i) { + bool isSet = static_cast(fp2->getBit(it.first * defaultCountBounds.size() + i)); + TEST_ASSERT(isSet == (it.second >= static_cast(defaultCountBounds[i]))); } } @@ -235,11 +237,10 @@ void testAtomPairNonSparseBitvector() { fp2 = atomPairGenerator->getFingerprint(*mol); nz = fp1->getNonzeroElements(); - for (std::map::iterator it = nz.begin(); it != nz.end(); - it++) { - for (unsigned int i = 0; i < defaultCountBounds.size(); i++) { - bool isSet = fp2->getBit(it->first * defaultCountBounds.size() + i); - TEST_ASSERT(isSet == (it->second >= defaultCountBounds[i])); + for (const auto& it : nz) { + for (unsigned int i = 0; i < defaultCountBounds.size(); ++i) { + bool isSet = static_cast(fp2->getBit(it.first * defaultCountBounds.size() + i)); + TEST_ASSERT(isSet == (it.second >= static_cast(defaultCountBounds[i]))); } } @@ -1008,6 +1009,8 @@ void testMorganFPFeatureInvs() { delete mol; delete invGen; delete invars; + delete patterns[0]; + delete patterns[1]; } BOOST_LOG(rdErrorLog) << " done" << std::endl; } @@ -1103,6 +1106,7 @@ void testMorganFPOptions() { delete m1; delete m2; + delete m3; delete generator; delete generatorChirality; } @@ -1485,6 +1489,7 @@ void testRDKFPUnfolded() { TEST_ASSERT(iter != fp1->getNonzeroElements().end() && iter->second == 2); delete m1; + delete fp1; delete generator; } { @@ -1500,6 +1505,7 @@ void testRDKFPUnfolded() { TEST_ASSERT(fp1->getNonzeroElements().size() == 0); delete m1; + delete fp1; delete generator; } // additional outputs are not fully functional yet @@ -2385,7 +2391,7 @@ void testBulkFP() { compareRes.push_back(it.first->getSparseCountFingerprint(*m)); } - for (int i = 0; i < results->size(); i++) { + for (unsigned long i = 0; i < results->size(); ++i) { TEST_ASSERT(*((*results)[i]) == *compareRes[i]); delete (*results)[i]; @@ -2395,7 +2401,8 @@ void testBulkFP() { delete results; } - BOOST_FOREACH (auto m, molVect) { delete m; } + BOOST_FOREACH (auto&& m, molVect) { delete m; } + BOOST_FOREACH (auto&& t, testPairs) { delete t.first; } BOOST_LOG(rdErrorLog) << " done" << std::endl; } diff --git a/Code/GraphMol/ForceFieldHelpers/CrystalFF/testCrystalFF.cpp b/Code/GraphMol/ForceFieldHelpers/CrystalFF/testCrystalFF.cpp index e524b500c..2f8c93625 100644 --- a/Code/GraphMol/ForceFieldHelpers/CrystalFF/testCrystalFF.cpp +++ b/Code/GraphMol/ForceFieldHelpers/CrystalFF/testCrystalFF.cpp @@ -145,6 +145,7 @@ void testTorsionPrefs() { ForceFields::CrystalFF::getExperimentalTorsions( *mol, expTorsionAtoms, expTorsionAngles, improperAtoms, true, false, 1, false); + delete mol; TEST_ASSERT(expTorsionAtoms.size() == 2); TEST_ASSERT(expTorsionAngles.size() == 2); } diff --git a/Code/GraphMol/ForceFieldHelpers/MMFF/testMMFFHelpers.cpp b/Code/GraphMol/ForceFieldHelpers/MMFF/testMMFFHelpers.cpp index e9147b6a7..591170f61 100644 --- a/Code/GraphMol/ForceFieldHelpers/MMFF/testMMFFHelpers.cpp +++ b/Code/GraphMol/ForceFieldHelpers/MMFF/testMMFFHelpers.cpp @@ -418,17 +418,18 @@ void testMMFFBatch() { if (field) { field->initialize(); int failed = field->minimize(500); + delete field; if (failed) { BOOST_LOG(rdErrorLog) << " not converged (code = " << failed << ")" << std::endl; std::cout << origMolBlock << "$$$$" << std::endl; std::cout << MolToMolBlock(*mol) << "$$$$" << std::endl; } - delete field; } delete mol; mol = suppl.next(); } + delete mol; BOOST_LOG(rdErrorLog) << " done" << std::endl; } @@ -627,6 +628,8 @@ void testGithub308() { field->initialize(); needMore = field->minimize(200, 1.0e-6, 1.0e-3); TEST_ASSERT(!needMore); + delete mol; + delete field; } void testSFIssue1653802() { @@ -767,6 +770,7 @@ void testMMFFParamGetters() { ROMol *mol = SmilesToMol("c1ccccc1CCNN"); TEST_ASSERT(mol); ROMol *molH = MolOps::addHs(*mol); + delete mol; TEST_ASSERT(molH); MMFF::MMFFMolProperties *mmffMolProperties = new MMFF::MMFFMolProperties(*molH); @@ -833,6 +837,7 @@ void testMMFFParamGetters() { RWMol *patt = SmartsToMol("NN[H]"); MatchVectType matchVect; TEST_ASSERT(SubstructMatch(*molH, (ROMol &)*patt, matchVect)); + delete patt; unsigned int nIdx = matchVect[0].second; unsigned int hIdx = matchVect[2].second; TEST_ASSERT(mmffMolProperties->getMMFFVdWParams(nIdx, hIdx, mmffVdWParams)); @@ -842,6 +847,8 @@ void testMMFFParamGetters() { ((int)boost::math::round(mmffVdWParams.epsilonUnscaled * 1000) == 34) && ((int)boost::math::round(mmffVdWParams.R_ij_star * 1000) == 2657) && ((int)boost::math::round(mmffVdWParams.epsilon * 1000) == 17)); + delete molH; + delete mmffMolProperties; } } #ifdef RDK_TEST_MULTITHREADED @@ -872,7 +879,7 @@ void runblock_mmff(const std::vector &mols, } } } -} +} // namespace #include #include void testMMFFMultiThread() { diff --git a/Code/GraphMol/ForceFieldHelpers/UFF/testUFFHelpers.cpp b/Code/GraphMol/ForceFieldHelpers/UFF/testUFFHelpers.cpp index 7d9a17176..f6157b8df 100644 --- a/Code/GraphMol/ForceFieldHelpers/UFF/testUFFHelpers.cpp +++ b/Code/GraphMol/ForceFieldHelpers/UFF/testUFFHelpers.cpp @@ -131,6 +131,7 @@ void testUFFTyper1() { TEST_ASSERT(key == "Rb"); key = UFF::Tools::getAtomLabel(mol->getAtomWithIdx(4)); TEST_ASSERT(key == "Cs"); + delete mol; BOOST_LOG(rdErrorLog) << " done" << std::endl; } @@ -163,6 +164,7 @@ void testUFFTyper2() { it != types.end(); it++) { TEST_ASSERT((*it)); } + delete mol2; // connected with sf.net bug 2094445 mol = SmilesToMol("[SiH2]=C"); @@ -171,6 +173,7 @@ void testUFFTyper2() { TEST_ASSERT(key == "Si3"); key = UFF::Tools::getAtomLabel(mol->getAtomWithIdx(1)); TEST_ASSERT(key == "C_2"); + delete mol; mol = SmilesToMol("[AlH]=C"); TEST_ASSERT(mol); @@ -178,6 +181,7 @@ void testUFFTyper2() { TEST_ASSERT(key == "Al3"); key = UFF::Tools::getAtomLabel(mol->getAtomWithIdx(1)); TEST_ASSERT(key == "C_2"); + delete mol; mol = SmilesToMol("[Mg]=C"); TEST_ASSERT(mol); @@ -185,6 +189,7 @@ void testUFFTyper2() { TEST_ASSERT(key == "Mg3+2"); key = UFF::Tools::getAtomLabel(mol->getAtomWithIdx(1)); TEST_ASSERT(key == "C_2"); + delete mol; mol = SmilesToMol("[SiH3][Si]([SiH3])=C"); TEST_ASSERT(mol); @@ -196,6 +201,7 @@ void testUFFTyper2() { TEST_ASSERT(key == "Si3"); key = UFF::Tools::getAtomLabel(mol->getAtomWithIdx(3)); TEST_ASSERT(key == "C_2"); + delete mol; BOOST_LOG(rdErrorLog) << " done" << std::endl; } @@ -608,6 +614,7 @@ void testUFFBatch() { delete mol; mol = suppl.next(); } + delete mol; BOOST_LOG(rdErrorLog) << " done" << std::endl; } @@ -1102,7 +1109,9 @@ void testGitHubIssue62() { SmilesMolSupplier smiSupplier(pathName + "/Issue62.smi"); SDWriter *sdfWriter = new SDWriter(pathName + "/Issue62.sdf"); for (unsigned int i = 0; i < smiSupplier.length(); ++i) { - ROMol *mol = MolOps::addHs(*(smiSupplier[i])); + auto *tmp = smiSupplier[i]; + ROMol *mol = MolOps::addHs(*tmp); + delete tmp; TEST_ASSERT(mol); std::string molName = ""; if (mol->hasProp(common_properties::_Name)) { @@ -1118,8 +1127,11 @@ void testGitHubIssue62() { double e = field->calcEnergy(); BOOST_LOG(rdErrorLog) << molName << " " << e << std::endl; TEST_ASSERT(fabs(e - energyValues[i]) < 1.); + delete field; + delete mol; } sdfWriter->close(); + delete sdfWriter; BOOST_LOG(rdErrorLog) << " done" << std::endl; } } @@ -1131,6 +1143,7 @@ void testUFFParamGetters() { ROMol *mol = SmilesToMol("c1ccccc1CCNN"); TEST_ASSERT(mol); ROMol *molH = MolOps::addHs(*mol); + delete mol; TEST_ASSERT(molH); ForceFields::UFF::UFFBond uffBondStretchParams; TEST_ASSERT( @@ -1161,6 +1174,7 @@ void testUFFParamGetters() { TEST_ASSERT(UFF::getUFFVdWParams(*molH, 0, 9, uffVdWParams)); TEST_ASSERT(((int)boost::math::round(uffVdWParams.x_ij * 1000) == 3754) && ((int)boost::math::round(uffVdWParams.D_ij * 1000) == 85)); + delete molH; } } @@ -1192,7 +1206,7 @@ void runblock_uff(const std::vector &mols, } } } -} +} // namespace #include #include void testUFFMultiThread() { @@ -1314,6 +1328,7 @@ void testGitHubIssue613() { TEST_ASSERT(ap); TEST_ASSERT(ap->r1 == types[0]->r1); TEST_ASSERT(ap->theta0 == types[0]->theta0); + delete mol; } BOOST_LOG(rdErrorLog) << " done" << std::endl; } diff --git a/Code/GraphMol/FragCatalog/test1.cpp b/Code/GraphMol/FragCatalog/test1.cpp index 1d7fcc187..405e8d69f 100644 --- a/Code/GraphMol/FragCatalog/test1.cpp +++ b/Code/GraphMol/FragCatalog/test1.cpp @@ -34,12 +34,11 @@ using namespace RDKit; -void testMols(std::vector &mols, FragFPGenerator &fpGen, +void testMols(std::vector> &mols, FragFPGenerator &fpGen, FragCatalog &fcat) { - std::vector::iterator mi; int nDone = 0; - for (mi = mols.begin(); mi != mols.end(); mi++) { - ExplicitBitVect *fp = fpGen.getFPForMol(*(*mi), fcat); + for (auto&& mi : mols) { + ExplicitBitVect *fp = fpGen.getFPForMol(*mi, fcat); switch (nDone) { case 0: TEST_ASSERT(fp->getNumOnBits() == 3); @@ -84,6 +83,7 @@ void testMols(std::vector &mols, FragFPGenerator &fpGen, TEST_ASSERT((*fp)[10]); break; } + delete fp; nDone += 1; } } @@ -100,11 +100,11 @@ void test1() { FragCatalog fcat(fparams); FragCatGenerator catGen; - std::vector mols; + std::vector> mols; unsigned int nDone = 0; ROMol *m = suppl.next(); while (m) { - mols.push_back(m); + mols.push_back(std::unique_ptr(m)); nDone += 1; catGen.addFragsFromMol(*m, &fcat); try { @@ -146,6 +146,7 @@ void test1() { TEST_ASSERT(fpEntry->getBitId() == fpEntry2->getBitId()); TEST_ASSERT(fpEntry2->match(fpEntry, 1e-8)); TEST_ASSERT(fpEntry->match(fpEntry2, 1e-8)); + delete fpEntry2; // test catalogs' initFromString: FragCatalog fcat2; @@ -205,6 +206,8 @@ void test1() { BOOST_LOG(rdInfoLog) << "---- Done" << std::endl; delete tmpMol; + delete fparams; + delete fcat3; } void testIssue294() { @@ -220,10 +223,10 @@ void testIssue294() { FragCatalog fcat(fparams); FragCatGenerator catGen; - std::vector mols; + std::vector> mols; ROMol *m = suppl.next(); while (m) { - mols.push_back(m); + mols.push_back(std::unique_ptr(m)); catGen.addFragsFromMol(*m, &fcat); try { m = suppl.next(); @@ -235,15 +238,13 @@ void testIssue294() { TEST_ASSERT(nents == 21); FragFPGenerator fpGen; - m = mols[0]; - for (unsigned int i = 0; i < 200; i++) { - for (std::vector::const_iterator mi = mols.begin(); - mi != mols.end(); mi++) { - ExplicitBitVect *fp = fpGen.getFPForMol(*(*mi), fcat); + for (auto&& mi : mols) { + ExplicitBitVect *fp = fpGen.getFPForMol(*mi, fcat); delete fp; } } + delete fparams; BOOST_LOG(rdInfoLog) << "---- Done" << std::endl; } diff --git a/Code/GraphMol/MolAlign/testMolAlign.cpp b/Code/GraphMol/MolAlign/testMolAlign.cpp index 9bcc95cca..1496317d0 100644 --- a/Code/GraphMol/MolAlign/testMolAlign.cpp +++ b/Code/GraphMol/MolAlign/testMolAlign.cpp @@ -89,11 +89,11 @@ void test1MolWithQueryAlign() { std::string rdbase = getenv("RDBASE"); std::string fname1 = rdbase + "/Code/GraphMol/MolAlign/test_data/1oir.mol"; - auto *m1 = new RWMol(*MolFileToMol(fname1)); + auto *m1 = MolFileToMol(fname1); auto *a1 = new QueryAtom(6); std::string fname2 = rdbase + "/Code/GraphMol/MolAlign/test_data/1oir_conf.mol"; - auto *m2 = new RWMol(*MolFileToMol(fname2)); + auto *m2 = MolFileToMol(fname2); auto *a2 = new QueryAtom(6); // we replace the same nitrogen instead with a null @@ -107,8 +107,9 @@ void test1MolWithQueryAlign() { std::string fname3 = rdbase + "/Code/GraphMol/MolAlign/test_data/1oir_trans.mol"; - auto *m3 = new RWMol(*MolFileToMol(fname3)); - m3->replaceAtom(0, new QueryAtom(5)); + auto *m3 = MolFileToMol(fname3); + auto *a3 = new QueryAtom(5); + m3->replaceAtom(0, a3); const Conformer &conf1 = m2->getConformer(0); const Conformer &conf2 = m3->getConformer(0); @@ -133,6 +134,9 @@ void test1MolWithQueryAlign() { delete m1; delete m2; delete m3; + delete a1; + delete a2; + delete a3; } void test2AtomMap() { @@ -205,6 +209,13 @@ void testIssue241() { ff2->minimize(200, 1e-8, 1e-6); double rmsd = MolAlign::alignMol(*ref, *probe); + + delete ff1; + delete ff2; + delete m1; + delete ref; + delete probe; + TEST_ASSERT(RDKit::feq(rmsd, 0.0)); } @@ -386,9 +397,12 @@ void testMMFFO3AConstraints() { ForceFields::ForceField *field = MMFF::constructForceField(*m1, &mp); field->initialize(); field->minimize(); + delete field; + RWMol *patt = SmartsToMol("nccc-cccc"); MatchVectType matchVect; TEST_ASSERT(SubstructMatch(*m1, (ROMol &)*patt, matchVect)); + delete patt; unsigned int nIdx = matchVect[0].second; unsigned int cIdx = matchVect[matchVect.size() - 1].second; MolTransforms::setDihedralDeg(m1->getConformer(), matchVect[2].second, @@ -431,9 +445,11 @@ void testCrippenO3AConstraints() { ForceFields::ForceField *field = MMFF::constructForceField(*m1, &mp); field->initialize(); field->minimize(); + delete field; RWMol *patt = SmartsToMol("nccc-cccc"); MatchVectType matchVect; TEST_ASSERT(SubstructMatch(*m1, (ROMol &)*patt, matchVect)); + delete patt; unsigned int nIdx = matchVect[0].second; unsigned int cIdx = matchVect[matchVect.size() - 1].second; MolTransforms::setDihedralDeg(m1->getConformer(), matchVect[2].second, @@ -533,6 +549,8 @@ void testMMFFO3AConstraintsAndLocalOnly() { .length(); TEST_ASSERT(feq(d, distOS[i], 0.1)); } + delete refMol; + delete prbMol; } void testCrippenO3AConstraintsAndLocalOnly() { @@ -585,6 +603,8 @@ void testCrippenO3AConstraintsAndLocalOnly() { .length(); TEST_ASSERT(feq(d, distOS[i], 0.1)); } + delete prbMol; + delete refMol; } #ifdef RDK_TEST_MULTITHREADED @@ -647,7 +667,7 @@ void runblock_o3a_crippen(ROMol *refMol, const std::vector &mols, } } } -} +} // namespace #include #include void testMMFFO3AMultiThread() { @@ -697,7 +717,7 @@ void testMMFFO3AMultiThread() { fut.get(); } - BOOST_FOREACH (ROMol *mol, mols) { delete mol; } + BOOST_FOREACH (auto &&mol, mols) { delete mol; } BOOST_LOG(rdErrorLog) << " done" << std::endl; } @@ -893,8 +913,7 @@ void testO3AMultiThreadBug() { #endif delete refMol; - for (auto &mol : mols) delete mol; - + BOOST_FOREACH (auto &&mol, mols) { delete mol; } BOOST_LOG(rdErrorLog) << " done" << std::endl; } @@ -902,91 +921,91 @@ int main() { std::cout << "***********************************************************\n"; std::cout << "Testing MolAlign\n"; -#if 1 - std::cout << "\t---------------------------------\n"; - std::cout << "\t test1MolAlign \n\n"; - test1MolAlign(); + #if 1 + std::cout << "\t---------------------------------\n"; + std::cout << "\t test1MolAlign \n\n"; + test1MolAlign(); - std::cout << "\t---------------------------------\n"; - std::cout << "\t test1GetBestRMS \n\n"; - test1GetBestRMS(); + std::cout << "\t---------------------------------\n"; + std::cout << "\t test1GetBestRMS \n\n"; + test1GetBestRMS(); - std::cout << "\t---------------------------------\n"; - std::cout << "\t test1MolWithQueryAlign \n\n"; - test1MolWithQueryAlign(); + std::cout << "\t---------------------------------\n"; + std::cout << "\t test1MolWithQueryAlign \n\n"; + test1MolWithQueryAlign(); - std::cout << "\t---------------------------------\n"; - std::cout << "\t test2AtomMap \n\n"; - test2AtomMap(); + std::cout << "\t---------------------------------\n"; + std::cout << "\t test2AtomMap \n\n"; + test2AtomMap(); - std::cout << "\t---------------------------------\n"; - std::cout << "\t test3Weights \n\n"; - test3Weights(); + std::cout << "\t---------------------------------\n"; + std::cout << "\t test3Weights \n\n"; + test3Weights(); - std::cout << "\t---------------------------------\n"; - std::cout << "\t testIssue241 \n\n"; - testIssue241(); + std::cout << "\t---------------------------------\n"; + std::cout << "\t testIssue241 \n\n"; + testIssue241(); - std::cout << "\t---------------------------------\n"; - std::cout << "\t testMMFFO3A \n\n"; - testMMFFO3A(); + std::cout << "\t---------------------------------\n"; + std::cout << "\t testMMFFO3A \n\n"; + testMMFFO3A(); - std::cout << "\t---------------------------------\n"; - std::cout << "\t testMMFFO3A with pre-computed dmat and MolHistogram\n\n"; - testMMFFO3AMolHist(); + std::cout << "\t---------------------------------\n"; + std::cout << "\t testMMFFO3A with pre-computed dmat and MolHistogram\n\n"; + testMMFFO3AMolHist(); - std::cout << "\t---------------------------------\n"; - std::cout << "\t testMMFFO3A with constraints\n\n"; - testMMFFO3AConstraints(); + std::cout << "\t---------------------------------\n"; + std::cout << "\t testMMFFO3A with constraints\n\n"; + testMMFFO3AConstraints(); - std::cout << "\t---------------------------------\n"; - std::cout << "\t testMMFFO3A with variable weight constraints followed by " - "local-only optimization\n\n"; - testMMFFO3AConstraintsAndLocalOnly(); + std::cout << "\t---------------------------------\n"; + std::cout << "\t testMMFFO3A with variable weight constraints followed by " + "local-only optimization\n\n"; + testMMFFO3AConstraintsAndLocalOnly(); - std::cout << "\t---------------------------------\n"; - std::cout << "\t testCrippenO3A \n\n"; - testCrippenO3A(); + std::cout << "\t---------------------------------\n"; + std::cout << "\t testCrippenO3A \n\n"; + testCrippenO3A(); - std::cout << "\t---------------------------------\n"; + std::cout << "\t---------------------------------\n"; std::cout << "\t testCrippenO3A with pre-computed dmat and MolHistogram\n\n"; testCrippenO3AMolHist(); - std::cout << "\t---------------------------------\n"; - std::cout << "\t testCrippenO3A with constraints\n\n"; - testCrippenO3AConstraints(); + std::cout << "\t---------------------------------\n"; + std::cout << "\t testCrippenO3A with constraints\n\n"; + testCrippenO3AConstraints(); - std::cout << "\t---------------------------------\n"; + std::cout << "\t---------------------------------\n"; std::cout << "\t testCrippenO3A with variable weight constraints followed by " "local-only optimization\n\n"; testCrippenO3AConstraintsAndLocalOnly(); -#ifdef RDK_TEST_MULTITHREADED - std::cout << "\t---------------------------------\n"; - std::cout << "\t testMMFFO3A multithreading\n\n"; - testMMFFO3AMultiThread(); + #ifdef RDK_TEST_MULTITHREADED + std::cout << "\t---------------------------------\n"; + std::cout << "\t testMMFFO3A multithreading\n\n"; + testMMFFO3AMultiThread(); - std::cout << "\t---------------------------------\n"; - std::cout << "\t test O3A multithreading bug\n\n"; - testO3AMultiThreadBug(); -#endif + std::cout << "\t---------------------------------\n"; + std::cout << "\t test O3A multithreading bug\n\n"; + testO3AMultiThreadBug(); + #endif -#ifdef RDK_TEST_MULTITHREADED - std::cout << "\t---------------------------------\n"; - std::cout << "\t testCrippenO3A multithreading\n\n"; - testCrippenO3AMultiThread(); -#endif + #ifdef RDK_TEST_MULTITHREADED + std::cout << "\t---------------------------------\n"; + std::cout << "\t testCrippenO3A multithreading\n\n"; + testCrippenO3AMultiThread(); + #endif - std::cout << "\t---------------------------------\n"; - std::cout << "\t test getO3AForProbeConfs\n\n"; - testGetO3AForProbeConfs(); -#endif + std::cout << "\t---------------------------------\n"; + std::cout << "\t test getO3AForProbeConfs\n\n"; + testGetO3AForProbeConfs(); + #endif -#ifdef RDK_TEST_MULTITHREADED - std::cout << "\t---------------------------------\n"; - std::cout << "\t test O3A multithreading bug\n\n"; - testO3AMultiThreadBug(); -#endif + #ifdef RDK_TEST_MULTITHREADED + std::cout << "\t---------------------------------\n"; + std::cout << "\t test O3A multithreading bug\n\n"; + testO3AMultiThreadBug(); + #endif std::cout << "***********************************************************\n"; } diff --git a/Code/GraphMol/MolCatalog/test1.cpp b/Code/GraphMol/MolCatalog/test1.cpp index 3fc5bb9cd..6508c4fae 100644 --- a/Code/GraphMol/MolCatalog/test1.cpp +++ b/Code/GraphMol/MolCatalog/test1.cpp @@ -30,9 +30,11 @@ void test1() { // MolCatalogParams are currently unused, so testing is easy: auto *mparams = new MolCatalogParams(); std::string pkl = mparams->Serialize(); - TEST_ASSERT(pkl == ""); + TEST_ASSERT(pkl.empty()); auto *mcat = new MolCatalog(mparams); + delete mparams; + TEST_ASSERT(mcat->getNumEntries() == 0); TEST_ASSERT(mcat->getFPLength() == 0); @@ -58,6 +60,7 @@ void test1() { entry->setDescription("child1"); entry->setOrder(1); mcat->addEntry(entry); + mol = SmilesToMol("C(=O)O"); entry = new MolCatalogEntry(mol); entry->setDescription("child2"); @@ -92,6 +95,7 @@ void test1() { pkl = mcat->Serialize(); delete mcat; + mcat = new MolCatalog(pkl); TEST_ASSERT(mcat->getNumEntries() == 3); TEST_ASSERT(mcat->getFPLength() == 3); @@ -107,6 +111,8 @@ void test1() { TEST_ASSERT(mcat->getEntryWithBitId(1)->getMol()->getNumAtoms() == 1); TEST_ASSERT(mcat->getEntryWithBitId(2)->getMol()->getNumAtoms() == 3); + delete mcat; + BOOST_LOG(rdInfoLog) << "<<-------------- Done" << std::endl; } diff --git a/Code/GraphMol/MolChemicalFeatures/FeatureParser.cpp b/Code/GraphMol/MolChemicalFeatures/FeatureParser.cpp index 468d450fe..ef5258ddf 100644 --- a/Code/GraphMol/MolChemicalFeatures/FeatureParser.cpp +++ b/Code/GraphMol/MolChemicalFeatures/FeatureParser.cpp @@ -155,10 +155,10 @@ MolChemicalFeatureDef *parseFeatureDef( // handle a blank or comment first line: boost::trim_if(nextLine, boost::is_any_of(" \t\r\n")); - while (nextLine == "" || nextLine[0] == '#') { + while (nextLine.empty() || nextLine[0] == '#') { Local::getNextLine(inStream, nextLine, lineNo); // need to check for EOS before we strip: - if (nextLine == "") { + if (nextLine.empty()) { // we hit EOS: throw FeatureFileParseException(lineNo, inLine, "EOF hit parsing feature definition"); @@ -284,7 +284,7 @@ int parseFeatureData(std::istream &inStream, while (!inStream.eof()) { // clean any whitespace off the line: boost::trim_if(inLine, boost::is_any_of(" \t\r\n")); - if (inLine != "" && inLine[0] != '#' && inLine[0] != '\n') { + if (!inLine.empty() && inLine[0] != '#' && inLine[0] != '\n') { boost::tokenizer<> tok(inLine); boost::tokenizer<>::iterator tokIt = tok.begin(); std::string token = boost::to_upper_copy(*tokIt); diff --git a/Code/GraphMol/MolChemicalFeatures/testFeatures.cpp b/Code/GraphMol/MolChemicalFeatures/testFeatures.cpp index 077aceab0..027648196 100644 --- a/Code/GraphMol/MolChemicalFeatures/testFeatures.cpp +++ b/Code/GraphMol/MolChemicalFeatures/testFeatures.cpp @@ -703,6 +703,7 @@ void testIssue347() { TEST_ASSERT(featSPtr->getFamily() == "LumpedHydrophobe"); TEST_ASSERT(featSPtr->getType() == "CTriplet"); + delete factory; // now reverse the order and we should get two matches: fdef = "DefineFeature CPair [C][C]\n" @@ -741,7 +742,8 @@ void testIssue347() { TEST_ASSERT(featSPtr->getFamily() == "LumpedHydrophobe"); TEST_ASSERT(featSPtr->getType() == "CTriplet"); - delete (factory); + delete factory; + delete testMol; BOOST_LOG(rdErrorLog) << " done" << std::endl; } @@ -843,6 +845,10 @@ void testGithub252() { } catch (const Invar::Invariant &i) { ok = true; } + + delete factory; + delete testMol; + TEST_ASSERT(ok); BOOST_LOG(rdErrorLog) << " Done" << std::endl; } diff --git a/Code/GraphMol/MolDraw2D/test1.cpp b/Code/GraphMol/MolDraw2D/test1.cpp index e469a4926..8340c2590 100644 --- a/Code/GraphMol/MolDraw2D/test1.cpp +++ b/Code/GraphMol/MolDraw2D/test1.cpp @@ -614,6 +614,9 @@ void testMultiThreaded() { for (auto &fut : tg) { fut.get(); } + for (auto&& mol : mols) { + delete mol; + } std::cerr << " Done" << std::endl; } #else @@ -636,6 +639,7 @@ void test6() { std::ofstream outs("test6_1.svg"); outs << txt; // TEST_ASSERT(txt.find(" result(tokens.begin(), tokens.end()); // tautomer information to collect from each line - std::string name = ""; - std::string smarts = ""; - std::string bond_str = ""; - std::string charge_str = ""; + std::string name; + std::string smarts; + std::string bond_str; + std::string charge_str; // line must have at least two tab separated values if (result.size() < 2) { @@ -140,11 +140,13 @@ std::vector readTautomers(std::string fileName) { std::vector readTautomers(std::istream& inStream, int nToRead) { - std::vector tautomers; - tautomers.clear(); if (inStream.bad()) { throw BadFileException("Bad stream contents."); } + std::vector tautomers; + if (nToRead > 0) { + tautomers.reserve(nToRead); + } const int MAX_LINE_LEN = 512; char inLine[MAX_LINE_LEN]; std::string tmpstr; @@ -156,11 +158,13 @@ std::vector readTautomers(std::istream& inStream, TautomerTransform* transform = getTautomer(tmpstr); if (transform != nullptr) { // std::cout << MolToSmiles(*(transform->Mol) ) << - //std::endl; - tautomers.push_back(*transform); + // std::endl; + tautomers.emplace_back(*transform); + delete transform; nRead++; } } + return tautomers; } diff --git a/Code/GraphMol/MolStandardize/TautomerCatalog/TautomerCatalogUtils.h b/Code/GraphMol/MolStandardize/TautomerCatalog/TautomerCatalogUtils.h index 4503ab22d..d1d1b0b42 100644 --- a/Code/GraphMol/MolStandardize/TautomerCatalog/TautomerCatalogUtils.h +++ b/Code/GraphMol/MolStandardize/TautomerCatalog/TautomerCatalogUtils.h @@ -32,13 +32,31 @@ class TautomerCatalogParams; //} BondType; // typedef std::vector tautomerTransform; -struct RDKIT_MOLSTANDARDIZE_EXPORT TautomerTransform { +class RDKIT_MOLSTANDARDIZE_EXPORT TautomerTransform { + public: ROMol* Mol; std::vector BondTypes; std::vector Charges; - TautomerTransform(ROMol* mol, std::vector bondtypes, - std::vector charges) + + TautomerTransform(ROMol* mol, const std::vector& bondtypes, + const std::vector& charges) : Mol(mol), BondTypes(bondtypes), Charges(charges) {} + + TautomerTransform(const TautomerTransform& other) + : BondTypes(other.BondTypes), Charges(other.Charges) { + Mol = new ROMol(*other.Mol); + } + + TautomerTransform& operator=(const TautomerTransform& other) { + if (this == &other) { + return *this; + } + Mol = new ROMol(*other.Mol); + BondTypes = other.BondTypes; + Charges = other.Charges; + }; + + ~TautomerTransform() { delete Mol; } }; RDKIT_MOLSTANDARDIZE_EXPORT std::vector stringToBondType( @@ -54,4 +72,4 @@ RDKIT_MOLSTANDARDIZE_EXPORT std::vector readTautomers( } // namespace MolStandardize } // namespace RDKit -#endif +#endif \ No newline at end of file diff --git a/Code/GraphMol/MolStandardize/testTautomer.cpp b/Code/GraphMol/MolStandardize/testTautomer.cpp index f3ef36127..f02487094 100644 --- a/Code/GraphMol/MolStandardize/testTautomer.cpp +++ b/Code/GraphMol/MolStandardize/testTautomer.cpp @@ -22,11 +22,11 @@ void testEnumerator() { std::string rdbase = getenv("RDBASE"); std::string tautomerFile = rdbase + "/Data/MolStandardize/tautomerTransforms.in"; - auto *tautparams = new TautomerCatalogParams(tautomerFile); + auto tautparams = std::unique_ptr(new TautomerCatalogParams(tautomerFile)); unsigned int ntautomers = tautparams->getNumTautomers(); TEST_ASSERT(ntautomers == 34); - TautomerCatalog tautcat(tautparams); + TautomerCatalog tautcat(tautparams.get()); TautomerEnumerator te; // Enumerate 1,3 keto/enol tautomer. diff --git a/Code/GraphMol/MolTransforms/test1.cpp b/Code/GraphMol/MolTransforms/test1.cpp index ca671499b..7413d3ad3 100644 --- a/Code/GraphMol/MolTransforms/test1.cpp +++ b/Code/GraphMol/MolTransforms/test1.cpp @@ -64,6 +64,7 @@ void test1Canonicalization() { conf->setAtomPos(0, RDGeom::Point3D(0.0, 0.0, 0.0)); conf->setAtomPos(1, RDGeom::Point3D(0.0, 1.5, 0.0)); + delete trans; trans = computeCanonicalTransform(*conf); canonicalizeConformer(*conf); @@ -157,6 +158,7 @@ void testGetSetBondLength() { setBondLength(conf, 19, 0, 3.0); dist = getBondLength(conf, 0, 19); TEST_ASSERT(RDKit::feq(dist, 3.0)); + delete m; } void testGetSetAngle() { @@ -177,6 +179,7 @@ void testGetSetAngle() { TEST_ASSERT(RDKit::feq(angle, M_PI / 2.)); angle = getAngleDeg(conf, 0, 19, 21); TEST_ASSERT(RDKit::feq(angle, 90.0)); + delete m; } void testGetSetDihedral() { @@ -200,6 +203,7 @@ void testGetSetDihedral() { TEST_ASSERT(RDKit::feq(dihedral, -2. / 3. * M_PI)); dihedral = getDihedralDeg(conf, 8, 0, 19, 21); TEST_ASSERT(RDKit::feq(dihedral, -120.0)); + delete m; } void testGetSetDihedralThroughTripleBond() { @@ -230,6 +234,7 @@ void testGetSetDihedralThroughTripleBond() { exceptionRaised = true; } TEST_ASSERT(exceptionRaised); + delete m; } #ifndef RDK_HAS_EIGEN3 diff --git a/Code/GraphMol/MonomerInfo.h b/Code/GraphMol/MonomerInfo.h index 4019ddd66..0acec5b4e 100644 --- a/Code/GraphMol/MonomerInfo.h +++ b/Code/GraphMol/MonomerInfo.h @@ -124,8 +124,8 @@ class RDKIT_GRAPHMOL_EXPORT AtomPDBResidueInfo : public AtomMonomerInfo { int d_residueNumber; std::string d_chainId; std::string d_insertionCode; - double d_occupancy; - double d_tempFactor; + double d_occupancy = 1.0; + double d_tempFactor = 0.0; // additional, non-PDB fields: bool df_heteroAtom; // is this from a HETATM record? unsigned int d_secondaryStructure; diff --git a/Code/GraphMol/PeriodicTable.cpp b/Code/GraphMol/PeriodicTable.cpp index 0047b7cdc..ccdfec596 100644 --- a/Code/GraphMol/PeriodicTable.cpp +++ b/Code/GraphMol/PeriodicTable.cpp @@ -21,7 +21,7 @@ typedef boost::tokenizer> tokenizer; namespace RDKit { -class PeriodicTable *PeriodicTable::ds_instance = nullptr; +class std::unique_ptr PeriodicTable::ds_instance = nullptr; PeriodicTable::PeriodicTable() { // it is assumed that the atomic atomData string constains atoms @@ -83,16 +83,16 @@ PeriodicTable::PeriodicTable() { } } -void PeriodicTable::initInstance() { ds_instance = new PeriodicTable(); } +void PeriodicTable::initInstance() { ds_instance = std::unique_ptr(new PeriodicTable()); } PeriodicTable *PeriodicTable::getTable() { #if RDK_BUILD_THREADSAFE_SSS static std::once_flag pt_init_once; std::call_once(pt_init_once, initInstance); #else - if (ds_instance == nullptr) initInstance(); + if (!ds_instance) initInstance(); #endif - return ds_instance; + return ds_instance.get(); } } // end of namespace diff --git a/Code/GraphMol/PeriodicTable.h b/Code/GraphMol/PeriodicTable.h index 23e5ace3d..210c7de55 100644 --- a/Code/GraphMol/PeriodicTable.h +++ b/Code/GraphMol/PeriodicTable.h @@ -313,7 +313,7 @@ class RDKIT_GRAPHMOL_EXPORT PeriodicTable { PeriodicTable &operator=(const PeriodicTable &); static void initInstance(); - static class PeriodicTable *ds_instance; + static class std::unique_ptr ds_instance; std::vector byanum; STR_UINT_MAP byname; diff --git a/Code/GraphMol/RGroupDecomposition/testRGroupDecomp.cpp b/Code/GraphMol/RGroupDecomposition/testRGroupDecomp.cpp index 9b9e82c3d..3cd66bb50 100644 --- a/Code/GraphMol/RGroupDecomposition/testRGroupDecomp.cpp +++ b/Code/GraphMol/RGroupDecomposition/testRGroupDecomp.cpp @@ -333,6 +333,8 @@ void testGithub1550() { RWMol *rg2 = (RWMol *)groups["R2"][0].get(); TEST_ASSERT(rg2->getNumAtoms() == 12); MolOps::Kekulize(*rg2); + + delete core; } void testRemoveHs() { @@ -379,6 +381,7 @@ void testRemoveHs() { RWMol *rg2 = (RWMol *)groups["R2"][0].get(); TEST_ASSERT(rg2->getNumAtoms() == 7); } + delete core; } void testGitHubIssue1705() { @@ -407,10 +410,8 @@ void testGitHubIssue1705() { ss << MolToSmiles(*rgroup) << std::endl; } } - + delete core; TEST_ASSERT(ss.str() == "Rgroup===Core\nOc1ccc([*:2])cc1[*:1]\nOc1ccc([*:2])cc1[*:1]\nOc1ccc([*:2])cc1[*:1]\nOc1ccc([*:2])cc1[*:1]\nOc1ccc([*:2])cc1[*:1]\nRgroup===R1\n[H][*:1]\nF[*:1]\nF[*:1]\nF[*:1]\nCl[*:1]\nRgroup===R2\n[H][*:2]\n[H][*:2]\n[H][*:2]\n[H]N([H])[*:2]\n[H][*:2]\n"); - - } void testMatchOnlyAtRgroupHs() { @@ -426,6 +427,7 @@ void testMatchOnlyAtRgroupHs() { for (int i = 0; i < 2; ++i) { ROMol *mol = SmilesToMol(smilesData[i]); decomp.add(*mol); + delete mol; } decomp.process(); @@ -438,6 +440,8 @@ void testMatchOnlyAtRgroupHs() { } } std::cerr << ss.str() << std::endl; + + delete core; TEST_ASSERT(ss.str() == "Rgroup===Core\nCCO[*:1]\nCCO[*:1]\nRgroup===R1\n[H][*:1]\n[H]C([H])([H])[*:1]\n"); } diff --git a/Code/GraphMol/SLNParse/test.cpp b/Code/GraphMol/SLNParse/test.cpp index c52b6716e..78725e10f 100644 --- a/Code/GraphMol/SLNParse/test.cpp +++ b/Code/GraphMol/SLNParse/test.cpp @@ -335,7 +335,7 @@ void test3() { sln = "CH4[I=13]"; mol = RDKit::SLNToMol(sln); TEST_ASSERT(!mol); - + delete mol; BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -735,6 +735,7 @@ void test6() { TEST_ASSERT(mol); TEST_ASSERT(!RDKit::SubstructMatch(*mol, *patt, mV)); + delete mol; delete patt; BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -787,6 +788,7 @@ void test7() { patt = RDKit::SLNQueryToMol(sln); TEST_ASSERT(patt); + delete mol; smi = "C[CH2+](C)C"; mol = RDKit::SmilesToMol(smi); TEST_ASSERT(mol); @@ -809,6 +811,7 @@ void test7() { patt = RDKit::SLNQueryToMol(sln); TEST_ASSERT(patt); + delete mol; smi = "C[CH2+](C)C"; mol = RDKit::SmilesToMol(smi); TEST_ASSERT(mol); @@ -831,6 +834,7 @@ void test7() { patt = RDKit::SLNQueryToMol(sln); TEST_ASSERT(patt); + delete mol; smi = "C[CH2+](C)C"; mol = RDKit::SmilesToMol(smi); TEST_ASSERT(mol); @@ -853,6 +857,7 @@ void test7() { patt = RDKit::SLNQueryToMol(sln); TEST_ASSERT(patt); + delete mol; smi = "C[CH2+](C)C"; mol = RDKit::SmilesToMol(smi); TEST_ASSERT(mol); @@ -875,6 +880,7 @@ void test7() { patt = RDKit::SLNQueryToMol(sln); TEST_ASSERT(patt); + delete mol; smi = "C[CH2+](C)C"; mol = RDKit::SmilesToMol(smi); TEST_ASSERT(mol); @@ -892,6 +898,7 @@ void test7() { TEST_ASSERT(mol); TEST_ASSERT(RDKit::SubstructMatch(*mol, *patt, mV) == 4); + delete mol; delete patt; BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -1527,6 +1534,7 @@ void test13() { mol = RDKit::SLNToMol(sln); TEST_ASSERT(!mol); + delete mol; sln = "CH2(CH2@1)"; mol = RDKit::SLNToMol(sln); TEST_ASSERT(!mol); @@ -1621,10 +1629,12 @@ void test14() { mol = RDKit::SLNToMol(sln); TEST_ASSERT(!mol); + delete mol; sln = "CH2(CH2[1])CH2(CH2CH2CH2@1)"; mol = RDKit::SLNToMol(sln); TEST_ASSERT(!mol); + delete mol; BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -1908,6 +1918,7 @@ void testIssue277() { while (slns[i] != "EOF") { RDKit::RWMol *mol = RDKit::SLNQueryToMol(slns[i++]); TEST_ASSERT(mol); + delete mol; } } @@ -1927,24 +1938,27 @@ void test17() { TEST_ASSERT(mol); TEST_ASSERT(mol->getNumAtoms() == 1); + delete mol; sln = "CH4\t"; mol = RDKit::SLNToMol(sln); TEST_ASSERT(mol); TEST_ASSERT(mol->getNumAtoms() == 1); - delete mol; + delete mol; sln = "CH4\tfff"; mol = RDKit::SLNToMol(sln); TEST_ASSERT(!mol); - delete mol; + delete mol; sln = "C[charge=+1] \t"; mol = RDKit::SLNQueryToMol(sln); TEST_ASSERT(mol); + delete mol; sln = "C[charge=+1] \tfoo"; mol = RDKit::SLNQueryToMol(sln); TEST_ASSERT(!mol); + delete mol; } int main(int argc, char *argv[]) { diff --git a/Code/GraphMol/ShapeHelpers/ShapeUtils.cpp b/Code/GraphMol/ShapeHelpers/ShapeUtils.cpp index e1ec19a69..329268751 100644 --- a/Code/GraphMol/ShapeHelpers/ShapeUtils.cpp +++ b/Code/GraphMol/ShapeHelpers/ShapeUtils.cpp @@ -137,6 +137,8 @@ double tverskyIndex(const Conformer &conf1, const Conformer &conf2, double alpha EncodeShape(conf1, grd1, trans, vdwScale, stepSize, maxLayers, ignoreHs); EncodeShape(conf2, grd2, trans, vdwScale, stepSize, maxLayers, ignoreHs); + + delete trans; return RDGeom::tverskyIndex(grd1, grd2, alpha, beta); } @@ -180,6 +182,8 @@ double tanimotoDistance(const Conformer &conf1, const Conformer &conf2, EncodeShape(conf1, grd1, trans, vdwScale, stepSize, maxLayers, ignoreHs); EncodeShape(conf2, grd2, trans, vdwScale, stepSize, maxLayers, ignoreHs); + + delete trans; return RDGeom::tanimotoDistance(grd1, grd2); } @@ -226,6 +230,8 @@ double protrudeDistance(const Conformer &conf1, const Conformer &conf2, EncodeShape(conf1, grd1, trans, vdwScale, stepSize, maxLayers, ignoreHs); EncodeShape(conf2, grd2, trans, vdwScale, stepSize, maxLayers, ignoreHs); + delete trans; + double res; if (allowReordering && (grd2.getOccupancyVect()->getTotalVal() < grd1.getOccupancyVect()->getTotalVal())) { diff --git a/Code/GraphMol/ShapeHelpers/testShapeHelpers.cpp b/Code/GraphMol/ShapeHelpers/testShapeHelpers.cpp index 713c68bab..ecf72d82e 100644 --- a/Code/GraphMol/ShapeHelpers/testShapeHelpers.cpp +++ b/Code/GraphMol/ShapeHelpers/testShapeHelpers.cpp @@ -35,6 +35,8 @@ void test1Encode() { MolTransforms::canonicalizeMol(*m); MolShapes::EncodeShape(*m, grd, 0); + delete m; + // RDGeom::writeGridToFile(grd, "junk.grd"); // MolToMolFile(m, "junk.mol", 0); CHECK_INVARIANT(grd.getOccupancyVect()->getTotalVal() == 9250, ""); @@ -100,6 +102,7 @@ void test3Methane() { // dims.x, dims.y, dims.z, 0.5, DiscreteValueVect::TWOBITVALUE, &offSet); MolShapes::EncodeShape(*m, grd, 0); RDGeom::writeGridToFile(grd, "methane.grd"); + delete m; } int main() { diff --git a/Code/GraphMol/SmilesParse/SmilesParse.cpp b/Code/GraphMol/SmilesParse/SmilesParse.cpp index be5be33ad..b251980ed 100644 --- a/Code/GraphMol/SmilesParse/SmilesParse.cpp +++ b/Code/GraphMol/SmilesParse/SmilesParse.cpp @@ -180,7 +180,7 @@ std::string labelRecursivePatterns(const std::string &sma) { std::list state; std::list startRecurse; std::map patterns; - std::string res = ""; + std::string res; state.push_back(BASE); @@ -230,12 +230,12 @@ RWMol *toMol(const std::string &inp, int func(const std::string &, std::vector &), const std::string &origInp) { // empty strings produce empty molecules: - if (inp == "") return new RWMol(); + if (inp.empty()) return new RWMol(); RWMol *res = nullptr; std::vector molVect; try { func(inp, molVect); - if (molVect.size() > 0) { + if (!molVect.empty()) { res = molVect[0]; SmilesParseOps::CloseMolRings(res, false); SmilesParseOps::AdjustAtomChiralityFlags(res); @@ -269,7 +269,7 @@ RWMol *toMol(const std::string &inp, Atom *toAtom(const std::string &inp, int func(const std::string &, Atom *&)) { // empty strings produce empty molecules: - if (inp == "") return nullptr; + if (inp.empty()) return nullptr; Atom *res = nullptr; try { func(inp, res); @@ -287,7 +287,7 @@ Atom *toAtom(const std::string &inp, int func(const std::string &, Atom *&)) { Bond *toBond(const std::string &inp, int func(const std::string &, Bond *&)) { // empty strings produce empty molecules: - if (inp == "") return nullptr; + if (inp.empty()) return nullptr; Bond *res = nullptr; try { func(inp, res); @@ -321,7 +321,7 @@ void preprocessSmiles(const std::string &smiles, } } - if (lsmiles == "") { + if (lsmiles.empty()) { lsmiles = smiles; } @@ -364,14 +364,14 @@ RWMol *SmilesToMol(const std::string &smiles, const SmilesParserParams ¶ms) { yysmiles_debug = params.debugParse; - std::string lsmiles = "", name = "", cxPart = ""; + std::string lsmiles, name, cxPart; preprocessSmiles(smiles, params, lsmiles, name, cxPart); // strip any leading/trailing whitespace: // boost::trim_if(smi,boost::is_any_of(" \t\r\n")); RWMol *res = nullptr; res = toMol(lsmiles, smiles_parse, lsmiles); - if (res && params.allowCXSMILES && cxPart != "") { + if (res && params.allowCXSMILES && !cxPart.empty()) { std::string::const_iterator pos = cxPart.cbegin(); SmilesParseOps::parseCXExtensions(*res, cxPart, pos); if (params.parseName && pos != cxPart.cend()) { @@ -396,9 +396,10 @@ RWMol *SmilesToMol(const std::string &smiles, bool cleanIt = true, force = true, flagPossible = true; MolOps::assignStereochemistry(*res, cleanIt, force, flagPossible); } - if (res && name != "") res->setProp(common_properties::_Name, name); + if (res && !name.empty()) res->setProp(common_properties::_Name, name); return res; }; + Atom *SmartsToAtom(const std::string &smiles) { yysmarts_debug = false; diff --git a/Code/GraphMol/SmilesParse/cxsmiles_test.cpp b/Code/GraphMol/SmilesParse/cxsmiles_test.cpp index 9f557ec92..df32b8c43 100644 --- a/Code/GraphMol/SmilesParse/cxsmiles_test.cpp +++ b/Code/GraphMol/SmilesParse/cxsmiles_test.cpp @@ -99,6 +99,8 @@ void testAtomLabels() { TEST_ASSERT(m->getAtomWithIdx(5)->getProp( common_properties::atomLabel) == "_AP2"); TEST_ASSERT(m->getAtomWithIdx(5)->getAtomMapNum() == 2); + + delete m; } { // query properties std::string smiles = "**C |$Q_e;QH_p;;$|"; diff --git a/Code/GraphMol/SmilesParse/smarts.tab.cpp.cmake b/Code/GraphMol/SmilesParse/smarts.tab.cpp.cmake index 297545934..735d97fa6 100644 --- a/Code/GraphMol/SmilesParse/smarts.tab.cpp.cmake +++ b/Code/GraphMol/SmilesParse/smarts.tab.cpp.cmake @@ -90,17 +90,6 @@ #include "smarts.tab.hpp" extern int yysmarts_lex(YYSTYPE *,void *, int &); - -void -yysmarts_error( const char *input, - std::vector *ms, - RDKit::Atom* &lastAtom, - RDKit::Bond* &lastBond, - void *scanner,int start_token, const char * msg ) -{ - throw RDKit::SmilesParseException(msg); -} - using namespace RDKit; namespace { void yyErrorCleanup(std::vector *molList){ @@ -113,6 +102,17 @@ namespace { } } +void +yysmarts_error( const char *input, + std::vector *ms, + RDKit::Atom* &lastAtom, + RDKit::Bond* &lastBond, + void *scanner,int start_token, const char * msg ) +{ + yyErrorCleanup(ms); + throw RDKit::SmilesParseException(msg); +} + #line 117 "/scratch/RDKit_git/Code/GraphMol/SmilesParse/smarts.tab.cpp" /* yacc.c:339 */ # ifndef YY_NULLPTR diff --git a/Code/GraphMol/SmilesParse/smarts.yy b/Code/GraphMol/SmilesParse/smarts.yy index accec1f18..964e8693a 100644 --- a/Code/GraphMol/SmilesParse/smarts.yy +++ b/Code/GraphMol/SmilesParse/smarts.yy @@ -1,5 +1,6 @@ %{ + // $Id$ // // Copyright (C) 2003-2018 Greg Landrum and Rational Discovery LLC // @@ -20,16 +21,6 @@ extern int yysmarts_lex(YYSTYPE *,void *, int &); -void -yysmarts_error( const char *input, - std::vector *ms, - RDKit::Atom* &lastAtom, - RDKit::Bond* &lastBond, - void *scanner,int start_token, const char * msg ) -{ - throw RDKit::SmilesParseException(msg); -} - using namespace RDKit; namespace { void yyErrorCleanup(std::vector *molList){ @@ -41,6 +32,17 @@ namespace { molList->resize(0); } } +void +yysmarts_error( const char *input, + std::vector *ms, + RDKit::Atom* &lastAtom, + RDKit::Bond* &lastBond, + void *scanner,int start_token, const char * msg ) +{ + yyErrorCleanup(ms); + throw RDKit::SmilesParseException(msg); +} + %} %define api.pure full @@ -93,22 +95,43 @@ namespace { %left AND_TOKEN %right NOT_TOKEN +%destructor { delete $$; } ATOM_TOKEN +%destructor { delete $$; } SIMPLE_ATOM_QUERY_TOKEN COMPLEX_ATOM_QUERY_TOKEN +%destructor { delete $$; } RINGSIZE_ATOM_QUERY_TOKEN RINGBOND_ATOM_QUERY_TOKEN IMPLICIT_H_ATOM_QUERY_TOKEN +%destructor { delete $$; } HYB_TOKEN HETERONEIGHBOR_ATOM_QUERY_TOKEN ALIPHATIC ALIPHATICHETERONEIGHBOR_ATOM_QUERY_TOKEN +%destructor { delete $$; } bond_expr + %start meta_start %% /* --------------------------------------------------------------- */ -meta_start: START_MOL mol { +meta_start: +START_MOL mol { // the molList has already been updated, no need to do anything } -| START_ATOM atomd { +| START_ATOM atomd EOS_TOKEN { lastAtom = $2; + YYACCEPT; +} +| START_ATOM bad_atom_def { + YYABORT; +} +| START_ATOM { + YYABORT; +} +| START_BOND bond_expr EOS_TOKEN { + lastBond = $2; + YYACCEPT; } | START_BOND bond_expr { - lastBond = $2; + delete $2; + YYABORT; +} +| START_BOND { + YYABORT; } | meta_start error EOS_TOKEN{ - yyclearin; yyerrok; yyErrorCleanup(molList); YYABORT; @@ -117,13 +140,22 @@ meta_start: START_MOL mol { YYACCEPT; } | error EOS_TOKEN { - yyclearin; yyerrok; yyErrorCleanup(molList); YYABORT; } ; +bad_atom_def: +ATOM_OPEN_TOKEN bad_atom_def +| ATOM_CLOSE_TOKEN bad_atom_def +| COLON_TOKEN bad_atom_def +| atom_expr { + delete $1; + YYABORT; +} +; + /* --------------------------------------------------------------- */ // FIX: mol MINUS DIGIT mol: atomd { @@ -245,7 +277,6 @@ mol: atomd { molList->resize( sz-1 ); } } - ; /* --------------------------------------------------------------- */ diff --git a/Code/GraphMol/SmilesParse/smatest.cpp b/Code/GraphMol/SmilesParse/smatest.cpp index e79170f96..66b857be8 100644 --- a/Code/GraphMol/SmilesParse/smatest.cpp +++ b/Code/GraphMol/SmilesParse/smatest.cpp @@ -154,6 +154,7 @@ void testFail() { } else { CHECK_INVARIANT(mol, smi); } + delete mol; i++; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; @@ -528,6 +529,8 @@ void testProblems() { _checkMatches("*-[N;H2,H1&-1,-2]", "CC([N-2])C", 1, 2); _checkNoMatches("*-[N;H2,H1&-1,-2]", "CC(=N)C"); _checkNoMatches("*-[N;H2,H1&-1,-2]", "CC(NC)C"); + + delete matcher; BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -759,6 +762,7 @@ void testSmartsWrite() { delete m1; delete m2; } + delete nmol; i++; } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; @@ -785,6 +789,8 @@ void testIssue196() { TEST_ASSERT(mts1); TEST_ASSERT(mV1.size() == 2); + delete mol1; + delete matcher1; BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -968,10 +974,12 @@ void testAtomMap() { sma = "[C:10H3]CC"; matcher1 = SmartsToMol(sma); TEST_ASSERT(!matcher1); + delete matcher1; sma = "[C:10:3]ON"; matcher1 = SmartsToMol(sma); TEST_ASSERT(!matcher1); + delete matcher1; sma = "C-C"; matcher1 = SmartsToMol(sma); @@ -994,6 +1002,7 @@ void testAtomMap() { sma = MolToSmarts(*matcher1); TEST_ASSERT(sma == "[C&$(C=O):2]-[O:3]"); + delete matcher1; BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } diff --git a/Code/GraphMol/SmilesParse/smiles.tab.cpp.cmake b/Code/GraphMol/SmilesParse/smiles.tab.cpp.cmake index 0c37191f8..374cf6b52 100644 --- a/Code/GraphMol/SmilesParse/smiles.tab.cpp.cmake +++ b/Code/GraphMol/SmilesParse/smiles.tab.cpp.cmake @@ -1452,8 +1452,8 @@ yyreduce: (*molList)[ sz ] = new RWMol(); RDKit::RWMol *curMol = (*molList)[ sz ]; (yyvsp[0].atom)->setProp(RDKit::common_properties::_SmilesStart,1); - curMol->addAtom((yyvsp[0].atom)); - delete (yyvsp[0].atom); + curMol->addAtom((yyvsp[0].atom),true,true); + //delete (yyvsp[0].atom); (yyval.moli) = sz; } #line 1460 "/scratch/RDKit_git/Code/GraphMol/SmilesParse/smiles.tab.cpp" /* yacc.c:1646 */ diff --git a/Code/GraphMol/SmilesParse/smiles.yy b/Code/GraphMol/SmilesParse/smiles.yy index a53c32dda..9e1658a7e 100644 --- a/Code/GraphMol/SmilesParse/smiles.yy +++ b/Code/GraphMol/SmilesParse/smiles.yy @@ -22,7 +22,6 @@ extern int yysmiles_lex(YYSTYPE *,void *,int &); - using namespace RDKit; namespace { void yyErrorCleanup(std::vector *molList){ @@ -96,21 +95,37 @@ yysmiles_error( const char *input, %token ATOM_OPEN_TOKEN ATOM_CLOSE_TOKEN %token EOS_TOKEN +%destructor { delete $$; } AROMATIC_ATOM_TOKEN ATOM_TOKEN ORGANIC_ATOM_TOKEN +%destructor { delete $$; } + %start meta_start %% -meta_start: START_MOL mol { +/* --------------------------------------------------------------- */ +meta_start: +START_MOL mol { // the molList has already been updated, no need to do anything } -| START_ATOM atomd { +| START_ATOM atomd EOS_TOKEN { lastAtom = $2; + YYACCEPT; +} +| START_ATOM bad_atom_def { + YYABORT; +} +| START_BOND bondd EOS_TOKEN { + lastBond = $2; + YYACCEPT; } | START_BOND bondd { - lastBond = $2; + delete $2; + YYABORT; +} +| START_BOND { + YYABORT; } | meta_start error EOS_TOKEN{ - yyclearin; yyerrok; yyErrorCleanup(molList); YYABORT; @@ -119,13 +134,21 @@ meta_start: START_MOL mol { YYACCEPT; } | error EOS_TOKEN { - yyclearin; yyerrok; yyErrorCleanup(molList); YYABORT; } ; +bad_atom_def: +ATOM_OPEN_TOKEN bad_atom_def +| ATOM_CLOSE_TOKEN bad_atom_def +| COLON_TOKEN bad_atom_def +| charge_element { + delete $1; + YYABORT; +} +; /* --------------------------------------------------------------- */ // FIX: mol MINUS DIGIT @@ -135,8 +158,8 @@ mol: atomd { (*molList)[ sz ] = new RWMol(); RDKit::RWMol *curMol = (*molList)[ sz ]; $1->setProp(RDKit::common_properties::_SmilesStart,1); - curMol->addAtom($1); - delete $1; + curMol->addAtom($1, true, true); + //delete $1; $$ = sz; } @@ -290,8 +313,6 @@ bondd: BOND_TOKEN } ; - - /* --------------------------------------------------------------- */ atomd: simple_atom | ATOM_OPEN_TOKEN charge_element COLON_TOKEN number ATOM_CLOSE_TOKEN @@ -300,7 +321,6 @@ atomd: simple_atom $$->setNoImplicit(true); $$->setProp(RDKit::common_properties::molAtomMapNumber,$4); } - | ATOM_OPEN_TOKEN charge_element ATOM_CLOSE_TOKEN { $$ = $2; @@ -316,7 +336,7 @@ charge_element: h_element | h_element MINUS_TOKEN { $1->setFormalCharge(-1); } | h_element MINUS_TOKEN MINUS_TOKEN { $1->setFormalCharge(-2); } | h_element MINUS_TOKEN number { $1->setFormalCharge(-$3); } - ; +; /* --------------------------------------------------------------- */ h_element: H_TOKEN { $$ = new Atom(1); } @@ -346,7 +366,7 @@ element: simple_atom ; /* --------------------------------------------------------------- */ -simple_atom: ORGANIC_ATOM_TOKEN +simple_atom: ORGANIC_ATOM_TOKEN | AROMATIC_ATOM_TOKEN ; diff --git a/Code/GraphMol/StructChecker/Pattern.cpp b/Code/GraphMol/StructChecker/Pattern.cpp index 0d4b41e95..969bd8ce7 100644 --- a/Code/GraphMol/StructChecker/Pattern.cpp +++ b/Code/GraphMol/StructChecker/Pattern.cpp @@ -86,11 +86,11 @@ bool LigandMatches(const Atom &a, const Bond &b, const Ligand &l, } static void applyAtomSymbolList(RWMol &mol, const std::string symbol, - Atom &atom) { + Atom *&atom) { // replace mol atom with Ligrad.AtomSymbol // single atom symbol: if (std::string::npos == symbol.find(',')) { - atom.setAtomicNum(getAtomicNumber(symbol)); + atom->setAtomicNum(getAtomicNumber(symbol)); return; } // comma separated list of atom symbols: @@ -103,8 +103,8 @@ static void applyAtomSymbolList(RWMol &mol, const std::string symbol, char *tokp; strcpy(buf, atsym); tokp = strtok_r(buf, ",", &context); - atom.setAtomicNum(getAtomicNumber(tokp)); - QueryAtom a(atom); + atom->setAtomicNum(getAtomicNumber(tokp)); + QueryAtom a(*atom); a.setQuery(makeAtomNumQuery(getAtomicNumber(tokp))); // QueryAtom a(atom); // copy all mol's atom properties to keep its for (tokp = strtok_r((char *)nullptr, ",", &context); tokp; @@ -112,7 +112,9 @@ static void applyAtomSymbolList(RWMol &mol, const std::string symbol, a.expandQuery(makeAtomNumQuery(getAtomicNumber(tokp)), Queries::COMPOSITE_OR); } - mol.replaceAtom(atom.getIdx(), &a); + unsigned int idx = atom->getIdx(); + mol.replaceAtom(idx, &a); + atom = mol.getAtomWithIdx(idx); } struct AtomNeighbor { @@ -226,7 +228,7 @@ bool TransformAugmentedAtoms( // change central atom Atom *a = mol.getAtomWithIdx(j); if (aa1.AtomSymbol != aa2.AtomSymbol) - applyAtomSymbolList(mol, aa2.AtomSymbol, *a); + applyAtomSymbolList(mol, aa2.AtomSymbol, a); if (a->getFormalCharge() != aa2.Charge) a->setFormalCharge(aa2.Charge); if (a->getNumRadicalElectrons() != aa2.Radical) a->setNumRadicalElectrons(aa2.Radical); @@ -237,7 +239,7 @@ bool TransformAugmentedAtoms( { // AVALON pattern.c:154 if (aa1.Ligands[l].AtomSymbol != ligand.AtomSymbol) - applyAtomSymbolList(mol, ligand.AtomSymbol, *al); + applyAtomSymbolList(mol, ligand.AtomSymbol, al); // } } if (al->getFormalCharge() != ligand.Charge) diff --git a/Code/GraphMol/StructChecker/testStructChecker.cpp b/Code/GraphMol/StructChecker/testStructChecker.cpp index 9f5b407ca..9ad31bd49 100644 --- a/Code/GraphMol/StructChecker/testStructChecker.cpp +++ b/Code/GraphMol/StructChecker/testStructChecker.cpp @@ -171,10 +171,10 @@ void test1() { RWMol* mol = SmilesToMol(smol); TEST_ASSERT(mol); unsigned flags = chk.checkMolStructure(*mol); - delete mol; BOOST_LOG(rdInfoLog) << StructChecker::StructureFlagsToString(flags) << "\n"; BOOST_LOG(rdInfoLog) << MolToSmarts(*mol) << "\n"; + delete mol; TEST_ASSERT(true); } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; @@ -198,10 +198,10 @@ void test2() { RWMol* mol = SmilesToMol(smol); TEST_ASSERT(mol); unsigned flags = chk.checkMolStructure(*mol); - delete mol; BOOST_LOG(rdInfoLog) << StructChecker::StructureFlagsToString(flags) << "\n"; BOOST_LOG(rdInfoLog) << MolToSmarts(*mol) << "\n"; + delete mol; TEST_ASSERT(true); } BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; @@ -470,7 +470,10 @@ void testCheckAtomFiles() { "Substance_310925001_310950000-021442.sdf", }; unsigned ref[] = { - (StructChecker::ATOM_CHECK_FAILED | StructChecker::TRANSFORMED), 0, 0, 0, + (StructChecker::ATOM_CHECK_FAILED | StructChecker::TRANSFORMED), + 0, + 0, + 0, }; StructCheckerOptions options; doLoadOptionsFromFiles(options); diff --git a/Code/GraphMol/Subgraphs/test1.cpp b/Code/GraphMol/Subgraphs/test1.cpp index b2b5672b7..2c8feb80a 100644 --- a/Code/GraphMol/Subgraphs/test1.cpp +++ b/Code/GraphMol/Subgraphs/test1.cpp @@ -21,12 +21,14 @@ void testSubgraphs() { std::cout << "-----------------------\n Subgraph retrieval" << std::endl; // build: CCC(C)CC RWMol mol; - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); + bool updateLabel = true; + bool takeOwnership = true; + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); mol.addBond(0, 1, Bond::SINGLE); mol.addBond(1, 2, Bond::SINGLE); mol.addBond(2, 3, Bond::SINGLE); @@ -35,7 +37,6 @@ void testSubgraphs() { PATH_LIST tmp; PATH_LIST::iterator i; - PATH_TYPE::iterator j; int totPs = 0; tmp = findAllSubgraphsOfLengthN(mol, 1); @@ -54,7 +55,7 @@ void testSubgraphs() { CHECK_INVARIANT(tmp.size() == 1, ""); totPs += tmp.size(); tmp = findAllSubgraphsOfLengthN(mol, 6); - CHECK_INVARIANT(tmp.size() == 0, ""); + CHECK_INVARIANT(tmp.empty(), ""); totPs += tmp.size(); // now use the direct range function and check that we get the @@ -69,7 +70,7 @@ void testSubgraphs() { CHECK_INVARIANT(totPs == newTot, ""); // add an H and make sure things don't change: - mol.addAtom(new Atom(1)); + mol.addAtom(new Atom(1), updateLabel, takeOwnership); mol.addBond(5, 6, Bond::SINGLE); tmp = findAllSubgraphsOfLengthN(mol, 1); @@ -84,7 +85,7 @@ void testSubgraphs() { tmp = findAllSubgraphsOfLengthN(mol, 5); CHECK_INVARIANT(tmp.size() == 1, ""); tmp = findAllSubgraphsOfLengthN(mol, 6); - CHECK_INVARIANT(tmp.size() == 0, ""); + CHECK_INVARIANT(tmp.empty(), ""); std::cout << "Finished" << std::endl; } @@ -128,9 +129,9 @@ void testSubgraphs2() { nUnique += tmp.size(); } + delete mol; CHECK_INVARIANT(nAll == 2433, ""); CHECK_INVARIANT(nUnique == 300, ""); - delete mol; mol = SmilesToMol("CCC(O)C(c1ccccc1)CC(C)N(C)C"); CHECK_INVARIANT(mol, ""); @@ -144,8 +145,9 @@ void testSubgraphs2() { tmp = findUniqueSubgraphsOfLengthN(*mol, i); nUnique += tmp.size(); } - CHECK_INVARIANT(nAll == 1990, ""); + delete mol; + CHECK_INVARIANT(nAll == 1990, ""); CHECK_INVARIANT(nUnique == 907, ""); std::cout << "Finished" << std::endl; @@ -166,12 +168,14 @@ void testPaths() { std::cout << "-----------------------\n Path retrieval" << std::endl; // build: CCC(C)CC RWMol mol; - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); + bool updateLabel = true; + bool takeOwnership = true; + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); mol.addBond(0, 1, Bond::SINGLE); mol.addBond(1, 2, Bond::SINGLE); mol.addBond(2, 3, Bond::SINGLE); @@ -192,9 +196,9 @@ void testPaths() { tmp = findAllPathsOfLengthN(mol, 4); CHECK_INVARIANT(tmp.size() == 1, ""); tmp = findAllPathsOfLengthN(mol, 5); - CHECK_INVARIANT(tmp.size() == 0, ""); + CHECK_INVARIANT(tmp.empty(), ""); tmp = findAllPathsOfLengthN(mol, 6); - CHECK_INVARIANT(tmp.size() == 0, ""); + CHECK_INVARIANT(tmp.empty(), ""); // // Retrieve using atoms, which gives the results shifted by @@ -211,7 +215,7 @@ void testPaths() { tmp = findAllPathsOfLengthN(mol, 5, false); CHECK_INVARIANT(tmp.size() == 1, ""); tmp = findAllPathsOfLengthN(mol, 6, false); - CHECK_INVARIANT(tmp.size() == 0, ""); + CHECK_INVARIANT(tmp.empty(), ""); // // try m->n @@ -222,8 +226,8 @@ void testPaths() { CHECK_INVARIANT(pths[2].size() == 5, ""); CHECK_INVARIANT(pths[3].size() == 4, ""); CHECK_INVARIANT(pths[4].size() == 1, ""); - CHECK_INVARIANT(pths[5].size() == 0, ""); - CHECK_INVARIANT(pths[6].size() == 0, ""); + CHECK_INVARIANT(pths[5].empty(), ""); + CHECK_INVARIANT(pths[6].empty(), ""); pths = findAllPathsOfLengthsMtoN(mol, 1, 6, false); CHECK_INVARIANT(pths[1].size() == 6, ""); @@ -231,13 +235,13 @@ void testPaths() { CHECK_INVARIANT(pths[3].size() == 5, ""); CHECK_INVARIANT(pths[4].size() == 4, ""); CHECK_INVARIANT(pths[5].size() == 1, ""); - CHECK_INVARIANT(pths[6].size() == 0, ""); + CHECK_INVARIANT(pths[6].empty(), ""); // // add an atom, close the ring and re-check a couple indices: // (leaves us with CC1CCCCC1) // - mol.addAtom(new Atom(6)); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); mol.addBond(5, 6, Bond::SINGLE); mol.addBond(0, 6, Bond::SINGLE); tmp = findAllPathsOfLengthN(mol, 4); @@ -252,10 +256,12 @@ void testPaths2() { std::cout << "-----------------------\n Path retrieval2" << std::endl; // build: CCC(C)CC RWMol mol; - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); + bool updateLabel = true; + bool takeOwnership = true; + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); mol.addBond(0, 1, Bond::SINGLE); mol.addBond(1, 2, Bond::SINGLE); mol.addBond(2, 3, Bond::SINGLE); @@ -277,12 +283,14 @@ void testUniqueSubgraphs() { << std::endl; // build: CCC(C)CC RWMol mol; - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); - mol.addAtom(new Atom(6)); + bool updateLabel = true; + bool takeOwnership = true; + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); + mol.addAtom(new Atom(6), updateLabel, takeOwnership); mol.addBond(0, 1, Bond::SINGLE); mol.addBond(1, 2, Bond::SINGLE); mol.addBond(2, 3, Bond::SINGLE); @@ -291,7 +299,6 @@ void testUniqueSubgraphs() { PATH_LIST tmp; PATH_LIST::iterator i; - PATH_TYPE::iterator j; tmp = findAllSubgraphsOfLengthN(mol, 1); CHECK_INVARIANT(tmp.size() == 5, ""); @@ -317,12 +324,12 @@ void testUniqueSubgraphs() { CHECK_INVARIANT(tmp.size() == 1, ""); tmp = findAllSubgraphsOfLengthN(mol, 6); - CHECK_INVARIANT(tmp.size() == 0, ""); + CHECK_INVARIANT(tmp.empty(), ""); tmp = findUniqueSubgraphsOfLengthN(mol, 6); - CHECK_INVARIANT(tmp.size() == 0, ""); + CHECK_INVARIANT(tmp.empty(), ""); // add an H and make sure things don't change: - mol.addAtom(new Atom(1)); + mol.addAtom(new Atom(1), updateLabel, takeOwnership); mol.addBond(5, 6, Bond::SINGLE); tmp = findAllSubgraphsOfLengthN(mol, 2); @@ -346,9 +353,9 @@ void testUniqueSubgraphs() { CHECK_INVARIANT(tmp.size() == 1, ""); tmp = findAllSubgraphsOfLengthN(mol, 6); - CHECK_INVARIANT(tmp.size() == 0, ""); + CHECK_INVARIANT(tmp.empty(), ""); tmp = findUniqueSubgraphsOfLengthN(mol, 6); - CHECK_INVARIANT(tmp.size() == 0, ""); + CHECK_INVARIANT(tmp.empty(), ""); std::cout << "Finished" << std::endl; } @@ -429,7 +436,7 @@ void testRootedSubgraphs() { // edge case: tmp = findAllSubgraphsOfLengthN(*mol, 1, false, 10); - TEST_ASSERT(tmp.size() == 0); + TEST_ASSERT(tmp.empty()); delete mol; } @@ -458,7 +465,7 @@ void testRootedSubgraphs() { // edge case: tmp = findAllSubgraphsOfLengthN(*mol, 1, false, 10); - TEST_ASSERT(tmp.size() == 0); + TEST_ASSERT(tmp.empty()); delete mol; } @@ -471,7 +478,7 @@ void testRootedSubgraphs() { tmpm = findAllSubgraphsOfLengthsMtoN(*mol, 1, 2, false, 0); TEST_ASSERT(tmpm[1].size() == 1); TEST_ASSERT(tmpm[2].size() == 2); - TEST_ASSERT(tmpm[3].size() == 0); + TEST_ASSERT(tmpm[3].empty()); tmpm = findAllSubgraphsOfLengthsMtoN(*mol, 1, 3, false, 0); TEST_ASSERT(tmpm[1].size() == 1); TEST_ASSERT(tmpm[2].size() == 2); @@ -486,7 +493,7 @@ void testRootedSubgraphs() { tmpm = findAllSubgraphsOfLengthsMtoN(*mol, 1, 2, false, 3); TEST_ASSERT(tmpm[1].size() == 1); TEST_ASSERT(tmpm[2].size() == 2); - TEST_ASSERT(tmpm[3].size() == 0); + TEST_ASSERT(tmpm[3].empty()); tmpm = findAllSubgraphsOfLengthsMtoN(*mol, 1, 3, false, 3); TEST_ASSERT(tmpm[1].size() == 1); TEST_ASSERT(tmpm[2].size() == 2); @@ -515,7 +522,7 @@ void testRootedPaths() { // edge case: tmp = findAllPathsOfLengthN(*mol, 1, true, false, 10); - TEST_ASSERT(tmp.size() == 0); + TEST_ASSERT(tmp.empty()); // atom paths: tmp = findAllPathsOfLengthN(*mol, 1, false, false, 0); @@ -546,7 +553,7 @@ void testRootedPaths() { // edge case: tmp = findAllPathsOfLengthN(*mol, 1, true, false, 10); - TEST_ASSERT(tmp.size() == 0); + TEST_ASSERT(tmp.empty()); // atom paths: tmp = findAllPathsOfLengthN(*mol, 1, false, false, 3); @@ -569,7 +576,7 @@ void testRootedPaths() { tmpm = findAllPathsOfLengthsMtoN(*mol, 1, 2, false, false, 0); TEST_ASSERT(tmpm[1].size() == 1); TEST_ASSERT(tmpm[2].size() == 1); - TEST_ASSERT(tmpm[3].size() == 0); + TEST_ASSERT(tmpm[3].empty()); tmpm = findAllPathsOfLengthsMtoN(*mol, 1, 3, false, false, 0); TEST_ASSERT(tmpm[1].size() == 1); TEST_ASSERT(tmpm[2].size() == 1); @@ -584,7 +591,7 @@ void testRootedPaths() { tmpm = findAllPathsOfLengthsMtoN(*mol, 1, 2, false, false, 3); TEST_ASSERT(tmpm[1].size() == 1); TEST_ASSERT(tmpm[2].size() == 1); - TEST_ASSERT(tmpm[3].size() == 0); + TEST_ASSERT(tmpm[3].empty()); tmpm = findAllPathsOfLengthsMtoN(*mol, 1, 3, false, false, 3); TEST_ASSERT(tmpm[1].size() == 1); TEST_ASSERT(tmpm[2].size() == 1); diff --git a/Code/GraphMol/Substruct/test1.cpp b/Code/GraphMol/Substruct/test1.cpp index 79c476b36..44cd9ec3b 100644 --- a/Code/GraphMol/Substruct/test1.cpp +++ b/Code/GraphMol/Substruct/test1.cpp @@ -34,16 +34,18 @@ void test1() { unsigned int n; RWMol *m, *q1; + bool updateLabel = true; + bool takeOwnership = true; m = new RWMol(); - m->addAtom(new Atom(8)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(8), updateLabel, takeOwnership); + m->addAtom(new Atom(6), updateLabel, takeOwnership); + m->addAtom(new Atom(6), updateLabel, takeOwnership); m->addBond(0, 1, Bond::SINGLE); m->addBond(1, 2, Bond::SINGLE); q1 = new RWMol(); - q1->addAtom(new QueryAtom(6)); - q1->addAtom(new QueryAtom(6)); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); q1->addBond(0, 1, Bond::SINGLE); n = SubstructMatch(*m, *q1, matches, false); CHECK_INVARIANT(n == 2, ""); @@ -78,9 +80,9 @@ void test1() { // make sure we reset the match vectors. // build a query we won't match: - q1->addAtom(new QueryAtom(6)); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); q1->addBond(1, 2, Bond::SINGLE); - q1->addAtom(new QueryAtom(6)); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); q1->addBond(2, 3, Bond::SINGLE); TEST_ASSERT(!SubstructMatch(*m, *q1, matchV)); @@ -90,6 +92,8 @@ void test1() { TEST_ASSERT(n == 0); TEST_ASSERT(matches.size() == 0); + delete m; + delete q1; std::cout << "Done\n" << std::endl; } @@ -101,15 +105,17 @@ void test2() { RWMol *m, *q1; m = new RWMol(); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(8)); + bool updateLabel = true; + bool takeOwnership = true; + m->addAtom(new Atom(6), updateLabel, takeOwnership); + m->addAtom(new Atom(6), updateLabel, takeOwnership); + m->addAtom(new Atom(8), updateLabel, takeOwnership); m->addBond(0, 1, Bond::SINGLE); m->addBond(1, 2, Bond::SINGLE); q1 = new RWMol(); - q1->addAtom(new QueryAtom(6)); - q1->addAtom(new QueryAtom(8)); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(8), updateLabel, takeOwnership); q1->addBond(0, 1, Bond::SINGLE); n = SubstructMatch(*m, *q1, matchV); @@ -134,9 +140,9 @@ void test2() { delete m; m = new RWMol(); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(8)); + m->addAtom(new Atom(6), updateLabel, takeOwnership); + m->addAtom(new Atom(6), updateLabel, takeOwnership); + m->addAtom(new Atom(8), updateLabel, takeOwnership); m->addBond(0, 1, Bond::SINGLE); m->addBond(1, 2, Bond::DOUBLE); @@ -148,6 +154,8 @@ void test2() { CHECK_INVARIANT(n == 0, ""); CHECK_INVARIANT(matches.size() == n, ""); CHECK_INVARIANT(!SubstructMatch(*m, *q1, matchV), ""); + delete m; + delete q1; std::cout << "Done\n" << std::endl; } @@ -160,15 +168,17 @@ void test3() { RWMol *m, *q1; m = new RWMol(); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(8)); + bool updateLabel = true; + bool takeOwnership = true; + m->addAtom(new Atom(6), updateLabel, takeOwnership); + m->addAtom(new Atom(6), updateLabel, takeOwnership); + m->addAtom(new Atom(8), updateLabel, takeOwnership); m->addBond(0, 1, Bond::SINGLE); m->addBond(1, 2, Bond::SINGLE); q1 = new RWMol(); - q1->addAtom(new QueryAtom(6)); - q1->addAtom(new QueryAtom(8)); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(8), updateLabel, takeOwnership); q1->addBond(0, 1, Bond::UNSPECIFIED); n = SubstructMatch(*m, *q1, matches, false); CHECK_INVARIANT(n == 1, ""); @@ -184,9 +194,9 @@ void test3() { delete m; m = new RWMol(); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(8)); + m->addAtom(new Atom(6), updateLabel, takeOwnership); + m->addAtom(new Atom(6), updateLabel, takeOwnership); + m->addAtom(new Atom(8), updateLabel, takeOwnership); m->addBond(0, 1, Bond::SINGLE); m->addBond(1, 2, Bond::DOUBLE); @@ -205,8 +215,8 @@ void test3() { delete q1; q1 = new RWMol(); - q1->addAtom(new QueryAtom(6)); - q1->addAtom(new QueryAtom(6)); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); q1->addBond(0, 1, Bond::UNSPECIFIED); n = SubstructMatch(*m, *q1, matches, false); TEST_ASSERT(n == 2); @@ -219,6 +229,8 @@ void test3() { TEST_ASSERT(n == 1); TEST_ASSERT(matches.size() == n); + delete m; + delete q1; std::cout << "Done\n" << std::endl; } @@ -227,6 +239,8 @@ void test4() { MatchVectType matchV; std::vector matches; int n; + bool updateLabel = true; + bool takeOwnership = true; RWMol *m, *q1, *q2; auto *a6 = new Atom(6); @@ -244,8 +258,8 @@ void test4() { // this will be the recursive query q1 = new RWMol(); - q1->addAtom(new QueryAtom(6), true); - q1->addAtom(new QueryAtom(8), true); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(8), updateLabel, takeOwnership); q1->addBond(0, 1, Bond::UNSPECIFIED); // here's the main query @@ -273,6 +287,10 @@ void test4() { TEST_ASSERT(matches[1].size() == 2); TEST_ASSERT(matches[0][0].second == matches[1][0].second); TEST_ASSERT(matches[0][1].second != matches[1][1].second); + delete m; + delete a6; + delete a8; + delete q2; std::cout << "Done\n" << std::endl; } @@ -282,6 +300,8 @@ void test5() { MatchVectType matchV; std::vector matches; int n; + bool updateLabel = true; + bool takeOwnership = true; RWMol *m, *q1, *q2; auto *a6 = new Atom(6); @@ -300,8 +320,8 @@ void test5() { // this will be the recursive query q1 = new RWMol(); - q1->addAtom(new QueryAtom(6), true); - q1->addAtom(new QueryAtom(8), true); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(8), updateLabel, takeOwnership); q1->addBond(0, 1, Bond::UNSPECIFIED); // here's the main query @@ -319,6 +339,10 @@ void test5() { n = SubstructMatch(*m, *q2, matches, true); CHECK_INVARIANT(n == 2, ""); CHECK_INVARIANT(matches[0].size() == 2, ""); + delete m; + delete a6; + delete a8; + delete q2; std::cout << "Done\n" << std::endl; } @@ -327,6 +351,8 @@ void test5QueryRoot() { MatchVectType matchV; std::vector matches; int n; + bool updateLabel = true; + bool takeOwnership = true; RWMol *m, *q1, *q2; auto *a6 = new Atom(6); @@ -345,8 +371,8 @@ void test5QueryRoot() { // this will be the recursive query q1 = new RWMol(); - q1->addAtom(new QueryAtom(8), true); - q1->addAtom(new QueryAtom(6), true); + q1->addAtom(new QueryAtom(8), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); q1->addBond(0, 1, Bond::UNSPECIFIED); q1->setProp(common_properties::_queryRootAtom, 1); @@ -365,6 +391,10 @@ void test5QueryRoot() { n = SubstructMatch(*m, *q2, matches, true); CHECK_INVARIANT(n == 2, ""); CHECK_INVARIANT(matches[0].size() == 2, ""); + delete m; + delete a6; + delete a8; + delete q2; std::cout << "Done\n" << std::endl; } @@ -374,6 +404,8 @@ void test6() { MatchVectType matchV; std::vector matches; int n; + bool updateLabel = true; + bool takeOwnership = true; RWMol *m, *q1; auto *a6 = new Atom(6); @@ -387,9 +419,9 @@ void test6() { m->addBond(0, 2, Bond::SINGLE); q1 = new RWMol(); - q1->addAtom(new QueryAtom(6), true); - q1->addAtom(new QueryAtom(6), true); - q1->addAtom(new QueryAtom(6), true); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); q1->addBond(0, 1, Bond::UNSPECIFIED); q1->addBond(1, 2, Bond::UNSPECIFIED); @@ -408,6 +440,9 @@ void test6() { n = SubstructMatch(*m, *q1, matches, true); CHECK_INVARIANT(n == 1, ""); CHECK_INVARIANT(matches[0].size() == 3, ""); + delete m; + delete a6; + delete q1; std::cout << "Done\n" << std::endl; } @@ -419,6 +454,8 @@ void test7() { RWMol *m, *q1; auto *a6 = new Atom(6); + bool updateLabel = true; + bool takeOwnership = true; m = new RWMol(); m->addAtom(a6); @@ -429,9 +466,9 @@ void test7() { m->addBond(0, 2, Bond::SINGLE); q1 = new RWMol(); - q1->addAtom(new QueryAtom(6), true); - q1->addAtom(new QueryAtom(6), true); - q1->addAtom(new QueryAtom(6), true); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); q1->addBond(0, 1, Bond::UNSPECIFIED); q1->addBond(1, 2, Bond::UNSPECIFIED); @@ -445,6 +482,10 @@ void test7() { CHECK_INVARIANT(matches[0].size() == 3, ""); if (!(i % 500)) std::cout << i << std::endl; } + delete m; + delete a6; + delete q1; + std::cout << "Done\n" << std::endl; } @@ -466,9 +507,9 @@ void test8() { m->addBond(0, 2, Bond::SINGLE); q1 = new RWMol(); - q1->addAtom(new QueryAtom(6), true); - q1->addAtom(new QueryAtom(6), true); - q1->addAtom(new QueryAtom(6), true); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); q1->addBond(0, 1, Bond::UNSPECIFIED); q1->addBond(1, 2, Bond::UNSPECIFIED); @@ -482,6 +523,10 @@ void test8() { CHECK_INVARIANT(matches[0].size() == 3, ""); if (!(i % 500)) std::cout << i << std::endl; } + delete m; + delete a6; + delete q1; + std::cout << "Done\n" << std::endl; } #endif @@ -496,11 +541,13 @@ void test9() { auto *a6 = new Atom(6); m = new RWMol(); + bool updateLabel = true; + bool takeOwnership = true; m->addAtom(a6); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(7)); - m->addAtom(new Atom(8)); - m->addAtom(new Atom(9)); + m->addAtom(new Atom(6), updateLabel, takeOwnership); + m->addAtom(new Atom(7), updateLabel, takeOwnership); + m->addAtom(new Atom(8), updateLabel, takeOwnership); + m->addAtom(new Atom(9), updateLabel, takeOwnership); m->addBond(0, 1, Bond::SINGLE); m->addBond(0, 2, Bond::SINGLE); m->addBond(0, 3, Bond::SINGLE); @@ -546,6 +593,9 @@ void test9() { TEST_ASSERT(found); n = SubstructMatch(*q1, *q1, matches, true, true, true); TEST_ASSERT(n == 1); + delete m; + delete a6; + delete q1; std::cout << "Done\n" << std::endl; } @@ -556,6 +606,8 @@ void testRecursiveSerialNumbers() { MatchVectType matchV; std::vector matches; int n; + bool updateLabel = true; + bool takeOwnership = true; RWMol *m, *q1, *q2; auto *a6 = new Atom(6); @@ -574,8 +626,8 @@ void testRecursiveSerialNumbers() { { // this will be the recursive query q1 = new RWMol(); - q1->addAtom(new QueryAtom(6), true); - q1->addAtom(new QueryAtom(8), true); + q1->addAtom(new QueryAtom(6), updateLabel, takeOwnership); + q1->addAtom(new QueryAtom(8), updateLabel, takeOwnership); q1->addBond(0, 1, Bond::UNSPECIFIED); // here's the main query @@ -602,11 +654,12 @@ void testRecursiveSerialNumbers() { TEST_ASSERT(n == 1); TEST_ASSERT(matches.size() == 1); TEST_ASSERT(matches[0].size() == 3); - delete q1; delete q2; } delete m; + delete a6; + delete a8; std::cout << "Done\n" << std::endl; } @@ -736,6 +789,8 @@ void testChiralMatch() { ROMol *mol = SmilesToMol(mSmi); MatchVectType matchV; bool matched = SubstructMatch(*mol, *query, matchV, true, true); + delete mol; + delete query; TEST_ASSERT(matched); } { @@ -745,6 +800,8 @@ void testChiralMatch() { ROMol *mol = SmilesToMol(mSmi); MatchVectType matchV; bool matched = SubstructMatch(*mol, *query, matchV, true, true); + delete mol; + delete query; TEST_ASSERT(!matched); } { @@ -754,6 +811,8 @@ void testChiralMatch() { ROMol *mol = SmilesToMol(mSmi); MatchVectType matchV; bool matched = SubstructMatch(*mol, *query, matchV, true, true); + delete mol; + delete query; TEST_ASSERT(matched); } { @@ -763,6 +822,8 @@ void testChiralMatch() { ROMol *mol = SmilesToMol(mSmi); MatchVectType matchV; bool matched = SubstructMatch(*mol, *query, matchV, true, true); + delete mol; + delete query; TEST_ASSERT(!matched); } { @@ -772,6 +833,8 @@ void testChiralMatch() { ROMol *mol = SmilesToMol(mSmi); MatchVectType matchV; bool matched = SubstructMatch(*mol, *query, matchV, true, true); + delete mol; + delete query; TEST_ASSERT(!matched); } { @@ -781,6 +844,8 @@ void testChiralMatch() { ROMol *mol = SmilesToMol(mSmi); MatchVectType matchV; bool matched = SubstructMatch(*mol, *query, matchV, true, true); + delete mol; + delete query; TEST_ASSERT(matched); } @@ -791,6 +856,8 @@ void testChiralMatch() { ROMol *mol = SmilesToMol(mSmi); MatchVectType matchV; bool matched = SubstructMatch(*mol, *query, matchV, true, true); + delete mol; + delete query; TEST_ASSERT(matched); } @@ -801,6 +868,8 @@ void testChiralMatch() { ROMol *mol = SmilesToMol(mSmi); MatchVectType matchV; bool matched = SubstructMatch(*mol, *query, matchV, true, true); + delete mol; + delete query; TEST_ASSERT(!matched); } @@ -811,6 +880,8 @@ void testChiralMatch() { ROMol *mol = SmilesToMol(mSmi); std::vector matches; int count = SubstructMatch(*mol, *query, matches, true, true, true); + delete mol; + delete query; TEST_ASSERT(count == 2); } @@ -821,6 +892,8 @@ void testChiralMatch() { ROMol *mol = SmilesToMol(mSmi); std::vector matches; int count = SubstructMatch(*mol, *query, matches, true, true, true); + delete mol; + delete query; TEST_ASSERT(count == 3); } { @@ -830,6 +903,8 @@ void testChiralMatch() { ROMol *mol = SmilesToMol(mSmi); std::vector matches; int count = SubstructMatch(*mol, *query, matches, true, true, true); + delete mol; + delete query; TEST_ASSERT(count == 1); } { @@ -842,9 +917,10 @@ void testChiralMatch() { // "<getBondWithIdx(1)->setStereo(Bond::STEREOANY); TEST_ASSERT(SubstructMatch(*mol, *query, matchV, true, true)); + delete mol; + delete query; } - { std::string qSmi = "CC=CC"; std::string mSmi = "CC=C(C)F"; @@ -1101,8 +1218,9 @@ void testCisTransMatch2() { TEST_ASSERT(SubstructMatch(*mol, *query, matchV, true, true)); query->getBondWithIdx(1)->setStereo(Bond::STEREOANY); TEST_ASSERT(SubstructMatch(*mol, *query, matchV, true, true)); + delete mol; + delete query; } - { std::string qSmi = "CC=CC"; std::string mSmi = "CCC=C(C)F"; @@ -1131,8 +1249,9 @@ void testCisTransMatch2() { TEST_ASSERT(SubstructMatch(*mol, *query, matchV, true, true)); query->getBondWithIdx(1)->setStereo(Bond::STEREOANY); TEST_ASSERT(SubstructMatch(*mol, *query, matchV, true, true)); + delete mol; + delete query; } - { // now make it harder: the stereoatoms don't match, but the stereochemistry // does std::string qSmi = "CC=CC"; @@ -1163,8 +1282,9 @@ void testCisTransMatch2() { TEST_ASSERT(SubstructMatch(*mol, *query, matchV, true, true)); query->getBondWithIdx(1)->setStereo(Bond::STEREOANY); TEST_ASSERT(SubstructMatch(*mol, *query, matchV, true, true)); + delete mol; + delete query; } - { // now make it harder: the stereoatoms don't match on either end, but the // stereochemistry does std::string qSmi = "CC=CC"; @@ -1195,6 +1315,8 @@ void testCisTransMatch2() { TEST_ASSERT(SubstructMatch(*mol, *query, matchV, true, true)); query->getBondWithIdx(1)->setStereo(Bond::STEREOANY); TEST_ASSERT(SubstructMatch(*mol, *query, matchV, true, true)); + delete mol; + delete query; } BOOST_LOG(rdErrorLog) << " done" << std::endl; @@ -1211,6 +1333,8 @@ void testGitHubIssue15() { ROMol *mol = SmilesToMol(mSmi); MatchVectType matchV; bool matched = SubstructMatch(*mol, *query, matchV, true, true, true); + delete mol; + delete query; TEST_ASSERT(!matched); } { @@ -1220,6 +1344,8 @@ void testGitHubIssue15() { ROMol *mol = SmartsToMol(mSmi); MatchVectType matchV; bool matched = SubstructMatch(*mol, *query, matchV, true, true, true); + delete mol; + delete query; TEST_ASSERT(!matched); } @@ -1240,6 +1366,7 @@ void testGitHubIssue409() { matched = SubstructMatch(*mol, *mol, matches, false, true, false, false, 16); TEST_ASSERT(matches.size() == 16); + delete mol; } BOOST_LOG(rdErrorLog) << " done" << std::endl; } diff --git a/Code/GraphMol/SubstructLibrary/substructLibraryTest.cpp b/Code/GraphMol/SubstructLibrary/substructLibraryTest.cpp index 603e225bc..578cce89f 100644 --- a/Code/GraphMol/SubstructLibrary/substructLibraryTest.cpp +++ b/Code/GraphMol/SubstructLibrary/substructLibraryTest.cpp @@ -60,6 +60,7 @@ void test1() { } if (!mol) continue; ssslib.addMol(*mol); + delete mol; } { @@ -105,6 +106,7 @@ void test2() { } if (!mol) continue; ssslib.addMol(*mol); + delete mol; } { diff --git a/Code/GraphMol/Wrap/rdchem.cpp b/Code/GraphMol/Wrap/rdchem.cpp index fed7251de..4e08c4d5d 100644 --- a/Code/GraphMol/Wrap/rdchem.cpp +++ b/Code/GraphMol/Wrap/rdchem.cpp @@ -106,8 +106,7 @@ void WrapLogs() { static PySysErrWrite error("RDKit ERROR: "); static PySysErrWrite info("RDKit INFO: "); static PySysErrWrite warning("RDKit WARNING: "); - if (rdDebugLog == nullptr || rdInfoLog == nullptr || rdErrorLog == nullptr || - rdWarningLog == nullptr) { + if (!rdDebugLog || !rdInfoLog || !rdErrorLog || !rdWarningLog) { RDLog::InitLogs(); } if (rdDebugLog != nullptr) rdDebugLog->SetTee(debug); diff --git a/Code/GraphMol/hanoitest.cpp b/Code/GraphMol/hanoitest.cpp index 842ffb8f8..d0e3a8545 100644 --- a/Code/GraphMol/hanoitest.cpp +++ b/Code/GraphMol/hanoitest.cpp @@ -61,7 +61,7 @@ class int_compare_ftor { } }; -void qs1(const std::vector > &vects) { +void qs1(const std::vector> &vects) { BOOST_LOG(rdInfoLog) << "sorting (qsort) vectors" << std::endl; for (auto tv : vects) { int *data = &tv.front(); @@ -73,7 +73,7 @@ void qs1(const std::vector > &vects) { BOOST_LOG(rdInfoLog) << "done: " << vects.size() << std::endl; } -void hs1(const std::vector > &vects) { +void hs1(const std::vector> &vects) { BOOST_LOG(rdInfoLog) << "sorting (hanoi sort) vectors" << std::endl; for (const auto &vect : vects) { const int *data = &vect.front(); @@ -89,6 +89,7 @@ void hs1(const std::vector > &vects) { } free(count); free(indices); + free(changed); } BOOST_LOG(rdInfoLog) << "done: " << vects.size() << std::endl; } @@ -112,7 +113,7 @@ void test1() { source_type randomSource(generator, dist); BOOST_LOG(rdInfoLog) << "populating vectors" << std::endl; - std::vector > vects(nVects); + std::vector> vects(nVects); for (unsigned int i = 0; i < nVects; ++i) { vects[i] = std::vector(vectSize); for (unsigned int j = 0; j < vectSize; ++j) { @@ -229,6 +230,9 @@ void test2() { TEST_ASSERT(count[indices[i]] != 0); } } + delete m; + free(count); + free(changed); } BOOST_LOG(rdInfoLog) << "Done" << std::endl; }; @@ -252,6 +256,7 @@ void test3() { int *changed = (int *)malloc(atoms.size() * sizeof(int)); memset(changed, 1, atoms.size() * sizeof(int)); char *touched = (char *)malloc(atoms.size() * sizeof(char)); + memset(touched, 0, atoms.size() * sizeof(char)); RDKit::Canon::CreateSinglePartition(atoms.size(), order, count, data); RDKit::Canon::ActivatePartitions(atoms.size(), order, count, activeset, @@ -285,6 +290,13 @@ void test3() { TEST_ASSERT(count[order[1]] == 0); TEST_ASSERT(count[order[6]] == 1); TEST_ASSERT(count[order[7]] == 1); + + delete m; + free(count); + free(order); + free(next); + free(changed); + free(touched); } { // this time with smarter invariants @@ -303,6 +315,7 @@ void test3() { int *changed = (int *)malloc(atoms.size() * sizeof(int)); memset(changed, 1, atoms.size() * sizeof(int)); char *touched = (char *)malloc(atoms.size() * sizeof(char)); + memset(touched, 0, atoms.size() * sizeof(char)); RDKit::Canon::CreateSinglePartition(atoms.size(), order, count, data); RDKit::Canon::ActivatePartitions(atoms.size(), order, count, activeset, @@ -329,6 +342,12 @@ void test3() { TEST_ASSERT(count[order[4]] == 0); TEST_ASSERT(count[order[5]] == 3); TEST_ASSERT(count[order[6]] == 0); + delete m; + free(count); + free(order); + free(next); + free(changed); + free(touched); } BOOST_LOG(rdInfoLog) << "Done" << std::endl; }; @@ -344,7 +363,7 @@ class atomcomparefunctor3 { ROMol::OEDGE_ITER beg, end; boost::tie(beg, end) = dp_mol->getAtomBonds(at); while (beg != end) { - const Bond* bond = (*dp_mol)[*beg]; + const Bond *bond = (*dp_mol)[*beg]; nbrs[nbridx] = static_cast(100 * bond->getBondTypeAsDouble()) + dp_atoms[bond->getOtherAtomIdx(i)].index; @@ -433,6 +452,7 @@ void test4() { int *changed = (int *)malloc(atoms.size() * sizeof(int)); memset(changed, 1, atoms.size() * sizeof(int)); char *touched = (char *)malloc(atoms.size() * sizeof(char)); + memset(touched, 0, atoms.size() * sizeof(char)); RDKit::Canon::CreateSinglePartition(atoms.size(), order, count, data); RDKit::Canon::ActivatePartitions(atoms.size(), order, count, activeset, @@ -476,6 +496,11 @@ void test4() { } } delete m; + free(count); + free(order); + free(next); + free(changed); + free(touched); } { @@ -494,6 +519,7 @@ void test4() { int *changed = (int *)malloc(atoms.size() * sizeof(int)); memset(changed, 1, atoms.size() * sizeof(int)); char *touched = (char *)malloc(atoms.size() * sizeof(char)); + memset(touched, 0, atoms.size() * sizeof(char)); RDKit::Canon::CreateSinglePartition(atoms.size(), order, count, data); RDKit::Canon::ActivatePartitions(atoms.size(), order, count, activeset, @@ -524,6 +550,11 @@ void test4() { } } delete m; + free(count); + free(order); + free(next); + free(changed); + free(touched); } { @@ -542,6 +573,7 @@ void test4() { int *changed = (int *)malloc(atoms.size() * sizeof(int)); memset(changed, 1, atoms.size() * sizeof(int)); char *touched = (char *)malloc(atoms.size() * sizeof(char)); + memset(touched, 0, atoms.size() * sizeof(char)); RDKit::Canon::CreateSinglePartition(atoms.size(), order, count, data); RDKit::Canon::ActivatePartitions(atoms.size(), order, count, activeset, @@ -587,6 +619,11 @@ void test4() { TEST_ASSERT(order[9] == 1 && count[1] == 1); delete m; + free(count); + free(order); + free(next); + free(changed); + free(touched); } BOOST_LOG(rdInfoLog) << "Done" << std::endl; @@ -612,6 +649,7 @@ void test5() { int *changed = (int *)malloc(atoms.size() * sizeof(int)); memset(changed, 1, atoms.size() * sizeof(int)); char *touched = (char *)malloc(atoms.size() * sizeof(char)); + memset(touched, 0, atoms.size() * sizeof(char)); RDKit::Canon::CreateSinglePartition(atoms.size(), order, count, data); RDKit::Canon::ActivatePartitions(atoms.size(), order, count, activeset, @@ -659,6 +697,11 @@ void test5() { TEST_ASSERT(count[order[i]] == 1); } delete m; + free(count); + free(order); + free(next); + free(changed); + free(touched); } BOOST_LOG(rdInfoLog) << "Done" << std::endl; }; @@ -866,8 +909,8 @@ void _renumberTest(const ROMol *m, std::string inSmiles, std::cerr << "Renumber: " << nVect[j] << "->" << j << std::endl; } } - TEST_ASSERT(smi == osmi); delete nm; + TEST_ASSERT(smi == osmi); } } @@ -904,9 +947,10 @@ void _renumberTest2(const ROMol *m, std::string inSmiles, TEST_ASSERT(ranksSet[i] == 1); } delete nm; + free(ranksSet); } } -} +} // namespace void test7a() { BOOST_LOG(rdInfoLog) << "testing some specific ordering problems" @@ -1088,8 +1132,8 @@ std::string smis[] = { "C12C3C4C5C6C7C8C1C1C9C5C5C%10C2C2C%11C%12C%13C3C3C7C%10C7C4C%11C1C3C(C5C8%" "12)C(C62)C7C9%13", // does not initially work // drawn examples first reviewer - "C12C3C4C1CC5C46C7C5C1C57C6C53C1C2", - "C1C2C3C4CC5C6C1C17C8C61C5C48C3C27", "EOS"}; + "C12C3C4C1CC5C46C7C5C1C57C6C53C1C2", "C1C2C3C4CC5C6C1C17C8C61C5C48C3C27", + "EOS"}; void test7() { BOOST_LOG(rdInfoLog) << "testing stability w.r.t. renumbering." << std::endl; @@ -1265,6 +1309,7 @@ void test9() { TEST_ASSERT(atomRanks[2] < atomRanks[3]); TEST_ASSERT(atomRanks[2] < atomRanks[4]); TEST_ASSERT(atomRanks[3] < atomRanks[4]); + delete m; } { @@ -1284,6 +1329,7 @@ void test9() { TEST_ASSERT(atomRanks[3] < atomRanks[4]); TEST_ASSERT(atomRanks[4] > atomRanks[5]); TEST_ASSERT(atomRanks[4] > atomRanks[5]); + delete m; } { @@ -1304,6 +1350,7 @@ void test9() { TEST_ASSERT(atomRanks[2] < atomRanks[3]); TEST_ASSERT(atomRanks[2] < atomRanks[4]); TEST_ASSERT(atomRanks[3] < atomRanks[4]); + delete m; } { @@ -1325,6 +1372,7 @@ void test9() { TEST_ASSERT(atomRanks[2] > atomRanks[3]); TEST_ASSERT(atomRanks[2] > atomRanks[11]); TEST_ASSERT(atomRanks[3] < atomRanks[11]); + delete m; } { @@ -1341,6 +1389,7 @@ void test9() { // std::cerr< atomRanks[8]); TEST_ASSERT(atomRanks[5] > atomRanks[2]); + delete m; } { @@ -1357,6 +1406,7 @@ void test9() { // std::cerr< atomRanks[5]); TEST_ASSERT(atomRanks[1] > atomRanks[4]); + delete m; } { @@ -1389,6 +1440,7 @@ void test9() { // std::cerr< atomRanks[6]); TEST_ASSERT(atomRanks[1] < atomRanks[4]); + delete m; } BOOST_LOG(rdInfoLog) << "Finished" << std::endl; @@ -1418,7 +1470,7 @@ void test11() { ROMol *m = SmilesToMol(smi); TEST_ASSERT(m); std::vector vfragsmi; - std::vector > frags; + std::vector> frags; unsigned int numFrag = MolOps::getMolFrags(*m, frags); for (unsigned i = 0; i < numFrag; ++i) { std::string smii = diff --git a/Code/GraphMol/itertest.cpp b/Code/GraphMol/itertest.cpp index 12d0fc865..b2b7b415a 100644 --- a/Code/GraphMol/itertest.cpp +++ b/Code/GraphMol/itertest.cpp @@ -83,6 +83,7 @@ void test1() { atIt -= 10; CHECK_INVARIANT(atIt >= atIt2, "past-the-end failed"); + delete m; BOOST_LOG(rdInfoLog) << "test1 done" << endl; }; @@ -123,6 +124,7 @@ void test2() { bondIt = m->beginBonds(); bondIt--; + delete m; BOOST_LOG(rdInfoLog) << "test2 done" << endl; }; @@ -156,6 +158,8 @@ void test3() { CHECK_INVARIANT((*--heteroIt)->getIdx() == heteros[0], "bad hetero"); CHECK_INVARIANT((*heteroIt)->getIdx() == heteros[0], "bad hetero"); } + + delete m; BOOST_LOG(rdInfoLog) << "test3 done" << endl; }; @@ -193,6 +197,8 @@ void test4() { } smi = "CC(C)CC(C)CC(C)CC(C)C"; unsigned int heteros2[] = {1, 4, 7, 10}; + + delete m; m = SmilesToMol(smi); // m->debugMol(cout); q->setQuery(makeAtomImplicitValenceQuery(1)); @@ -204,6 +210,9 @@ void test4() { nSeen++; } } + + delete m; + delete q; BOOST_LOG(rdInfoLog) << "test4 done" << endl; }; @@ -233,6 +242,7 @@ void test5() { } CHECK_INVARIANT(idx == 3, "bad idx"); + delete m; BOOST_LOG(rdInfoLog) << "test5 done" << endl; } @@ -299,6 +309,7 @@ void test6() { Mol *m = SmilesToMol(smi); _test6Help(m); + delete m; BOOST_LOG(rdInfoLog) << "test6 done" << endl; }; #endif @@ -333,6 +344,8 @@ void test7() { idx++; } TEST_ASSERT(idx == 6); + delete m; + #endif BOOST_LOG(rdInfoLog) << "test7 done" << endl; } @@ -356,6 +369,7 @@ void testIssue263() { idx++; } CHECK_INVARIANT(idx == 7, "bad idx"); + delete m; #endif BOOST_LOG(rdInfoLog) << "testIssue263 done" << endl; diff --git a/Code/GraphMol/memtest1.cpp b/Code/GraphMol/memtest1.cpp index 8bfd15e67..0b281d82e 100644 --- a/Code/GraphMol/memtest1.cpp +++ b/Code/GraphMol/memtest1.cpp @@ -150,16 +150,25 @@ void testProps() { void testDict() { BOOST_LOG(rdInfoLog) << "-----------------------\n dict" << std::endl; int val = 1; + auto *d = new Dict(); + delete d; + d = new Dict(); d->setVal("foo", val); + delete d; + d = new Dict(); d->setVal("foo", val); d->setVal("bar", val); + delete d; + d = new Dict(); d->setVal("foo", val); d->setVal("bar", val); d->setVal("baz", val); + delete d; + BOOST_LOG(rdInfoLog) << "Finished" << std::endl; } // ------------------------------------------------------------------- diff --git a/Code/GraphMol/molopstest.cpp b/Code/GraphMol/molopstest.cpp index dff3d2840..c8baf1cbc 100644 --- a/Code/GraphMol/molopstest.cpp +++ b/Code/GraphMol/molopstest.cpp @@ -303,6 +303,7 @@ void test3() { TEST_ASSERT(sssr[0].size() == 5); TEST_ASSERT(sssr[1].size() == 6); TEST_ASSERT(sssr[2].size() == 6); + delete m; // this yet another painful case smi = "CC1=CC=C(C=C1)S(=O)(=O)O[CH]2[CH]3CO[CH](O3)[CH]4OC(C)(C)O[CH]24"; @@ -314,6 +315,7 @@ void test3() { TEST_ASSERT(sssr[1].size() == 5); TEST_ASSERT(sssr[2].size() == 5); TEST_ASSERT(sssr[3].size() == 6); + delete m; smi = "C1CC2C1C2"; m = SmilesToMol(smi, 0, 0); @@ -388,6 +390,7 @@ void test4() { TEST_ASSERT(adjMat[1] == 1); TEST_ASSERT(adjMat[2] == 1); TEST_ASSERT(adjMat[3] == 0); + delete m; } void test5() { @@ -401,11 +404,13 @@ void test5() { count = MolOps::findSSSR(*m, sssr); BOOST_LOG(rdInfoLog) << "Count: " << count << "\n"; CHECK_INVARIANT(count == 5, ""); + delete m; smi = "C1C(C2)CCC2C1"; m = SmilesToMol(smi); count = MolOps::findSSSR(*m, sssr); CHECK_INVARIANT(count == 2, ""); + delete m; } /* @@ -514,96 +519,100 @@ void test8() { // BOOST_LOG(rdInfoLog) << "1" << std::endl; m2 = MolOps::addHs(*m); CHECK_INVARIANT(m2->getNumAtoms() == 11, ""); + delete m; + delete m2; smi = "CC(=O)[OH]"; - delete m; m = SmilesToMol(smi); CHECK_INVARIANT(m, ""); CHECK_INVARIANT(m->getNumAtoms() == 4, ""); - // BOOST_LOG(rdInfoLog) << "2" << std::endl; - delete m2; + m2 = MolOps::addHs(*m, true); CHECK_INVARIANT(m2->getNumAtoms() == 5, ""); - // BOOST_LOG(rdInfoLog) << "3" << std::endl; m3 = MolOps::addHs(*m2, false); CHECK_INVARIANT(m3->getNumAtoms() == 8, ""); - - // BOOST_LOG(rdInfoLog) << "4" << std::endl; delete m2; + delete m3; + // BOOST_LOG(rdInfoLog) << "4" << std::endl; + m2 = MolOps::addHs(*m, false); CHECK_INVARIANT(m2->getNumAtoms() == 8, ""); - delete m3; + delete m; // remove all // BOOST_LOG(rdInfoLog) << "5" << std::endl; m3 = MolOps::removeHs(*m2, false); CHECK_INVARIANT(m3->getNumAtoms() == 4, ""); delete m3; + // remove only implicit // BOOST_LOG(rdInfoLog) << "6" << std::endl; m3 = MolOps::removeHs(*m2, true); CHECK_INVARIANT(m3->getNumAtoms() == 5, ""); - // BOOST_LOG(rdInfoLog) << "7" << std::endl; // remove all after removing only implicit MolOps::removeHs(static_cast(*m3), false); CHECK_INVARIANT(m3->getNumAtoms() == 4, ""); + delete m2; + delete m3; // this test is also done in the same order in the python tests: - delete m; m = SmilesToMol(smi); CHECK_INVARIANT(m, ""); CHECK_INVARIANT(m->getNumAtoms() == 4, ""); - - delete m2; m2 = MolOps::addHs(*m, true); CHECK_INVARIANT(m2->getNumAtoms() == 5, ""); // BOOST_LOG(rdInfoLog) << "8" << std::endl; m3 = MolOps::removeHs(*m2, true); CHECK_INVARIANT(m3->getNumAtoms() == 5, ""); delete m3; + // BOOST_LOG(rdInfoLog) << "9" << std::endl; m3 = MolOps::removeHs(*m2, false); CHECK_INVARIANT(m3->getNumAtoms() == 4, ""); - delete m2; + delete m3; + // BOOST_LOG(rdInfoLog) << "10" << std::endl; m2 = MolOps::addHs(*m, false); CHECK_INVARIANT(m2->getNumAtoms() == 8, ""); - delete m3; // BOOST_LOG(rdInfoLog) << "11" << std::endl; m3 = MolOps::removeHs(*m2, true); CHECK_INVARIANT(m3->getNumAtoms() == 5, ""); delete m3; + // BOOST_LOG(rdInfoLog) << "12" << std::endl; m3 = MolOps::removeHs(*m2, false); CHECK_INVARIANT(m3->getNumAtoms() == 4, ""); + delete m3; + delete m2; + delete m; // related to RDTrack Issues 109 and 110: smi = "C1C=C([C@H](N)C(=O)N[C@@]2([H])[C@]3([H])SC(C)(C)[C@@H](C(=O)O)N3C(=O)2)" "C=CC=1"; - delete m; m = SmilesToMol(smi); CHECK_INVARIANT(m, ""); CHECK_INVARIANT(m->getNumAtoms() == 24, ""); - delete m3; // BOOST_LOG(rdInfoLog) << "13" << std::endl; m3 = MolOps::removeHs(*m, false); CHECK_INVARIANT(m3->getNumAtoms() == 24, ""); + delete m; + delete m3; // RDTrack Issue 130: - delete m; smi = "[H][N+]([H])([H])[H]"; m = SmilesToMol(smi, false, false); CHECK_INVARIANT(m, ""); CHECK_INVARIANT(m->getNumAtoms() == 5, ""); - delete m2; // BOOST_LOG(rdInfoLog) << "14" << std::endl; m2 = MolOps::removeHs(*m, 0, false); CHECK_INVARIANT(m2->getNumAtoms() == 1, ""); delete m; + delete m2; + smi = "[H][N+]([H])([H])[H]"; m = SmilesToMol(smi); CHECK_INVARIANT(m, ""); @@ -614,13 +623,13 @@ void test8() { m = SmilesToMol(smi, false, false); CHECK_INVARIANT(m, ""); CHECK_INVARIANT(m->getNumAtoms() == 2, ""); - delete m2; // BOOST_LOG(rdInfoLog) << "15" << std::endl; m2 = MolOps::removeHs(*m, 0, false); CHECK_INVARIANT(m2->getNumAtoms() == 2, ""); + delete m; + delete m2; std::string sma; - delete m; smi = "CC"; m = SmartsToMol(smi); MolOps::sanitizeMol(*((RWMol *)m)); @@ -630,15 +639,14 @@ void test8() { static_cast(m->getAtomWithIdx(0))); TEST_ASSERT(sma == "C"); - delete m2; // BOOST_LOG(rdInfoLog) << "16" << std::endl; m2 = MolOps::addHs(*m); TEST_ASSERT(m2->getNumAtoms() == 8); sma = SmartsWrite::GetAtomSmarts( static_cast(m2->getAtomWithIdx(0))); TEST_ASSERT(sma == "C"); - delete m; + // BOOST_LOG(rdInfoLog) << "17" << std::endl; m = MolOps::mergeQueryHs(*m2); TEST_ASSERT(m->getNumAtoms() == 2); @@ -647,41 +655,41 @@ void test8() { // BOOST_LOG(rdInfoLog) << "sma: " << sma<getNumAtoms() == 5, ""); - delete m2; // BOOST_LOG(rdInfoLog) << "18" << std::endl; m2 = MolOps::addHs(*m, false, false); CHECK_INVARIANT(m2->getNumAtoms() == 10, ""); - delete m; // BOOST_LOG(rdInfoLog) << "19" << std::endl; + delete m; m = MolOps::removeHs(*m2); CHECK_INVARIANT(m, ""); CHECK_INVARIANT(m->getNumAtoms() == 5, ""); + delete m; + delete m2; // labelling: - delete m; smi = "c1cn([H])cc1"; m = SmilesToMol(smi); CHECK_INVARIANT(m, ""); CHECK_INVARIANT(m->getNumAtoms() == 5, ""); - delete m2; // BOOST_LOG(rdInfoLog) << "19" << std::endl; m2 = MolOps::removeHs(*m); CHECK_INVARIANT(m, ""); CHECK_INVARIANT(m->getNumAtoms() == 5, ""); - delete m; + delete m2; + smi = "c1cn([2H])cc1"; m = SmilesToMol(smi); CHECK_INVARIANT(m, ""); CHECK_INVARIANT(m->getNumAtoms() == 6, ""); - delete m2; // BOOST_LOG(rdInfoLog) << "19" << std::endl; m2 = MolOps::removeHs(*m); CHECK_INVARIANT(m, ""); @@ -759,6 +767,7 @@ void test9() { m = SmilesToMol(smi); TEST_ASSERT(m); TEST_ASSERT(m->getNumAtoms() == 3); + double *dMat; dMat = MolOps::getDistanceMat(*m, false, false); TEST_ASSERT(dMat); @@ -809,6 +818,8 @@ void test9() { TEST_ASSERT(dMat[7] == 1.0); TEST_ASSERT(dMat[8] == 0.0); + delete m; + BOOST_LOG(rdInfoLog) << "Finished" << std::endl; } @@ -851,6 +862,7 @@ void test10() { TEST_ASSERT(m->getAtomWithIdx(i)->hasProp(common_properties::_CIPRank)); m->getAtomWithIdx(i)->getProp(common_properties::_CIPRank, cip); } + delete m; BOOST_LOG(rdInfoLog) << "Finished" << std::endl; } @@ -1290,7 +1302,7 @@ void test11() { TEST_ASSERT(m->getAtomWithIdx(2)->hasProp(common_properties::_CIPCode)); m->getAtomWithIdx(2)->getProp(common_properties::_CIPCode, cip); TEST_ASSERT(cip == "S"); - + delete m; // ----------------------------------------------- BOOST_LOG(rdInfoLog) << "Finished" << std::endl; @@ -1787,6 +1799,7 @@ void testIssue211() { const Atom *at = m->getAtomWithIdx(0); TEST_ASSERT(at->getHybridization() == Atom::SP3); + delete m; BOOST_LOG(rdInfoLog) << "Finished" << std::endl; } @@ -2266,6 +2279,7 @@ void testHsAndAromaticity() { TEST_ASSERT(mol->getAtomWithIdx(0)->getNumRadicalElectrons() == 1); TEST_ASSERT(!mol->getAtomWithIdx(0)->getIsAromatic()); TEST_ASSERT(!mol->getBondBetweenAtoms(0, 1)->getIsAromatic()); + delete mol; smi = "C1=CC(=C)C(=C)C=C1"; mol = SmilesToMol(smi); @@ -2455,18 +2469,21 @@ void testSFIssue1811276() { TEST_ASSERT(m); smi = MolToSmiles(*m); TEST_ASSERT(smi == "O=c1ccocc1"); + delete m; smi = "O=[n+]1ccocc1"; m = SmilesToMol(smi); TEST_ASSERT(m); smi = MolToSmiles(*m); TEST_ASSERT(smi == "O=[n+]1ccocc1"); + delete m; smi = "O=[n+]1ccn([O-])cc1"; m = SmilesToMol(smi); TEST_ASSERT(m); smi = MolToSmiles(*m); TEST_ASSERT(smi == "O=[n+]1ccn([O-])cc1"); + delete m; smi = "O=n1ccccc1"; m = SmilesToMol(smi); @@ -2506,7 +2523,7 @@ void testSFIssue1836576() { TEST_ASSERT(ok); TEST_ASSERT(opThatFailed == MolOps::SANITIZE_PROPERTIES); delete m; - + BOOST_LOG(rdInfoLog) << "Finished" << std::endl; } @@ -2901,6 +2918,7 @@ void testSFIssue1968608() { TEST_ASSERT(m->getRingInfo()->minAtomRingSize(3) == 0); TEST_ASSERT(m->getRingInfo()->minBondRingSize(0) == 3); TEST_ASSERT(m->getRingInfo()->minBondRingSize(3) == 0); + delete m; BOOST_LOG(rdInfoLog) << "Finished" << std::endl; } @@ -3297,6 +3315,7 @@ void testSFNetIssue2316677() { std::cerr << "smi: " << smi << std::endl; TEST_ASSERT(smi == "Cc1ccc(S(=O)(=O)/N=C2\\CC(=N\\C(C)(C)C)/C2=N\\C(C)(C)C)cc1"); + delete m; } BOOST_LOG(rdInfoLog) << "Finished" << std::endl; @@ -3557,6 +3576,7 @@ void testSFNetIssue3185548() { RWMol *m = MolFileToMol(pathName + "Issue3185548.mol"); BOOST_LOG(rdInfoLog) << " finished" << std::endl; TEST_ASSERT(m); + delete m; } { @@ -3574,6 +3594,7 @@ void testSFNetIssue3185548() { TEST_ASSERT(nsssr = 48); nsssr = MolOps::symmetrizeSSSR(*m, sssrs); TEST_ASSERT(nsssr = 56); + delete m; } BOOST_LOG(rdInfoLog) << "Finished" << std::endl; @@ -4005,6 +4026,8 @@ void testBasicCanon() { Bond::STEREOZ); TEST_ASSERT(m2->getBondBetweenAtoms(mmap[7], mmap[8])->getStereo() == Bond::STEREOZ); + delete m; + delete m2; } { std::string pathName = getenv("RDBASE"); @@ -4032,6 +4055,8 @@ void testBasicCanon() { Bond::STEREOZ); TEST_ASSERT(m2->getBondBetweenAtoms(mmap[14], mmap[15])->getStereo() == Bond::STEREOZ); + delete m; + delete m2; } #endif @@ -4089,6 +4114,7 @@ void testBasicCanon() { // std::cerr< nVect; - MolOps::renumberAtoms(*m, nVect); + auto *m1 = MolOps::renumberAtoms(*m, nVect); delete m; + delete m1; } BOOST_LOG(rdInfoLog) << "Finished" << std::endl; @@ -4736,13 +4764,13 @@ void testZBO() { { auto *m = new RWMol(); - m->addAtom(new Atom(26)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(26), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); m->addBond(1, 2, Bond::AROMATIC); m->addBond(2, 3, Bond::AROMATIC); m->addBond(3, 4, Bond::AROMATIC); @@ -4775,6 +4803,7 @@ void testZBO() { TEST_ASSERT(m->getBondWithIdx(3)->getIsAromatic()); TEST_ASSERT(m->getBondWithIdx(4)->getIsAromatic()); TEST_ASSERT(m->getBondWithIdx(5)->getIsAromatic()); + delete m; } BOOST_LOG(rdInfoLog) << "Finished" << std::endl; } @@ -5603,6 +5632,7 @@ void testAdjustQueryProperties() { t = SmilesToMol("c1ccc(Cl)cc1Cl"); TEST_ASSERT(!SubstructMatch(*t, *m, match)); delete m; + delete t; } { // CTAB @@ -5651,6 +5681,7 @@ void testAdjustQueryProperties() { t = SmilesToMol("c1c(Cl)cc(Cl)cc1Cl"); TEST_ASSERT(SubstructMatch(*t, *m, match)); delete m; + delete t; } #endif { // make atoms generic @@ -6310,6 +6341,8 @@ void testBondSetStereoAtoms() { doubleBond->setStereo(Bond::STEREOTRANS); BOOST_LOG(rdInfoLog) << MolToSmiles(*m, doIsomericSmiles) << std::endl; TEST_ASSERT(MolToSmiles(*m, doIsomericSmiles) == "F/C(Cl)=C(/Br)I"); + delete m; + ; } } diff --git a/Code/GraphMol/new_canon.h b/Code/GraphMol/new_canon.h index a3cd98666..8d877e322 100644 --- a/Code/GraphMol/new_canon.h +++ b/Code/GraphMol/new_canon.h @@ -74,7 +74,8 @@ struct RDKIT_GRAPHMOL_EXPORT bondholder { } }; -struct RDKIT_GRAPHMOL_EXPORT canon_atom { +class RDKIT_GRAPHMOL_EXPORT canon_atom { + public: const Atom *atom; int index; unsigned int degree; @@ -96,13 +97,18 @@ struct RDKIT_GRAPHMOL_EXPORT canon_atom { isRingStereoAtom(false), nbrIds(NULL), p_symbol(NULL){}; + + ~canon_atom() { + free(nbrIds); + } }; -RDKIT_GRAPHMOL_EXPORT void updateAtomNeighborIndex(canon_atom *atoms, std::vector &nbrs); +RDKIT_GRAPHMOL_EXPORT void updateAtomNeighborIndex( + canon_atom *atoms, std::vector &nbrs); RDKIT_GRAPHMOL_EXPORT void updateAtomNeighborNumSwaps( canon_atom *atoms, std::vector &nbrs, unsigned int atomIdx, - std::vector > &result); + std::vector> &result); /* * Different types of atom compare functions: @@ -155,8 +161,8 @@ class RDKIT_GRAPHMOL_EXPORT SpecialChiralityAtomCompareFunctor { if (cmp) return cmp; } - std::vector > swapsi; - std::vector > swapsj; + std::vector> swapsi; + std::vector> swapsj; if ((dp_atomsInPlay && (*dp_atomsInPlay)[i]) || !dp_atomsInPlay) { updateAtomNeighborNumSwaps(dp_atoms, dp_atoms[i].bonds, i, swapsi); } @@ -703,27 +709,33 @@ void BreakTies(const ROMol &mol, canon_atom *atoms, CompareFunc compar, } } // end of BreakTies() -RDKIT_GRAPHMOL_EXPORT void CreateSinglePartition(unsigned int nAtoms, int *order, int *count, - canon_atom *atoms); +RDKIT_GRAPHMOL_EXPORT void CreateSinglePartition(unsigned int nAtoms, + int *order, int *count, + canon_atom *atoms); -RDKIT_GRAPHMOL_EXPORT void ActivatePartitions(unsigned int nAtoms, int *order, int *count, - int &activeset, int *next, int *changed); +RDKIT_GRAPHMOL_EXPORT void ActivatePartitions(unsigned int nAtoms, int *order, + int *count, int &activeset, + int *next, int *changed); -RDKIT_GRAPHMOL_EXPORT void rankMolAtoms(const ROMol &mol, std::vector &res, - bool breakTies = true, bool includeChirality = true, - bool includeIsotopes = true); +RDKIT_GRAPHMOL_EXPORT void rankMolAtoms(const ROMol &mol, + std::vector &res, + bool breakTies = true, + bool includeChirality = true, + bool includeIsotopes = true); -RDKIT_GRAPHMOL_EXPORT void rankFragmentAtoms(const ROMol &mol, std::vector &res, - const boost::dynamic_bitset<> &atomsInPlay, - const boost::dynamic_bitset<> &bondsInPlay, - const std::vector *atomSymbols = NULL, - bool breakTies = true, bool includeChirality = true, - bool includeIsotopes = true); +RDKIT_GRAPHMOL_EXPORT void rankFragmentAtoms( + const ROMol &mol, std::vector &res, + const boost::dynamic_bitset<> &atomsInPlay, + const boost::dynamic_bitset<> &bondsInPlay, + const std::vector *atomSymbols = NULL, bool breakTies = true, + bool includeChirality = true, bool includeIsotopes = true); -RDKIT_GRAPHMOL_EXPORT void chiralRankMolAtoms(const ROMol &mol, std::vector &res); +RDKIT_GRAPHMOL_EXPORT void chiralRankMolAtoms(const ROMol &mol, + std::vector &res); -RDKIT_GRAPHMOL_EXPORT void initCanonAtoms(const ROMol &mol, std::vector &atoms, - bool includeChirality = true); +RDKIT_GRAPHMOL_EXPORT void initCanonAtoms(const ROMol &mol, + std::vector &atoms, + bool includeChirality = true); -} // end of Canon namespace -} // end of RDKit namespace +} // namespace Canon +} // namespace RDKit diff --git a/Code/GraphMol/querytest.cpp b/Code/GraphMol/querytest.cpp index 363a0a46b..bba7830a0 100644 --- a/Code/GraphMol/querytest.cpp +++ b/Code/GraphMol/querytest.cpp @@ -119,6 +119,7 @@ void test2() { CHECK_INVARIANT(qB->Match(m.getBondWithIdx(1)), ""); CHECK_INVARIANT(qB->Match(m.getBondWithIdx(2)), ""); + delete qB; BOOST_LOG(rdErrorLog) << "Done!" << std::endl; } @@ -237,6 +238,7 @@ void test3() { CHECK_INVARIANT(!beq->Match(m.getBondBetweenAtoms(5, 6)), ""); CHECK_INVARIANT(!beq->Match(m.getBondBetweenAtoms(6, 5)), ""); + delete beq; BOOST_LOG(rdErrorLog) << "Done!" << std::endl; } @@ -514,6 +516,7 @@ void testIssue2892580() { TEST_ASSERT(massVal == static_cast(RDKit::round( 13.003 * massIntegerConversionFactor))); + delete a; BOOST_LOG(rdErrorLog) << "Done!" << std::endl; } @@ -531,6 +534,9 @@ void testGithub153() { TEST_ASSERT(mvv.size() == 3); TEST_ASSERT(mvv[0].size() == 1); + delete m; + delete q; + BOOST_LOG(rdErrorLog) << "Done!" << std::endl; } @@ -855,6 +861,7 @@ void testAtomTypeQueries() { TEST_ASSERT(!qA3.Match(m->getAtomWithIdx(2))); } + delete m; BOOST_LOG(rdErrorLog) << "Done!" << std::endl; } diff --git a/Code/GraphMol/resMolSupplierTest.cpp b/Code/GraphMol/resMolSupplierTest.cpp index e89e760ba..400dc9d49 100644 --- a/Code/GraphMol/resMolSupplierTest.cpp +++ b/Code/GraphMol/resMolSupplierTest.cpp @@ -75,23 +75,29 @@ void testBaseFunctionality() { TEST_ASSERT(!resMolSuppl->getIsEnumerated()); resMolSuppl->enumerate(); TEST_ASSERT(resMolSuppl->getIsEnumerated()); - TEST_ASSERT(((*resMolSuppl)[0]->getBondBetweenAtoms(0, 1)->getBondType() != - (*resMolSuppl)[1]->getBondBetweenAtoms(0, 1)->getBondType()) || - ((*resMolSuppl)[0]->getBondBetweenAtoms(9, 10)->getBondType() != - (*resMolSuppl)[1]->getBondBetweenAtoms(9, 10)->getBondType())); + auto *smol0 = (*resMolSuppl)[0]; + auto *smol1 = (*resMolSuppl)[1]; + TEST_ASSERT((smol0->getBondBetweenAtoms(0, 1)->getBondType() != + smol1->getBondBetweenAtoms(0, 1)->getBondType()) || + (smol0->getBondBetweenAtoms(9, 10)->getBondType() != + smol1->getBondBetweenAtoms(9, 10)->getBondType())); + delete smol0; + delete smol1; delete resMolSuppl; resMolSuppl = new ResonanceMolSupplier((ROMol &)*mol, ResonanceMolSupplier::KEKULE_ALL); TEST_ASSERT(resMolSuppl->length() == 8); std::set bondTypeSet; + smol0 = (*resMolSuppl)[0]; + smol1 = (*resMolSuppl)[1]; // check that we actually have two alternate Kekule structures - bondTypeSet.insert( - (*resMolSuppl)[0]->getBondBetweenAtoms(3, 4)->getBondType()); - bondTypeSet.insert( - (*resMolSuppl)[1]->getBondBetweenAtoms(3, 4)->getBondType()); + bondTypeSet.insert(smol0->getBondBetweenAtoms(3, 4)->getBondType()); + bondTypeSet.insert(smol1->getBondBetweenAtoms(3, 4)->getBondType()); TEST_ASSERT(bondTypeSet.size() == 2); bondTypeSet.clear(); + delete smol0; + delete smol1; delete resMolSuppl; resMolSuppl = new ResonanceMolSupplier( @@ -110,10 +116,19 @@ void testBaseFunctionality() { delete resMol; } resMolSuppl->reset(); - cmpFormalChargeBondOrder((*resMolSuppl)[0], resMolSuppl->next()); + smol0 = (*resMolSuppl)[0]; + smol1 = resMolSuppl->next(); + cmpFormalChargeBondOrder(smol0, smol1); + delete smol0; + delete smol1; + resMolSuppl->moveTo(12); - cmpFormalChargeBondOrder((*resMolSuppl)[12], resMolSuppl->next()); + smol0 = (*resMolSuppl)[12]; + smol1 = resMolSuppl->next(); + cmpFormalChargeBondOrder(smol0, smol1); delete resMolSuppl; + delete smol0; + delete smol1; resMolSuppl = new ResonanceMolSupplier( (ROMol &)*mol, ResonanceMolSupplier::ALLOW_INCOMPLETE_OCTETS | @@ -130,6 +145,7 @@ void testBaseFunctionality() { 0); TEST_ASSERT(resMolSuppl->length() == 0); delete resMolSuppl; + delete mol; } void testBenzylCation() { @@ -151,6 +167,7 @@ void testBenzylCation() { TEST_ASSERT(fcMap[idx] == 1); } delete resMolSuppl; + delete mol; } void testBenzylAnion() { @@ -172,6 +189,7 @@ void testBenzylAnion() { TEST_ASSERT(fcMap[idx] == -1); } delete resMolSuppl; + delete mol; } void testButadiene() { @@ -202,6 +220,7 @@ void testButadiene() { TEST_ASSERT(fcMap[idx] == 0); } delete resMolSuppl; + delete mol; } void testZwitterion() { @@ -224,8 +243,10 @@ void testZwitterion() { ROMol *mol1 = (*resMolSuppl)[1]; TEST_ASSERT(mol1->getAtomWithIdx(0)->getFormalCharge() == 1); TEST_ASSERT(mol1->getAtomWithIdx(6)->getFormalCharge() == -1); + delete mol0; delete mol1; delete resMolSuppl; + delete mol; } void testChargeMigration() { @@ -248,6 +269,7 @@ void testChargeMigration() { TEST_ASSERT(fcMap[idx] == 1); } delete resMolSuppl; + delete mol; } void testChargeSeparation1() { @@ -280,6 +302,7 @@ void testChargeSeparation1() { TEST_ASSERT(resMol->getAtomWithIdx(8)->getFormalCharge() == -1); delete resMol; delete resMolSuppl; + delete mol; } void testChargeSeparation2() { @@ -335,6 +358,7 @@ void testChargeSeparation2() { delete resMol; } delete resMolSuppl; + delete mol; } void testMultipleConjGroups1() { @@ -385,6 +409,7 @@ void testMultipleConjGroups1() { delete resMol; } delete resMolSuppl; + delete mol; } void testMultipleConjGroups2() { @@ -411,6 +436,7 @@ void testMultipleConjGroups2() { delete resMol; } delete resMolSuppl; + delete mol; } void testDimethylMalonate() { @@ -434,6 +460,7 @@ void testDimethylMalonate() { delete resMol; } delete resMolSuppl; + delete mol; } void testMethylAcetate() { @@ -473,6 +500,7 @@ void testMethylAcetate() { delete resMol; } delete resMolSuppl; + delete mol; } void testPyranium2_6dicarboxylate() { @@ -492,6 +520,7 @@ void testPyranium2_6dicarboxylate() { delete resMol; } delete resMolSuppl; + delete mol; } void testSubstructMatchAcetate() { @@ -694,34 +723,31 @@ void testGitHub1166() { // check that formal charges on odd indices are in the same position // as on even indices for (unsigned int i = 0; i < resMolSuppl->length(); i += 2) { - TEST_ASSERT((*resMolSuppl)[i]->getNumAtoms() == - (*resMolSuppl)[i + 1]->getNumAtoms()); - for (unsigned int atomIdx = 0; atomIdx < (*resMolSuppl)[i]->getNumAtoms(); - ++atomIdx) + auto *smol0 = (*resMolSuppl)[i]; + auto *smol1 = (*resMolSuppl)[i + 1]; + TEST_ASSERT(smol0->getNumAtoms() == smol1->getNumAtoms()); + for (unsigned int atomIdx = 0; atomIdx < smol0->getNumAtoms(); ++atomIdx) TEST_ASSERT( - (*resMolSuppl)[i]->getAtomWithIdx(atomIdx)->getFormalCharge() == - (*resMolSuppl)[i + 1]->getAtomWithIdx(atomIdx)->getFormalCharge()); + smol0->getAtomWithIdx(atomIdx)->getFormalCharge() == + smol1->getAtomWithIdx(atomIdx)->getFormalCharge()); // check that bond orders are alternate on aromatic bonds between // structures on odd indices and structures on even indices - TEST_ASSERT((*resMolSuppl)[i]->getNumBonds() == - (*resMolSuppl)[i + 1]->getNumBonds()); - for (unsigned int bondIdx = 0; bondIdx < (*resMolSuppl)[i]->getNumBonds(); - ++bondIdx) + TEST_ASSERT(smol0->getNumBonds() == smol1->getNumBonds()); + for (unsigned int bondIdx = 0; bondIdx < smol0->getNumBonds(); ++bondIdx) TEST_ASSERT( - (!(*resMolSuppl)[i]->getBondWithIdx(bondIdx)->getIsAromatic() && - !(*resMolSuppl)[i + 1]->getBondWithIdx(bondIdx)->getIsAromatic() && - ((*resMolSuppl)[i]->getBondWithIdx(bondIdx)->getBondType() == - (*resMolSuppl)[i + 1]->getBondWithIdx(bondIdx)->getBondType())) || - ((*resMolSuppl)[i]->getBondWithIdx(bondIdx)->getIsAromatic() && - (*resMolSuppl)[i + 1]->getBondWithIdx(bondIdx)->getIsAromatic() && - (static_cast((*resMolSuppl)[i] - ->getBondWithIdx(bondIdx) - ->getBondTypeAsDouble() + - (*resMolSuppl)[i + 1] - ->getBondWithIdx(bondIdx) - ->getBondTypeAsDouble()) == 3))); + (!smol0->getBondWithIdx(bondIdx)->getIsAromatic() && + !smol1->getBondWithIdx(bondIdx)->getIsAromatic() && + (smol0->getBondWithIdx(bondIdx)->getBondType() == + smol1->getBondWithIdx(bondIdx)->getBondType())) || + (smol0->getBondWithIdx(bondIdx)->getIsAromatic() && + smol1->getBondWithIdx(bondIdx)->getIsAromatic() && + (static_cast(smol0->getBondWithIdx(bondIdx)->getBondTypeAsDouble() + + smol1->getBondWithIdx(bondIdx)->getBondTypeAsDouble()) == 3))); + delete smol0; + delete smol1; } delete resMolSuppl; + delete mol; } int main() { diff --git a/Code/GraphMol/test1.cpp b/Code/GraphMol/test1.cpp index ce138d554..7a588953b 100644 --- a/Code/GraphMol/test1.cpp +++ b/Code/GraphMol/test1.cpp @@ -126,8 +126,8 @@ void testMolProps() { RWMol m2; STR_VECT propNames; - m2.addAtom(new Atom(6)); - m2.addAtom(new Atom(6)); + m2.addAtom(new Atom(6), true, true); + m2.addAtom(new Atom(6), true, true); m2.addBond(0, 1, Bond::TRIPLE); CHECK_INVARIANT(!m2.hasProp("prop1"), ""); @@ -196,8 +196,8 @@ void testClearMol() { << std::endl; RWMol m2; - m2.addAtom(new Atom(6)); - m2.addAtom(new Atom(6)); + m2.addAtom(new Atom(6), true, true); + m2.addAtom(new Atom(6), true, true); m2.addBond(0, 1, Bond::TRIPLE); TEST_ASSERT(!m2.hasProp("prop1")); @@ -227,8 +227,8 @@ void testAtomProps() { BOOST_LOG(rdInfoLog) << "-----------------------\n Testing Atom Property Caches" << std::endl; RWMol m2; - m2.addAtom(new Atom(6)); - m2.addAtom(new Atom(6)); + m2.addAtom(new Atom(6), true, true); + m2.addAtom(new Atom(6), true, true); m2.addBond(0, 1, Bond::TRIPLE); Atom *a1 = m2.getAtomWithIdx(0); @@ -311,8 +311,8 @@ void testBondProps() { BOOST_LOG(rdInfoLog) << "-----------------------\n Testing Bond Property Caches" << std::endl; RWMol m2; - m2.addAtom(new Atom(6)); - m2.addAtom(new Atom(6)); + m2.addAtom(new Atom(6), true, true); + m2.addAtom(new Atom(6), true, true); m2.addBond(0, 1, Bond::TRIPLE); Bond *b1 = m2.getBondWithIdx(0); @@ -369,8 +369,8 @@ void testPropLeak() { << "-----------------------\n Testing Atom and Bond Property Caches" << std::endl; RWMol m2; - m2.addAtom(new Atom(6)); - m2.addAtom(new Atom(6)); + m2.addAtom(new Atom(6), true, true); + m2.addAtom(new Atom(6), true, true); m2.addBond(0, 1, Bond::TRIPLE); Atom *a1 = m2.getAtomWithIdx(0); @@ -429,10 +429,10 @@ void testMisc() { BOOST_LOG(rdInfoLog) << "-----------------------\n Testing Misc Properties" << std::endl; RWMol m2; - m2.addAtom(new Atom(6)); - m2.addAtom(new Atom(6)); - m2.addAtom(new Atom(6)); - m2.addAtom(new Atom(6)); + m2.addAtom(new Atom(6), true, true); + m2.addAtom(new Atom(6), true, true); + m2.addAtom(new Atom(6), true, true); + m2.addAtom(new Atom(6), true, true); m2.addBond(0, 1, Bond::SINGLE); m2.addBond(1, 2, Bond::SINGLE); m2.addBond(0, 2, Bond::SINGLE); @@ -474,7 +474,7 @@ void testMisc() { MolOps::sanitizeMol(m2); CHECK_INVARIANT(m2.getAtomWithIdx(0)->getTotalNumHs() == 3, ""); - m2.addAtom(new Atom(1)); + m2.addAtom(new Atom(1), true, true); m2.addBond(2, 3, Bond::SINGLE); MolOps::sanitizeMol(m2); @@ -513,10 +513,10 @@ void testDegree() { RWMol *m; m = new RWMol(); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); m->addBond(0, 1, Bond::SINGLE); m->addBond(1, 2, Bond::SINGLE); m->addBond(0, 2, Bond::SINGLE); @@ -532,11 +532,11 @@ void testDegree() { delete m; m = new RWMol(); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(1)); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(1), true, true); m->addBond(0, 1, Bond::SINGLE); m->addBond(1, 2, Bond::SINGLE); m->addBond(0, 2, Bond::SINGLE); @@ -551,6 +551,7 @@ void testDegree() { TEST_ASSERT(m->getAtomWithIdx(2)->getDegree() == 3); TEST_ASSERT(m->getAtomWithIdx(2)->getTotalNumHs() == 1); TEST_ASSERT(m->getAtomWithIdx(2)->getTotalDegree() == 4); + delete m; BOOST_LOG(rdInfoLog) << "Finished" << std::endl; } @@ -561,8 +562,8 @@ void testIssue1993296() { BOOST_LOG(rdInfoLog) << "-------------------------------------" << std::endl; BOOST_LOG(rdInfoLog) << "Testing Issue 1993296" << std::endl; - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); m->addBond(0, 1, Bond::SINGLE); ok = false; try { @@ -612,6 +613,7 @@ void testIssue1993296() { } TEST_ASSERT(ok); delete newB; + delete m; BOOST_LOG(rdInfoLog) << "\tdone" << std::endl; } @@ -622,10 +624,10 @@ void testIssue2381580() { { auto *m = new RWMol(); - m->addAtom(new Atom(5)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(5), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); m->addBond(0, 1, Bond::SINGLE); m->addBond(0, 2, Bond::SINGLE); m->addBond(0, 3, Bond::SINGLE); @@ -638,11 +640,11 @@ void testIssue2381580() { { auto *m = new RWMol(); - m->addAtom(new Atom(5)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(5), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); m->addBond(0, 1, Bond::SINGLE); m->addBond(0, 2, Bond::SINGLE); m->addBond(0, 3, Bond::SINGLE); @@ -657,11 +659,11 @@ void testIssue2381580() { { auto *m = new RWMol(); - m->addAtom(new Atom(5)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(5), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); m->addBond(0, 1, Bond::SINGLE); m->addBond(0, 2, Bond::SINGLE); m->addBond(0, 3, Bond::SINGLE); @@ -678,11 +680,11 @@ void testIssue2381580() { { auto *m = new RWMol(); - m->addAtom(new Atom(5)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(5), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); m->addBond(0, 1, Bond::SINGLE); m->addBond(0, 2, Bond::SINGLE); m->addBond(0, 3, Bond::SINGLE); @@ -700,9 +702,9 @@ void testIssue2381580() { { auto *m = new RWMol(); - m->addAtom(new Atom(5)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(5), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); m->addBond(0, 1, Bond::SINGLE); m->addBond(0, 2, Bond::SINGLE); m->getAtomWithIdx(0)->setFormalCharge(+1); @@ -715,10 +717,10 @@ void testIssue2381580() { { auto *m = new RWMol(); - m->addAtom(new Atom(5)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(5), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); m->addBond(0, 1, Bond::SINGLE); m->addBond(0, 2, Bond::SINGLE); m->addBond(0, 3, Bond::SINGLE); @@ -752,12 +754,12 @@ void testIssue2840217() { { auto *m = new RWMol(); for (unsigned int i = 0; i < 200; ++i) { - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); for (unsigned int j = 0; j < 5; ++j) { m->addBond(i * 6 + j, i * 6 + j + 1, Bond::AROMATIC); } @@ -777,15 +779,15 @@ void test1() { RWMol m; auto *newAtom = new Atom(8); - m.addAtom(newAtom); + m.addAtom(newAtom, true, true); CHECK_INVARIANT(m.getAtomWithIdx(0)->getIdx() == 0, ""); newAtom = new Atom(6); - m.addAtom(newAtom); + m.addAtom(newAtom, true, true); CHECK_INVARIANT(m.getAtomWithIdx(0)->getIdx() == 0, ""); CHECK_INVARIANT(m.getAtomWithIdx(1)->getIdx() == 1, ""); newAtom = new Atom(7); - m.addAtom(newAtom); + m.addAtom(newAtom, true, true); CHECK_INVARIANT(m.getAtomWithIdx(0)->getIdx() == 0, ""); CHECK_INVARIANT(m.getAtomWithIdx(1)->getIdx() == 1, ""); CHECK_INVARIANT(m.getAtomWithIdx(2)->getIdx() == 2, ""); @@ -818,7 +820,7 @@ void test1() { ai1++; } - m.addAtom(new Atom(6)); + m.addAtom(new Atom(6), true, true); Bond *bsp = m.createPartialBond(2); m.setBondBookmark(bsp, 47); m.finishPartialBond(3, 47, Bond::SINGLE); @@ -831,7 +833,7 @@ void test1() { BOOST_LOG(rdInfoLog) << "\t" << *a << endl; } - int newAtNum = m.addAtom(new Atom(6)); + int newAtNum = m.addAtom(new Atom(6), true, true); m.addBond(0, newAtNum, Bond::SINGLE); BOOST_LOG(rdInfoLog) << "Again:" << endl; @@ -842,12 +844,12 @@ void test1() { } RWMol m2; - m2.addAtom(new Atom(6)); - m2.addAtom(new Atom(6)); + m2.addAtom(new Atom(6), true, true); + m2.addAtom(new Atom(6), true, true); // QueryAtom *qA = new QueryAtom; // qA->setAtomicNum(7); // m2.addAtom(qA); - m2.addAtom(new QueryAtom(7)); + m2.addAtom(new QueryAtom(7), true, true); m2.addBond(0, 1, Bond::TRIPLE); m2.addBond(1, 2, Bond::SINGLE); @@ -861,7 +863,7 @@ void test1() { BOOST_LOG(rdInfoLog) << " ------------------- " << endl; auto *newA = new Atom(12); - int newIdx = m.addAtom(newA); + int newIdx = m.addAtom(newA, true, true); m.addBond(newIdx - 1, newIdx, Bond::AROMATIC); // m.debugMol(cout); BOOST_LOG(rdInfoLog) << " trying a replace " << endl; @@ -877,11 +879,12 @@ void test1() { TEST_ASSERT(m.getBondWithIdx(m.getNumBonds() - 1)->getBondType() == nbnd->getBondType()); delete nbnd; + delete bsp; } { RWMol m; - m.addAtom(new Atom(6)); - m.addAtom(new Atom(6)); + m.addAtom(new Atom(6), true, true); + m.addAtom(new Atom(6), true, true); m.addBond(0, 1, Bond::SINGLE); auto *conf = new Conformer(m.getNumAtoms()); m.addConformer(conf); @@ -890,7 +893,7 @@ void test1() { RWMol m2; // insert molecule without a conf: - m2.addAtom(new Atom(6)); + m2.addAtom(new Atom(6), true, true); m.insertMol(m2); TEST_ASSERT(m.getConformer().getNumAtoms() == m.getNumAtoms()); TEST_ASSERT(feq(m.getConformer().getAtomPos(2).x, 0.0)); @@ -913,14 +916,14 @@ void test1() { { // start with a molecule with no conf RWMol m; - m.addAtom(new Atom(6)); - m.addAtom(new Atom(6)); + m.addAtom(new Atom(6), true, true); + m.addAtom(new Atom(6), true, true); m.addBond(0, 1, Bond::SINGLE); TEST_ASSERT(m.getNumConformers() == 0); RWMol m2; // insert molecule without a conf: - m2.addAtom(new Atom(6)); + m2.addAtom(new Atom(6), true, true); m.insertMol(m2); TEST_ASSERT(m.getNumConformers() == 0); @@ -978,20 +981,20 @@ void testAddAtomWithConf() { { RWMol m; - m.addAtom(new Atom(6)); - m.addAtom(new Atom(6)); + m.addAtom(new Atom(6), true, true); + m.addAtom(new Atom(6), true, true); auto *conf = new Conformer(m.getNumAtoms()); m.addConformer(conf); - m.addAtom(new Atom(6)); + m.addAtom(new Atom(6), true, true); TEST_ASSERT(m.getConformer().getNumAtoms() == m.getNumAtoms()); } { RWMol m; - m.addAtom(new Atom(6)); - m.addAtom(new Atom(6)); + m.addAtom(new Atom(6), true, true); + m.addAtom(new Atom(6), true, true); auto *conf = new Conformer(m.getNumAtoms()); m.addConformer(conf); @@ -1002,9 +1005,9 @@ void testAddAtomWithConf() { { // make sure things are ok even if there is no conformer RWMol m; - m.addAtom(new Atom(6)); - m.addAtom(new Atom(6)); - m.addAtom(new Atom(6)); + m.addAtom(new Atom(6), true, true); + m.addAtom(new Atom(6), true, true); + m.addAtom(new Atom(6), true, true); TEST_ASSERT(m.getNumConformers() == 0); } @@ -1018,7 +1021,7 @@ void testIssue267() { { RWMol m; - m.addAtom(new Atom(0)); + m.addAtom(new Atom(0), true, true); m.updatePropertyCache(); TEST_ASSERT(m.getAtomWithIdx(0)->getImplicitValence() == 0); @@ -1026,9 +1029,9 @@ void testIssue267() { { RWMol m; - m.addAtom(new Atom(0)); + m.addAtom(new Atom(0), true, true); for (unsigned int i = 0; i < 8; ++i) { - m.addAtom(new Atom(1)); + m.addAtom(new Atom(1), true, true); m.addBond(0, i + 1, Bond::SINGLE); } m.updatePropertyCache(); @@ -1043,9 +1046,9 @@ void testIssue284() { { RWMol m; - m.addAtom(new Atom(6)); - m.addAtom(new Atom(6)); - m.addAtom(new Atom(6)); + m.addAtom(new Atom(6), true, true); + m.addAtom(new Atom(6), true, true); + m.addAtom(new Atom(6), true, true); m.addBond(0, 1, Bond::SINGLE); m.addBond(1, 2, Bond::SINGLE); m.updatePropertyCache(); @@ -1065,12 +1068,12 @@ void testAtomResidues() { { auto *m = new RWMol(); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(6), true, true); + m->addAtom(new Atom(6), true, true); m->addBond(0, 1, Bond::SINGLE); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(6), true, true); m->addBond(1, 2, Bond::SINGLE); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(6), true, true); m->addBond(2, 3, Bond::SINGLE); TEST_ASSERT(!(m->getAtomWithIdx(0)->getMonomerInfo())); @@ -1102,6 +1105,7 @@ void testAtomResidues() { ->getSerialNumber() == 3); TEST_ASSERT(!(m2->getAtomWithIdx(2)->getMonomerInfo())); TEST_ASSERT(!(m2->getAtomWithIdx(3)->getMonomerInfo())); + delete m2; } BOOST_LOG(rdInfoLog) << "Finished" << std::endl; } @@ -1113,7 +1117,7 @@ void testNeedsUpdatePropertyCache() { { RWMol m; - m.addAtom(new Atom(0)); + m.addAtom(new Atom(0), true, true); TEST_ASSERT(m.needsUpdatePropertyCache() == true); m.updatePropertyCache(); @@ -1123,13 +1127,13 @@ void testNeedsUpdatePropertyCache() { { RWMol m; - m.addAtom(new Atom(6)); + m.addAtom(new Atom(6), true, true); for (ROMol::AtomIterator atomIt = m.beginAtoms(); atomIt != m.endAtoms(); ++atomIt) { (*atomIt)->calcExplicitValence(false); (*atomIt)->calcImplicitValence(false); } - m.addAtom(new Atom(6)); + m.addAtom(new Atom(6), true, true); m.addBond(0, 1, Bond::SINGLE); TEST_ASSERT(m.needsUpdatePropertyCache() == true); m.updatePropertyCache(); @@ -1137,7 +1141,7 @@ void testNeedsUpdatePropertyCache() { } { RWMol m; - m.addAtom(new Atom(6)); + m.addAtom(new Atom(6), true, true); m.getAtomWithIdx(0)->calcExplicitValence(false); TEST_ASSERT(m.getAtomWithIdx(0)->needsUpdatePropertyCache()); m.getAtomWithIdx(0)->setNoImplicit(true); @@ -1158,7 +1162,7 @@ std::string qhelper(Atom::QUERYATOM_QUERY *q, unsigned int depth = 0) { } return res; } -} +} // namespace const char *m_als_mol = "\n" @@ -1214,6 +1218,8 @@ void testAtomListLineRoundTrip() { TEST_ASSERT(dynamic_cast(m->getAtomWithIdx(3))->Match(o)); TEST_ASSERT(dynamic_cast(m2->getAtomWithIdx(3))->Match(cl)); TEST_ASSERT(dynamic_cast(m2->getAtomWithIdx(3))->Match(o)); + delete cl; + delete o; delete m; delete m2; BOOST_LOG(rdInfoLog) << "Finished" << std::endl; @@ -1283,7 +1289,7 @@ void runblock(std::vector *pts, int idx) { TEST_ASSERT(pt->getAtomicNumber("N") == 7); TEST_ASSERT(pt->getAtomicNumber("O") == 8); }; -} +} // namespace void testGithub381() { BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl; BOOST_LOG(rdErrorLog) @@ -1349,8 +1355,8 @@ void testGithub1453() { RWMol m2; - m2.addAtom(new Atom(6)); - m2.addAtom(new Atom(6)); + m2.addAtom(new Atom(6), true, true); + m2.addAtom(new Atom(6), true, true); m2.addBond(0, 1, Bond::TRIPLE); TEST_ASSERT(m2.getNumAtoms() == 2); TEST_ASSERT(m2.getNumBonds() == 1); @@ -1473,6 +1479,7 @@ void testGithub1642() { } TEST_ASSERT(m2.getNumAtoms() == 0); + delete carbon; BOOST_LOG(rdErrorLog) << "Finished" << std::endl; } @@ -1485,9 +1492,8 @@ void testGithub1843() { RWMol *m = SmilesToMol("N1NN1"); m->clear(); MolOps::sanitizeMol(*m); - delete m; + delete m; BOOST_LOG(rdErrorLog) << "Finished" << std::endl; - } // ------------------------------------------------------------------- diff --git a/Code/GraphMol/testChirality.cpp b/Code/GraphMol/testChirality.cpp index a00199b36..f7a634b6a 100644 --- a/Code/GraphMol/testChirality.cpp +++ b/Code/GraphMol/testChirality.cpp @@ -112,6 +112,7 @@ void testMol1() { TEST_ASSERT(cip == "R"); MolOps::removeStereochemistry(*m); TEST_ASSERT(!m->getAtomWithIdx(1)->hasProp(common_properties::_CIPCode)); + delete m; BOOST_LOG(rdInfoLog) << "done" << std::endl; }; @@ -269,6 +270,7 @@ void testRoundTrip() { TEST_ASSERT(smi == smi2); #endif + delete m; BOOST_LOG(rdInfoLog) << "done" << std::endl; }; @@ -336,6 +338,7 @@ void testMol2() { m->getAtomWithIdx(3)->getProp(common_properties::_CIPCode, cip); TEST_ASSERT(cip == "R"); + delete m; BOOST_LOG(rdInfoLog) << "done" << std::endl; }; diff --git a/Code/GraphMol/testPickler.cpp b/Code/GraphMol/testPickler.cpp index c9b395d43..8adf5adeb 100644 --- a/Code/GraphMol/testPickler.cpp +++ b/Code/GraphMol/testPickler.cpp @@ -231,6 +231,8 @@ void test4() { TEST_ASSERT(!m3.getRingInfo()->isBondInRingOfSize(0, 4)); TEST_ASSERT(!m3.getRingInfo()->isBondInRingOfSize(4, 3)); TEST_ASSERT(m3.getRingInfo()->isBondInRingOfSize(4, 4)); + delete m1; + delete m2; BOOST_LOG(rdErrorLog) << "\tdone" << std::endl; } @@ -268,6 +270,9 @@ void testIssue164() { TEST_ASSERT(m3->getNumAtoms() == m4.getNumAtoms()); TEST_ASSERT(m3->getNumBonds() == m4.getNumBonds()); + delete m1; + delete m3; + BOOST_LOG(rdErrorLog) << "\tdone" << std::endl; } @@ -295,6 +300,8 @@ void testIssue219() { MolPickler::molFromPickle(pickle, *m2); TEST_ASSERT(m1->getNumAtoms() == m2->getNumAtoms()); TEST_ASSERT(m2->getConformer().getId() == 23); + delete m1; + delete m2; BOOST_LOG(rdErrorLog) << "\tdone" << std::endl; } @@ -324,6 +331,8 @@ void testIssue220() { m2->getBondWithIdx(i)->getStereoAtoms()); } + delete m1; + delete m2; BOOST_LOG(rdErrorLog) << "\tdone" << std::endl; } @@ -379,6 +388,7 @@ void testQueries() { TEST_ASSERT(m2); TEST_ASSERT(!m1->getAtomWithIdx(0)->Match(m2->getAtomWithIdx(0))); delete m1; + delete m2; // atom lists: smi = "[C,N,O]"; @@ -418,6 +428,7 @@ void testQueries() { TEST_ASSERT(!m1->getAtomWithIdx(0)->Match(m2->getAtomWithIdx(1))); TEST_ASSERT(!m1->getAtomWithIdx(0)->Match(m2->getAtomWithIdx(2))); delete m1; + delete m2; // more complex atom queries: smi = "[C&D2,N&D1]"; @@ -464,6 +475,7 @@ void testQueries() { m2 = SmilesToMol(smi); TEST_ASSERT(m2); TEST_ASSERT(!m1->getAtomWithIdx(0)->Match(m2->getAtomWithIdx(0))); + delete m1; delete m2; // basic recursive queries: @@ -493,6 +505,7 @@ void testQueries() { TEST_ASSERT(m2); TEST_ASSERT(SubstructMatch(*m2, *m1, matchV)); delete m1; + delete m2; smi = "[R2]"; m1 = SmartsToMol(smi); @@ -515,6 +528,7 @@ void testQueries() { TEST_ASSERT(m2); TEST_ASSERT(m1->getAtomWithIdx(0)->Match(m2->getAtomWithIdx(0))); TEST_ASSERT(!m1->getAtomWithIdx(0)->Match(m2->getAtomWithIdx(1))); + delete m1; delete m2; // basic bond queries: @@ -550,6 +564,7 @@ void testQueries() { m2 = SmilesToMol(smi); TEST_ASSERT(m2); TEST_ASSERT(SubstructMatch(*m2, *m1, matchV)); + delete m1; delete m2; smi = "[#6]-[#6]"; @@ -584,6 +599,7 @@ void testQueries() { m2 = SmilesToMol(smi); TEST_ASSERT(m2); TEST_ASSERT(!SubstructMatch(*m2, *m1, matchV)); + delete m1; delete m2; smi = "C=C"; @@ -596,6 +612,7 @@ void testQueries() { TEST_ASSERT(m1->getNumAtoms() == 2); smi = MolToSmarts(*m1); TEST_ASSERT(smi == "C=C"); + delete m1; smi = "C=[$(C=O)]"; m1 = SmartsToMol(smi); @@ -608,6 +625,7 @@ void testQueries() { smi = MolToSmarts(*m1); BOOST_LOG(rdErrorLog) << smi << std::endl; TEST_ASSERT(smi == "C=[$(C=O)]"); + delete m1; smi = "S(=O)(=O)-[C;H2]([F,Br,I,Cl])"; m1 = SmartsToMol(smi); @@ -620,6 +638,7 @@ void testQueries() { smi2 = MolToSmarts(*m1); BOOST_LOG(rdErrorLog) << smi << " " << smi2 << std::endl; TEST_ASSERT(smi == smi2); + delete m1; // more complex recursive queries: smi = "[$(C)]"; @@ -648,6 +667,7 @@ void testQueries() { TEST_ASSERT(m2); TEST_ASSERT(!SubstructMatch(*m2, *m1, matchV)); delete m1; + delete m2; // more complex recursive queries: smi = "[$(C=O);$(C-N)]"; @@ -669,9 +689,9 @@ void testQueries() { m2 = SmilesToMol(smi); TEST_ASSERT(m2); TEST_ASSERT(SubstructMatch(*m2, *m1, matchV)); + delete m1; delete m2; - delete m1; BOOST_LOG(rdErrorLog) << "\tdone" << std::endl; } @@ -691,6 +711,8 @@ void testRadicals() { TEST_ASSERT(m1->getNumAtoms() == m2->getNumAtoms()); TEST_ASSERT(m1->getNumBonds() == m2->getNumBonds()); TEST_ASSERT(m2->getAtomWithIdx(1)->getNumRadicalElectrons() == 1); + delete m1; + delete m2; BOOST_LOG(rdErrorLog) << "\tdone" << std::endl; } @@ -941,12 +963,14 @@ void testAtomResidues() { { auto *m = new RWMol(); - m->addAtom(new Atom(6)); - m->addAtom(new Atom(6)); + bool updateLabel = true; + bool takeOwnership = true; + m->addAtom(new Atom(6), updateLabel, takeOwnership); + m->addAtom(new Atom(6), updateLabel, takeOwnership); m->addBond(0, 1, Bond::SINGLE); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(6), updateLabel, takeOwnership); m->addBond(1, 2, Bond::SINGLE); - m->addAtom(new Atom(6)); + m->addAtom(new Atom(6), updateLabel, takeOwnership); m->addBond(2, 3, Bond::SINGLE); m->getAtomWithIdx(0)->setMonomerInfo( @@ -968,6 +992,7 @@ void testAtomResidues() { ->getSerialNumber() == 3); TEST_ASSERT(!(m2->getAtomWithIdx(2)->getMonomerInfo())); TEST_ASSERT(!(m2->getAtomWithIdx(3)->getMonomerInfo())); + delete m2; } BOOST_LOG(rdErrorLog) << "\tdone" << std::endl; } @@ -1216,7 +1241,8 @@ void testGithub1563() { << std::endl; RWMol m; auto *qa = new QueryAtom(); - qa->setQuery(makeAtomHeavyAtomDegreeQuery(3)); + auto *query = makeAtomHeavyAtomDegreeQuery(3); + qa->setQuery(query); m.addAtom(qa); TEST_ASSERT(m.getAtomWithIdx(0)->hasQuery()); TEST_ASSERT(m.getAtomWithIdx(0)->getQuery()->getDescription() == @@ -1231,7 +1257,7 @@ void testGithub1563() { TEST_ASSERT(nm2.getAtomWithIdx(0)->hasQuery()); TEST_ASSERT(nm2.getAtomWithIdx(0)->getQuery()->getDescription() == "AtomHeavyAtomDegree"); - + delete qa; BOOST_LOG(rdErrorLog) << "\tdone" << std::endl; } diff --git a/Code/Query/test.cpp b/Code/Query/test.cpp index 93a927d91..2cde70f70 100644 --- a/Code/Query/test.cpp +++ b/Code/Query/test.cpp @@ -43,8 +43,10 @@ void test1() { CHECK_INVARIANT(newQ->Match(1.001), ""); CHECK_INVARIANT(!newQ->Match(1.1), ""); CHECK_INVARIANT(!newQ->Match(-2), ""); + delete newQ; } + void test2() { cout << "Set" << endl; SetQuery q; @@ -63,6 +65,7 @@ void test2() { CHECK_INVARIANT(newQ->Match(1), ""); CHECK_INVARIANT(newQ->Match(3), ""); CHECK_INVARIANT(!newQ->Match(-3), ""); + delete newQ; } void test3() { @@ -87,6 +90,9 @@ void test3() { CHECK_INVARIANT(newQ->Match(1), ""); CHECK_INVARIANT(newQ->Match(3), ""); CHECK_INVARIANT(!newQ->Match(-3), ""); + + delete newQ; + delete q; } void test4() { @@ -111,6 +117,9 @@ void test4() { CHECK_INVARIANT(newQ->Match(1), ""); CHECK_INVARIANT(newQ->Match(3), ""); CHECK_INVARIANT(newQ->Match(-3), ""); + + delete newQ; + delete q; } void test5() { @@ -137,6 +146,9 @@ void test5() { CHECK_INVARIANT(!newQ->Match(1), ""); CHECK_INVARIANT(!newQ->Match(3), ""); CHECK_INVARIANT(newQ->Match(-3), ""); + + delete newQ; + delete q; } int foofun(double bar) { return int(floor(bar)); }; @@ -166,6 +178,9 @@ void test6() { CHECK_INVARIANT(newQ3->Match(6.0), ""); CHECK_INVARIANT(newQ3->Match(6.1), ""); CHECK_INVARIANT(!newQ3->Match(5.0), ""); + + delete newQ; + delete newQ3; } bool matchF(int v) { return v == 3; } @@ -275,6 +290,8 @@ void test7() { CHECK_INVARIANT(newQ->Match("1"), ""); CHECK_INVARIANT(newQ->Match("3"), ""); CHECK_INVARIANT(!newQ->Match("-3"), ""); + + delete newQ; } int main() { diff --git a/Code/RDBoost/Wrap/RDBase.cpp b/Code/RDBoost/Wrap/RDBase.cpp index 7848dff4e..c5948e443 100644 --- a/Code/RDBoost/Wrap/RDBase.cpp +++ b/Code/RDBoost/Wrap/RDBase.cpp @@ -55,7 +55,7 @@ void LogMessage(std::string spec, std::string msg) { } #else // FIX: get this more general - boost::logging::rdLogger *dest; + std::shared_ptr dest = nullptr; if (spec == "rdApp.error") { dest = rdErrorLog; } else if (spec == "rdApp.warning") { diff --git a/Code/RDGeneral/Dict.h b/Code/RDGeneral/Dict.h index 32b32212c..abd715946 100644 --- a/Code/RDGeneral/Dict.h +++ b/Code/RDGeneral/Dict.h @@ -40,8 +40,8 @@ class RDKIT_RDGENERAL_EXPORT Dict { RDValue val; Pair() : key(), val() {} - Pair(const std::string &s) : key(s), val() {} - Pair(const std::string &s, const RDValue &v) : key(s), val(v) {} + explicit Pair(std::string s) : key(std::move(s)), val() {} + Pair(std::string s, const RDValue &v) : key(std::move(s)), val(v) {} }; typedef std::vector DataType; @@ -105,10 +105,17 @@ class RDKIT_RDGENERAL_EXPORT Dict { } else { _data = other._data; } - _hasNonPodData = other._hasNonPodData; + _hasNonPodData = other._hasNonPodData; return *this; }; + //---------------------------------------------------------- + //! \brief Access to the underlying non-POD containment flag + //! This is meant to be used only in bulk updates of _data. + bool& getNonPODStatus() { + return _hasNonPodData; + } + //---------------------------------------------------------- //! \brief Access to the underlying data. const DataType &getData() const { return _data; } @@ -119,8 +126,8 @@ class RDKIT_RDGENERAL_EXPORT Dict { //! \brief Returns whether or not the dictionary contains a particular //! key. bool hasVal(const std::string &what) const { - for (size_t i = 0; i < _data.size(); ++i) { - if (_data[i].key == what) return true; + for (const auto& data : _data) { + if (data.key == what) return true; } return false; }; @@ -159,9 +166,9 @@ class RDKIT_RDGENERAL_EXPORT Dict { //! \overload template T getVal(const std::string &what) const { - for (size_t i = 0; i < _data.size(); ++i) { - if (_data[i].key == what) { - return from_rdvalue(_data[i].val); + for (auto& data : _data) { + if (data.key == what) { + return from_rdvalue(data.val); } } throw KeyErrorException(what); @@ -187,9 +194,9 @@ class RDKIT_RDGENERAL_EXPORT Dict { template bool getValIfPresent(const std::string &what, T &res) const { - for (size_t i = 0; i < _data.size(); ++i) { - if (_data[i].key == what) { - res = from_rdvalue(_data[i].val); + for (const auto& data : _data) { + if (data.key == what) { + res = from_rdvalue(data.val); return true; } } @@ -215,10 +222,10 @@ class RDKIT_RDGENERAL_EXPORT Dict { template void setVal(const std::string &what, T &val) { _hasNonPodData = true; - for (size_t i = 0; i < _data.size(); ++i) { - if (_data[i].key == what) { - RDValue::cleanup_rdvalue(_data[i].val); - _data[i].val = val; + for (auto&& data : _data) { + if (data.key == what) { + RDValue::cleanup_rdvalue(data.val); + data.val = val; return; } } @@ -228,10 +235,10 @@ class RDKIT_RDGENERAL_EXPORT Dict { template void setPODVal(const std::string &what, T val) { // don't change the hasNonPodData status - for (size_t i = 0; i < _data.size(); ++i) { - if (_data[i].key == what) { - RDValue::cleanup_rdvalue(_data[i].val); - _data[i].val = val; + for (auto&& data : _data) { + if (data.key == what) { + RDValue::cleanup_rdvalue(data.val); + data.val = val; return; } } @@ -285,8 +292,8 @@ class RDKIT_RDGENERAL_EXPORT Dict { //! void reset() { if (_hasNonPodData) { - for (size_t i = 0; i < _data.size(); ++i) { - RDValue::cleanup_rdvalue(_data[i].val); + for (auto&& data : _data) { + RDValue::cleanup_rdvalue(data.val); } } DataType data; diff --git a/Code/RDGeneral/RDLog.cpp b/Code/RDGeneral/RDLog.cpp index 06831fe16..b32dde705 100644 --- a/Code/RDGeneral/RDLog.cpp +++ b/Code/RDGeneral/RDLog.cpp @@ -15,19 +15,12 @@ #include #include -namespace { -// this is a "bit" of a hack to work around shared/static library problems -// on windows -boost::logging::rdLogger cerrLogger(&std::cerr); -boost::logging::rdLogger coutLogger(&std::cout); -} // namespace - -boost::logging::rdLogger *rdAppLog = nullptr; -boost::logging::rdLogger *rdDebugLog = nullptr; -boost::logging::rdLogger *rdInfoLog = &cerrLogger; -boost::logging::rdLogger *rdErrorLog = &cerrLogger; -boost::logging::rdLogger *rdWarningLog = &cerrLogger; -boost::logging::rdLogger *rdStatusLog = nullptr; +std::shared_ptr rdAppLog = nullptr; +std::shared_ptr rdDebugLog = nullptr; +std::shared_ptr rdInfoLog = nullptr; +std::shared_ptr rdErrorLog = nullptr; +std::shared_ptr rdWarningLog = nullptr; +std::shared_ptr rdStatusLog = nullptr; namespace boost { namespace logging { @@ -69,10 +62,10 @@ void disable_logs(const std::string &arg) { namespace RDLog { void InitLogs() { - rdDebugLog = new boost::logging::rdLogger(&std::cerr); - rdInfoLog = new boost::logging::rdLogger(&std::cout); - rdWarningLog = new boost::logging::rdLogger(&std::cerr); - rdErrorLog = new boost::logging::rdLogger(&std::cerr); + rdDebugLog = std::make_shared(&std::cerr); + rdInfoLog = std::make_shared(&std::cout); + rdWarningLog = std::make_shared(&std::cerr); + rdErrorLog = std::make_shared(&std::cerr); } std::ostream &toStream(std::ostream &logstrm) { time_t t = time(nullptr); diff --git a/Code/RDGeneral/RDLog.h b/Code/RDGeneral/RDLog.h index e510ba4fb..0cc4ad124 100644 --- a/Code/RDGeneral/RDLog.h +++ b/Code/RDGeneral/RDLog.h @@ -90,12 +90,12 @@ RDKIT_RDGENERAL_EXPORT std::ostream &toStream(std::ostream &); RDLog::toStream((__arg__->teestream) ? *(__arg__->teestream) \ : *(__arg__->dp_dest)) -RDKIT_RDGENERAL_EXPORT extern boost::logging::rdLogger *rdAppLog; -RDKIT_RDGENERAL_EXPORT extern boost::logging::rdLogger *rdDebugLog; -RDKIT_RDGENERAL_EXPORT extern boost::logging::rdLogger *rdInfoLog; -RDKIT_RDGENERAL_EXPORT extern boost::logging::rdLogger *rdErrorLog; -RDKIT_RDGENERAL_EXPORT extern boost::logging::rdLogger *rdWarningLog; -RDKIT_RDGENERAL_EXPORT extern boost::logging::rdLogger *rdStatusLog; +RDKIT_RDGENERAL_EXPORT extern std::shared_ptr rdAppLog; +RDKIT_RDGENERAL_EXPORT extern std::shared_ptr rdDebugLog; +RDKIT_RDGENERAL_EXPORT extern std::shared_ptr rdInfoLog; +RDKIT_RDGENERAL_EXPORT extern std::shared_ptr rdErrorLog; +RDKIT_RDGENERAL_EXPORT extern std::shared_ptr rdWarningLog; +RDKIT_RDGENERAL_EXPORT extern std::shared_ptr rdStatusLog; #else #define BOOST_LOG_NO_LIB diff --git a/Code/RDGeneral/StreamOps.h b/Code/RDGeneral/StreamOps.h index 4a0842085..ba2588237 100644 --- a/Code/RDGeneral/StreamOps.h +++ b/Code/RDGeneral/StreamOps.h @@ -457,34 +457,42 @@ inline void readRDStringVecValue(std::istream &ss, RDValue &value) { value = v; } -inline bool streamReadProp(std::istream &ss, Dict::Pair &pair) { +inline bool streamReadProp(std::istream &ss, Dict::Pair &pair, bool& dictHasNonPOD) { int version=0; streamRead(ss, pair.key, version); unsigned char type; streamRead(ss, type); switch(type) { - case DTags::StringTag: readRDValueString(ss, pair.val); break; case DTags::IntTag: readRDValue(ss, pair.val); break; case DTags::UnsignedIntTag: readRDValue(ss, pair.val); break; case DTags::BoolTag: readRDValue(ss, pair.val); break; case DTags::FloatTag: readRDValue(ss, pair.val); break; case DTags::DoubleTag: readRDValue(ss, pair.val); break; + case DTags::StringTag: + readRDValueString(ss, pair.val); + dictHasNonPOD = true; + break; case DTags::VecStringTag: readRDStringVecValue(ss, pair.val); + dictHasNonPOD = true; break; case DTags::VecIntTag: readRDVecValue(ss, pair.val); + dictHasNonPOD = true; break; case DTags::VecUIntTag: readRDVecValue(ss, pair.val); + dictHasNonPOD = true; break; case DTags::VecFloatTag: readRDVecValue(ss, pair.val); + dictHasNonPOD = true; break; case DTags::VecDoubleTag: readRDVecValue(ss, pair.val); + dictHasNonPOD = true; break; default: @@ -498,9 +506,10 @@ inline unsigned int streamReadProps(std::istream &ss, RDProps &props) { streamRead(ss, count); Dict &dict = props.getDict(); + dict.reset(); // Clear data before repopulating dict.getData().resize(count); for(unsigned index = 0; index > + fun:_ZNK5RDKit7RDProps7setPropINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEvRKS7_T_b + fun:_Z12yysmiles_lexP7YYSTYPEPvRi + fun:_Z14yysmiles_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPNSt7__cxx114listIjSaIjEEEPvRi + fun:_ZN5RDKit12_GLOBAL__N_117smiles_bond_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPNS_4BondE + fun:_ZN5RDKit6toBondERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RPNS_4BondEE +} +{ + memory indirectly lost 3 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 4 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN11schrodinger10BufferDataC1Em + fun:_ZN11schrodinger6Buffer4loadERPc + fun:_ZN11schrodinger3maeL24property_key_author_nameERNS_6BufferERPc + fun:_ZN11schrodinger3mae12property_keyB5cxx11ERNS_6BufferE + fun:_ZN11schrodinger3mae26BufferedIndexedBlockParser5parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmRNS_6BufferE + fun:_ZN11schrodinger3mae9MaeParser9blockBodyERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE + fun:_ZN11schrodinger3mae9MaeParser10outerBlockEv + fun:_ZN11schrodinger3mae6Reader4nextERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE + fun:_ZL12loadTemplateRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIP25sketcherMinimizerMoleculeSaIS9_EE.constprop.1036 + fun:_ZN17sketcherMinimizer13loadTemplatesEv + fun:_ZNK23CoordgenFragmentBuilder12findTemplateESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder31generateCoordinatesCentralRingsESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder10buildRingsEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder13buildFragmentEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder21initializeCoordinatesEP25sketcherMinimizerFragment + fun:_ZN17sketcherMinimizer19initializeFragmentsEv + fun:_ZN17sketcherMinimizer22runGenerateCoordinatesEv + fun:_ZN5RDKit8CoordGen9addCoordsINS_5ROMolEEEjRT_PKNS0_14CoordGenParamsE +} +{ + memory indirectly lost 5 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN11schrodinger10BufferDataC1Em + fun:_ZN11schrodinger6Buffer4loadERPc + fun:load + fun:MaeParser + fun:Reader + fun:_ZN5RDKit14MaeMolSupplierC1EPSibbb +} +{ + memory indirectly lost 6 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN11schrodinger10BufferDataC1Em + fun:_ZN11schrodinger6Buffer4loadERPc + fun:load + fun:MaeParser + fun:Reader + fun:_ZN5RDKit14MaeMolSupplierC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbb +} +{ + memory indirectly lost 7 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN11schrodinger10BufferDataC1Em + fun:_ZN11schrodinger6BufferC1Em + fun:_ZN11schrodinger6BufferC1ERSim + fun:MaeParser + fun:Reader + fun:_ZL12loadTemplateRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIP25sketcherMinimizerMoleculeSaIS9_EE.constprop.1036 + fun:_ZN17sketcherMinimizer13loadTemplatesEv + fun:_ZNK23CoordgenFragmentBuilder12findTemplateESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder31generateCoordinatesCentralRingsESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder10buildRingsEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder13buildFragmentEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder21initializeCoordinatesEP25sketcherMinimizerFragment + fun:_ZN17sketcherMinimizer19initializeFragmentsEv + fun:_ZN17sketcherMinimizer22runGenerateCoordinatesEv + fun:_ZN5RDKit8CoordGen9addCoordsINS_5ROMolEEEjRT_PKNS0_14CoordGenParamsE +} +{ + memory indirectly lost 8 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN11schrodinger6BufferC1ERSim + fun:MaeParser + fun:Reader + fun:_ZL12loadTemplateRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIP25sketcherMinimizerMoleculeSaIS9_EE.constprop.1036 + fun:_ZN17sketcherMinimizer13loadTemplatesEv + fun:_ZNK23CoordgenFragmentBuilder12findTemplateESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder31generateCoordinatesCentralRingsESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder10buildRingsEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder13buildFragmentEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder21initializeCoordinatesEP25sketcherMinimizerFragment + fun:_ZN17sketcherMinimizer19initializeFragmentsEv + fun:_ZN17sketcherMinimizer22runGenerateCoordinatesEv + fun:_ZN5RDKit8CoordGen9addCoordsINS_5ROMolEEEjRT_PKNS0_14CoordGenParamsE +} +{ + memory indirectly lost 9 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN11schrodinger6BufferC1ERSim + fun:MaeParser + fun:Reader + fun:_ZN5RDKit14MaeMolSupplierC1EPSibbb +} +{ + memory indirectly lost 10 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN11schrodinger6BufferC1ERSim + fun:MaeParser + fun:Reader + fun:_ZN5RDKit14MaeMolSupplierC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbb +} +{ + memory indirectly lost 11 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit17makeAtomNullQueryEv + fun:_Z12yysmarts_lexP7YYSTYPEPvRi + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_117smarts_bond_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPNS_4BondE + fun:_ZN5RDKit6toBondERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RPNS_4BondEE +} +{ + memory indirectly lost 12 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit19makeAtomSimpleQueryIN7Queries13EqualityQueryIiPKNS_4AtomELb1EEEEEPT_iPFiS5_ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE + fun:_ZN5RDKit17makeAtomTypeQueryEii + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE +} +{ + memory indirectly lost 13 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit19makeAtomSimpleQueryIN7Queries13EqualityQueryIiPKNS_4AtomELb1EEEEEPT_iPFiS5_ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE + fun:_ZN5RDKit17makeAtomTypeQueryEii + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_117smarts_atom_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPNS_4AtomE + fun:_ZN5RDKit6toAtomERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RPNS_4AtomEE +} +{ + memory indirectly lost 14 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit19makeAtomSimpleQueryIN7Queries13EqualityQueryIiPKNS_4AtomELb1EEEEEPT_iPFiS5_ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE + fun:_ZN5RDKit19makeAtomHCountQueryEi + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE +} +{ + memory indirectly lost 15 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit24makeBondOrderEqualsQueryENS_4Bond8BondTypeE + fun:_Z12yysmarts_lexP7YYSTYPEPvRi + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE +} +{ + memory indirectly lost 16 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit24makeBondOrderEqualsQueryENS_4Bond8BondTypeE + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_117smarts_bond_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPNS_4BondE + fun:_ZN5RDKit6toBondERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RPNS_4BondEE +} +{ + memory indirectly lost 17 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit5ROMol13initFromOtherERKS0_bi + fun:ROMol + fun:_ZNK5RDKit23RecursiveStructureQuery4copyEv + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 18 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit5ROMol7initMolEv + fun:ROMol + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 19 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit5ROMol7initMolEv + fun:ROMol + fun:_ZN5RDKit8SLNParse8startMolINS_4AtomEEEiRSt6vectorIPNS_5RWMolESaIS5_EEPT_b + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 20 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit5RWMol7addBondEjjNS_4Bond8BondTypeE + fun:_ZN5RDKit8SLNParse8startMolINS_4AtomEEEiRSt6vectorIPNS_5RWMolESaIS5_EEPT_b + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 21 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit8SLNParse13closeRingBondERSt6vectorIPNS_5RWMolESaIS3_EEjj + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 22 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit8SLNParse14addBranchToMolERSt6vectorIPNS_5RWMolESaIS3_EEjj + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 23 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit8SLNParse8startMolINS_4AtomEEEiRSt6vectorIPNS_5RWMolESaIS5_EEPT_b + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 24 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZN5RDKit9QueryAtom11expandQueryEPN7Queries5QueryIiPKNS_4AtomELb1EEENS1_18CompositeQueryTypeEb + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 25 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZNK5RDKit23RecursiveStructureQuery4copyEv + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 26 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZNK5RDKit4Atom4copyEv + fun:_ZN5RDKit5RWMol9insertMolERKNS_5ROMolE + fun:_ZN5RDKit8SLNParse14addBranchToMolINS_4BondEEEiRSt6vectorIPNS_5RWMolESaIS5_EEjjRPT_ + fun:_ZN5RDKit8SLNParse14addBranchToMolERSt6vectorIPNS_5RWMolESaIS3_EEjj + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 27 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZNK5RDKit4Bond4copyEv + fun:_ZN5RDKit5RWMol9insertMolERKNS_5ROMolE + fun:_ZN5RDKit8SLNParse14addBranchToMolINS_4BondEEEiRSt6vectorIPNS_5RWMolESaIS5_EEjjRPT_ + fun:_ZN5RDKit8SLNParse14addBranchToMolERSt6vectorIPNS_5RWMolESaIS3_EEjj + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 28 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZNK5RDKit9QueryAtom4copyEv + fun:_ZN5RDKit5ROMol13initFromOtherERKS0_bi + fun:ROMol + fun:_ZNK5RDKit23RecursiveStructureQuery4copyEv + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 29 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZNK7Queries13EqualityQueryIiPKN5RDKit4AtomELb1EE4copyEv + fun:QueryAtom + fun:_ZNK5RDKit9QueryAtom4copyEv + fun:_ZN5RDKit5ROMol13initFromOtherERKS0_bi + fun:ROMol + fun:_ZNK5RDKit23RecursiveStructureQuery4copyEv + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 30 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZNK7Queries13EqualityQueryIiPKN5RDKit4AtomELb1EE4copyEv + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 31 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag.isra.219 + fun:_M_construct_aux + fun:_M_construct + fun:basic_string + fun:setDescription + fun:_ZN5RDKit23RecursiveStructureQueryC1EPKNS_5ROMolEj + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 32 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag.isra.219 + fun:_M_construct_aux + fun:_M_construct + fun:basic_string + fun:setDescription + fun:_ZNK5RDKit23RecursiveStructureQuery4copyEv + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 33 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:__shared_count*> + fun:__shared_count*> + fun:__shared_ptr > + fun:shared_ptr > + fun:_ZN11schrodinger10BufferDataC1Em + fun:_ZN11schrodinger6Buffer4loadERPc + fun:_ZN11schrodinger3maeL24property_key_author_nameERNS_6BufferERPc + fun:_ZN11schrodinger3mae12property_keyB5cxx11ERNS_6BufferE + fun:_ZN11schrodinger3mae26BufferedIndexedBlockParser5parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmRNS_6BufferE + fun:_ZN11schrodinger3mae9MaeParser9blockBodyERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE + fun:_ZN11schrodinger3mae9MaeParser10outerBlockEv + fun:_ZN11schrodinger3mae6Reader4nextERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE + fun:_ZL12loadTemplateRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIP25sketcherMinimizerMoleculeSaIS9_EE.constprop.1036 + fun:_ZN17sketcherMinimizer13loadTemplatesEv + fun:_ZNK23CoordgenFragmentBuilder12findTemplateESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder31generateCoordinatesCentralRingsESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder10buildRingsEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder13buildFragmentEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder21initializeCoordinatesEP25sketcherMinimizerFragment + fun:_ZN17sketcherMinimizer19initializeFragmentsEv + fun:_ZN17sketcherMinimizer22runGenerateCoordinatesEv + fun:_ZN5RDKit8CoordGen9addCoordsINS_5ROMolEEEjRT_PKNS0_14CoordGenParamsE +} +{ + memory indirectly lost 34 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:__shared_count*> + fun:__shared_count*> + fun:__shared_ptr > + fun:shared_ptr > + fun:_ZN11schrodinger10BufferDataC1Em + fun:_ZN11schrodinger6Buffer4loadERPc + fun:load + fun:MaeParser + fun:Reader + fun:_ZN5RDKit14MaeMolSupplierC1EPSibbb +} +{ + memory indirectly lost 35 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:__shared_count*> + fun:__shared_count*> + fun:__shared_ptr > + fun:shared_ptr > + fun:_ZN11schrodinger10BufferDataC1Em + fun:_ZN11schrodinger6Buffer4loadERPc + fun:load + fun:MaeParser + fun:Reader + fun:_ZN5RDKit14MaeMolSupplierC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbb +} +{ + memory indirectly lost 36 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:__shared_count*> + fun:__shared_count*> + fun:__shared_ptr > + fun:shared_ptr > + fun:_ZN11schrodinger10BufferDataC1Em + fun:_ZN11schrodinger6BufferC1Em + fun:_ZN11schrodinger6BufferC1ERSim + fun:MaeParser + fun:Reader + fun:_ZL12loadTemplateRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIP25sketcherMinimizerMoleculeSaIS9_EE.constprop.1036 + fun:_ZN17sketcherMinimizer13loadTemplatesEv + fun:_ZNK23CoordgenFragmentBuilder12findTemplateESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder31generateCoordinatesCentralRingsESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder10buildRingsEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder13buildFragmentEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder21initializeCoordinatesEP25sketcherMinimizerFragment + fun:_ZN17sketcherMinimizer19initializeFragmentsEv + fun:_ZN17sketcherMinimizer22runGenerateCoordinatesEv + fun:_ZN5RDKit8CoordGen9addCoordsINS_5ROMolEEEjRT_PKNS0_14CoordGenParamsE +} +{ + memory indirectly lost 37 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:adjacency_list + fun:ROMol + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 38 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:adjacency_list + fun:ROMol + fun:_ZN5RDKit8SLNParse8startMolINS_4AtomEEEiRSt6vectorIPNS_5RWMolESaIS5_EEPT_b + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 39 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:adjacency_list + fun:ROMol + fun:_ZNK5RDKit23RecursiveStructureQuery4copyEv + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 40 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_M_default_append + fun:resize + fun:_ZN11schrodinger10BufferDataC1Em + fun:_ZN11schrodinger6Buffer4loadERPc + fun:_ZN11schrodinger3maeL24property_key_author_nameERNS_6BufferERPc + fun:_ZN11schrodinger3mae12property_keyB5cxx11ERNS_6BufferE + fun:_ZN11schrodinger3mae26BufferedIndexedBlockParser5parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmRNS_6BufferE + fun:_ZN11schrodinger3mae9MaeParser9blockBodyERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE + fun:_ZN11schrodinger3mae9MaeParser10outerBlockEv + fun:_ZN11schrodinger3mae6Reader4nextERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE + fun:_ZL12loadTemplateRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIP25sketcherMinimizerMoleculeSaIS9_EE.constprop.1036 + fun:_ZN17sketcherMinimizer13loadTemplatesEv + fun:_ZNK23CoordgenFragmentBuilder12findTemplateESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder31generateCoordinatesCentralRingsESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder10buildRingsEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder13buildFragmentEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder21initializeCoordinatesEP25sketcherMinimizerFragment + fun:_ZN17sketcherMinimizer19initializeFragmentsEv + fun:_ZN17sketcherMinimizer22runGenerateCoordinatesEv + fun:_ZN5RDKit8CoordGen9addCoordsINS_5ROMolEEEjRT_PKNS0_14CoordGenParamsE +} +{ + memory indirectly lost 41 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_M_default_append + fun:resize + fun:_ZN11schrodinger10BufferDataC1Em + fun:_ZN11schrodinger6Buffer4loadERPc + fun:load + fun:MaeParser + fun:Reader + fun:_ZN5RDKit14MaeMolSupplierC1EPSibbb +} +{ + memory indirectly lost 42 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_M_default_append + fun:resize + fun:_ZN11schrodinger10BufferDataC1Em + fun:_ZN11schrodinger6Buffer4loadERPc + fun:load + fun:MaeParser + fun:Reader + fun:_ZN5RDKit14MaeMolSupplierC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbb +} +{ + memory indirectly lost 43 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_M_default_append + fun:resize + fun:_ZN11schrodinger10BufferDataC1Em + fun:_ZN11schrodinger6BufferC1Em + fun:_ZN11schrodinger6BufferC1ERSim + fun:MaeParser + fun:Reader + fun:_ZL12loadTemplateRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIP25sketcherMinimizerMoleculeSaIS9_EE.constprop.1036 + fun:_ZN17sketcherMinimizer13loadTemplatesEv + fun:_ZNK23CoordgenFragmentBuilder12findTemplateESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder31generateCoordinatesCentralRingsESt6vectorIP21sketcherMinimizerRingSaIS2_EE + fun:_ZNK23CoordgenFragmentBuilder10buildRingsEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder13buildFragmentEP25sketcherMinimizerFragment + fun:_ZNK23CoordgenFragmentBuilder21initializeCoordinatesEP25sketcherMinimizerFragment + fun:_ZN17sketcherMinimizer19initializeFragmentsEv + fun:_ZN17sketcherMinimizer22runGenerateCoordinatesEv + fun:_ZN5RDKit8CoordGen9addCoordsINS_5ROMolEEEjRT_PKNS0_14CoordGenParamsE +} +{ + memory indirectly lost 44 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_ZNSt6vectorIN5RDKit4Dict4PairESaIS2_EE17_M_realloc_insertIJS2_EEEvN9__gnu_cxx17__normal_iteratorIPS2_S4_EEDpOT_ + fun:push_back + fun:_ZN5RDKit4Dict6setValISt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EEEEvRKS8_RT_ + fun:_ZN5RDKit5ROMol13initFromOtherERKS0_bi + fun:ROMol + fun:_ZNK5RDKit23RecursiveStructureQuery4copyEv + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 45 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_ZNSt6vectorIN5RDKit4Dict4PairESaIS2_EE17_M_realloc_insertIJS2_EEEvN9__gnu_cxx17__normal_iteratorIPS2_S4_EEDpOT_ + fun:push_back + fun:_ZN5RDKit4Dict6setValISt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EEEEvRKS8_RT_ + fun:_ZN5RDKit5ROMol7initMolEv + fun:ROMol + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 46 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_ZNSt6vectorIN5RDKit4Dict4PairESaIS2_EE17_M_realloc_insertIJS2_EEEvN9__gnu_cxx17__normal_iteratorIPS2_S4_EEDpOT_ + fun:push_back + fun:_ZN5RDKit4Dict6setValISt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EEEEvRKS8_RT_ + fun:_ZN5RDKit5ROMol7initMolEv + fun:ROMol + fun:_ZN5RDKit8SLNParse8startMolINS_4AtomEEEiRSt6vectorIPNS_5RWMolESaIS5_EEPT_b + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 47 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_ZNSt6vectorIN5RDKit4Dict4PairESaIS2_EE17_M_realloc_insertIJS2_EEEvN9__gnu_cxx17__normal_iteratorIPS2_S4_EEDpOT_ + fun:push_back + fun:setVal > + fun:_ZNK5RDKit7RDProps7setPropINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEvRKS7_T_b + fun:_Z12yysmiles_lexP7YYSTYPEPvRi + fun:_Z14yysmiles_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPNSt7__cxx114listIjSaIjEEEPvRi + fun:_ZN5RDKit12_GLOBAL__N_117smiles_bond_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERPNS_4BondE + fun:_ZN5RDKit6toBondERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RPNS_4BondEE +} +{ + memory indirectly lost 48 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_ZNSt6vectorIN5boost10shared_ptrIN7Queries5QueryIiPKN5RDKit4AtomELb1EEEEESaIS9_EE17_M_realloc_insertIJRKS9_EEEvN9__gnu_cxx17__normal_iteratorIPS9_SB_EEDpOT_ + fun:push_back + fun:addChild + fun:_ZN5RDKit9QueryAtom11expandQueryEPN7Queries5QueryIiPKNS_4AtomELb1EEENS1_18CompositeQueryTypeEb + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 49 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_ZNSt6vectorIN5boost6detail12adj_list_genINS0_14adjacency_listINS0_4vecSES4_NS0_11undirectedSEPN5RDKit4AtomEPNS6_4BondENS0_11no_propertyENS0_5listSEEES4_S4_S5_S8_SA_SB_SC_E6config13stored_vertexESaISG_EE17_M_default_appendEm + fun:resize + fun:add_vertex, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:_ZN5RDKit5ROMol7addAtomEPNS_4AtomEbb + fun:_ZN5RDKit5ROMol13initFromOtherERKS0_bi + fun:ROMol + fun:_ZNK5RDKit23RecursiveStructureQuery4copyEv + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 50 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_ZNSt6vectorIN5boost6detail12adj_list_genINS0_14adjacency_listINS0_4vecSES4_NS0_11undirectedSEPN5RDKit4AtomEPNS6_4BondENS0_11no_propertyENS0_5listSEEES4_S4_S5_S8_SA_SB_SC_E6config13stored_vertexESaISG_EE17_M_default_appendEm + fun:resize + fun:add_vertex, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:_ZN5RDKit5ROMol7addAtomEPNS_4AtomEbb + fun:addAtom + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 51 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_ZNSt6vectorIN5boost6detail12adj_list_genINS0_14adjacency_listINS0_4vecSES4_NS0_11undirectedSEPN5RDKit4AtomEPNS6_4BondENS0_11no_propertyENS0_5listSEEES4_S4_S5_S8_SA_SB_SC_E6config13stored_vertexESaISG_EE17_M_default_appendEm + fun:resize + fun:add_vertex, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:_ZN5RDKit5ROMol7addAtomEPNS_4AtomEbb + fun:addAtom + fun:_ZN5RDKit5RWMol9insertMolERKNS_5ROMolE + fun:_ZN5RDKit8SLNParse14addBranchToMolINS_4BondEEEiRSt6vectorIPNS_5RWMolESaIS5_EEjjRPT_ + fun:_ZN5RDKit8SLNParse14addBranchToMolERSt6vectorIPNS_5RWMolESaIS3_EEjj + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 52 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_ZNSt6vectorIN5boost6detail16stored_edge_iterImSt14_List_iteratorINS0_9list_edgeImPN5RDKit4BondEEEES7_EESaISA_EE17_M_realloc_insertIJSA_EEEvN9__gnu_cxx17__normal_iteratorIPSA_SC_EEDpOT_ + fun:push_back + fun:push_dispatch >, RDKit::Bond*>, std::allocator >, RDKit::Bond*> > >, boost::detail::stored_edge_iter >, RDKit::Bond*> > + fun:push >, RDKit::Bond*>, std::allocator >, RDKit::Bond*> > >, boost::detail::stored_edge_iter >, RDKit::Bond*> > + fun:add_edge, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> + fun:add_edge, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:add_edge, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:_ZN5RDKit5ROMol7addBondEPNS_4BondEb + fun:addBond + fun:_ZN5RDKit5RWMol9insertMolERKNS_5ROMolE + fun:_ZN5RDKit8SLNParse14addBranchToMolINS_4BondEEEiRSt6vectorIPNS_5RWMolESaIS5_EEjjRPT_ + fun:_ZN5RDKit8SLNParse14addBranchToMolERSt6vectorIPNS_5RWMolESaIS3_EEjj + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 53 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_ZNSt6vectorIN5boost6detail16stored_edge_iterImSt14_List_iteratorINS0_9list_edgeImPN5RDKit4BondEEEES7_EESaISA_EE17_M_realloc_insertIJSA_EEEvN9__gnu_cxx17__normal_iteratorIPSA_SC_EEDpOT_ + fun:push_back + fun:push_dispatch >, RDKit::Bond*>, std::allocator >, RDKit::Bond*> > >, boost::detail::stored_edge_iter >, RDKit::Bond*> > + fun:push >, RDKit::Bond*>, std::allocator >, RDKit::Bond*> > >, boost::detail::stored_edge_iter >, RDKit::Bond*> > + fun:add_edge, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> + fun:add_edge, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:add_edge, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:_ZN5RDKit5ROMol7addBondEPNS_4BondEb + fun:addBond + fun:_ZN5RDKit8SLNParse12_GLOBAL__N_112addBondToMolINS_4BondEEEvPNS_5RWMolEPT_ + fun:_ZN5RDKit8SLNParse14addBranchToMolINS_4BondEEEiRSt6vectorIPNS_5RWMolESaIS5_EEjjRPT_ + fun:_ZN5RDKit8SLNParse14addBranchToMolERSt6vectorIPNS_5RWMolESaIS3_EEjj + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 54 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_allocate + fun:_ZNSt6vectorIN5boost6detail16stored_edge_iterImSt14_List_iteratorINS0_9list_edgeImPN5RDKit4BondEEEES7_EESaISA_EE17_M_realloc_insertIJSA_EEEvN9__gnu_cxx17__normal_iteratorIPSA_SC_EEDpOT_ + fun:push_back + fun:push_dispatch >, RDKit::Bond*>, std::allocator >, RDKit::Bond*> > >, boost::detail::stored_edge_iter >, RDKit::Bond*> > + fun:push >, RDKit::Bond*>, std::allocator >, RDKit::Bond*> > >, boost::detail::stored_edge_iter >, RDKit::Bond*> > + fun:add_edge, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> + fun:add_edge, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:add_edge, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:_ZN5RDKit5RWMol7addBondEjjNS_4Bond8BondTypeE + fun:_ZN5RDKit8SLNParse8startMolINS_4AtomEEEiRSt6vectorIPNS_5RWMolESaIS5_EEPT_b + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 55 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_get_node + fun:_M_create_node + fun:_M_insert + fun:push_back + fun:replaceAtomBookmark + fun:_ZN5RDKit5ROMol7addAtomEPNS_4AtomEbb + fun:addAtom + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 56 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_get_node + fun:_M_create_node + fun:_M_insert + fun:push_back + fun:replaceAtomBookmark + fun:_ZN5RDKit5ROMol7addAtomEPNS_4AtomEbb + fun:addAtom + fun:_ZN5RDKit8SLNParse8startMolINS_4AtomEEEiRSt6vectorIPNS_5RWMolESaIS5_EEPT_b + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 57 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_get_node + fun:_M_create_node + fun:_M_insert + fun:push_back + fun:setBondBookmark + fun:_ZN5RDKit8SLNParse14addBranchToMolINS_4BondEEEiRSt6vectorIPNS_5RWMolESaIS5_EEjjRPT_ + fun:_ZN5RDKit8SLNParse14addBranchToMolERSt6vectorIPNS_5RWMolESaIS3_EEjj + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 58 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_get_node + fun:_M_create_node&> + fun:_M_insert&> + fun:push_back + fun:push_dispatch, std::allocator > >, boost::list_edge&> + fun:push, std::allocator > >, boost::list_edge&> + fun:add_edge, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> + fun:add_edge, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:add_edge, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:_ZN5RDKit5ROMol7addBondEPNS_4BondEb + fun:addBond + fun:_ZN5RDKit5RWMol9insertMolERKNS_5ROMolE + fun:_ZN5RDKit8SLNParse14addBranchToMolINS_4BondEEEiRSt6vectorIPNS_5RWMolESaIS5_EEjjRPT_ + fun:_ZN5RDKit8SLNParse14addBranchToMolERSt6vectorIPNS_5RWMolESaIS3_EEjj + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 59 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_get_node + fun:_M_create_node&> + fun:_M_insert&> + fun:push_back + fun:push_dispatch, std::allocator > >, boost::list_edge&> + fun:push, std::allocator > >, boost::list_edge&> + fun:add_edge, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> + fun:add_edge, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:add_edge, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:_ZN5RDKit5ROMol7addBondEPNS_4BondEb + fun:addBond + fun:_ZN5RDKit8SLNParse12_GLOBAL__N_112addBondToMolINS_4BondEEEvPNS_5RWMolEPT_ + fun:_ZN5RDKit8SLNParse14addBranchToMolINS_4BondEEEiRSt6vectorIPNS_5RWMolESaIS5_EEjjRPT_ + fun:_ZN5RDKit8SLNParse14addBranchToMolERSt6vectorIPNS_5RWMolESaIS3_EEjj + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 60 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_get_node + fun:_M_create_node&> + fun:_M_insert&> + fun:push_back + fun:push_dispatch, std::allocator > >, boost::list_edge&> + fun:push, std::allocator > >, boost::list_edge&> + fun:add_edge, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> + fun:add_edge, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:add_edge, boost::detail::adj_list_gen, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config, boost::undirected_graph_helper, boost::vecS, boost::vecS, boost::undirectedS, RDKit::Atom*, RDKit::Bond*, boost::no_property, boost::listS>::config> > + fun:_ZN5RDKit5RWMol7addBondEjjNS_4Bond8BondTypeE + fun:_ZN5RDKit8SLNParse8startMolINS_4AtomEEEiRSt6vectorIPNS_5RWMolESaIS5_EEPT_b + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 61 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_get_node + fun:_M_create_node, std::tuple<> > + fun:_ZNSt8_Rb_treeIiSt4pairIKiNSt7__cxx114listIPN5RDKit4AtomESaIS6_EEEESt10_Select1stIS9_ESt4lessIiESaIS9_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESK_IJEEEEESt17_Rb_tree_iteratorIS9_ESt23_Rb_tree_const_iteratorIS9_EDpOT_.isra.588 + fun:operator[] + fun:replaceAtomBookmark + fun:_ZN5RDKit5ROMol7addAtomEPNS_4AtomEbb + fun:addAtom + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 62 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_get_node + fun:_M_create_node, std::tuple<> > + fun:_ZNSt8_Rb_treeIiSt4pairIKiNSt7__cxx114listIPN5RDKit4AtomESaIS6_EEEESt10_Select1stIS9_ESt4lessIiESaIS9_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESK_IJEEEEESt17_Rb_tree_iteratorIS9_ESt23_Rb_tree_const_iteratorIS9_EDpOT_.isra.588 + fun:operator[] + fun:replaceAtomBookmark + fun:_ZN5RDKit5ROMol7addAtomEPNS_4AtomEbb + fun:addAtom + fun:_ZN5RDKit8SLNParse8startMolINS_4AtomEEEiRSt6vectorIPNS_5RWMolESaIS5_EEPT_b + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 63 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:allocate + fun:allocate + fun:_M_get_node + fun:_M_create_node, std::tuple<> > + fun:_ZNSt8_Rb_treeIiSt4pairIKiNSt7__cxx114listIPN5RDKit4BondESaIS6_EEEESt10_Select1stIS9_ESt4lessIiESaIS9_EE22_M_emplace_hint_uniqueIJRKSt21piecewise_construct_tSt5tupleIJRS1_EESK_IJEEEEESt17_Rb_tree_iteratorIS9_ESt23_Rb_tree_const_iteratorIS9_EDpOT_.isra.407 + fun:operator[] + fun:setBondBookmark + fun:_ZN5RDKit8SLNParse14addBranchToMolINS_4BondEEEiRSt6vectorIPNS_5RWMolESaIS5_EEjjRPT_ + fun:_ZN5RDKit8SLNParse14addBranchToMolERSt6vectorIPNS_5RWMolESaIS3_EEjj + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 64 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:getStereoAtoms + fun:_ZN5RDKit5RWMol9insertMolERKNS_5ROMolE + fun:_ZN5RDKit8SLNParse14addBranchToMolINS_4BondEEEiRSt6vectorIPNS_5RWMolESaIS5_EEjjRPT_ + fun:_ZN5RDKit8SLNParse14addBranchToMolERSt6vectorIPNS_5RWMolESaIS3_EEjj + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 65 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:shared_count > + fun:sp_pointer_construct, Queries::Query > + fun:shared_ptr > + fun:_ZN5RDKit9QueryAtom11expandQueryEPN7Queries5QueryIiPKNS_4AtomELb1EEENS1_18CompositeQueryTypeEb + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 66 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:shared_count + fun:sp_pointer_construct + fun:shared_ptr + fun:reset + fun:_ZNK5RDKit23RecursiveStructureQuery4copyEv + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 67 + Memcheck:Leak + match-leak-kinds: indirect + fun:_Znwm + fun:shared_count + fun:sp_pointer_construct + fun:shared_ptr + fun:reset + fun:setQueryMol + fun:_ZN5RDKit23RecursiveStructureQueryC1EPKNS_5ROMolEj + fun:_Z14yysmarts_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EERPNS2_4AtomERPNS2_4BondEPvRi + fun:_ZN5RDKit12_GLOBAL__N_112smarts_parseERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt6vectorIPNS_5RWMolESaISB_EE + fun:_ZN5RDKit5toMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPFiS7_RSt6vectorIPNS_5RWMolESaISA_EEES7_ + fun:_ZN5RDKit11SmartsToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEibPSt3mapIS5_S5_St4lessIS5_ESaISt4pairIS6_S5_EEE + fun:_ZN5RDKit5Local19expandAndTestSmartsERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt3mapIS6_S6_St4lessIS6_ESaISt4pairIKS6_S6_EEE + fun:_ZN5RDKit5Local13parseAtomTypeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERSt3mapIS6_S6_St4lessIS6_ESaISt4pairIS7_S6_EEERKj +} +{ + memory indirectly lost 68 + Memcheck:Leak + match-leak-kinds: indirect + fun:malloc + fun:_Z17yysln__scan_bytesPKcmPv + fun:_Z16setup_sln_stringRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 69 + Memcheck:Leak + match-leak-kinds: indirect + fun:malloc + fun:_Z18yysln__scan_bufferPcmPv + fun:_Z17yysln__scan_bytesPKcmPv + fun:_Z16setup_sln_stringRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 70 + Memcheck:Leak + match-leak-kinds: indirect + fun:malloc + fun:_ZL13yy_push_stateiPv + fun:_Z9yysln_lexP7YYSTYPEPv + fun:_Z11yysln_parsePKcPSt6vectorIPN5RDKit5RWMolESaIS4_EEbPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} +{ + memory indirectly lost 71 + Memcheck:Leak + match-leak-kinds: indirect + fun:malloc + fun:_ZL25yysln_ensure_buffer_stackPv + fun:_Z23yysln__switch_to_bufferP15yy_buffer_statePv + fun:_Z18yysln__scan_bufferPcmPv + fun:_Z17yysln__scan_bytesPKcmPv + fun:_Z16setup_sln_stringRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPv + fun:_Z9sln_parseRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbRSt6vectorIPN5RDKit5RWMolESaISA_EE + fun:_ZN5RDKit8SLNParse5toMolENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi + fun:_ZN5RDKit8SLNToMolERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbi +} diff --git a/External/AvalonTools/test1.cpp b/External/AvalonTools/test1.cpp index 667237805..340f57795 100755 --- a/External/AvalonTools/test1.cpp +++ b/External/AvalonTools/test1.cpp @@ -410,6 +410,7 @@ void testInitStruChk() { int errs = AvalonTools::initCheckMol(struchk_init); TEST_ASSERT(!errs); RDKit::ROMOL_SPTR m = AvalonTools::checkMol(errs, "c1ccccc1", true); + AvalonTools::closeCheckMolFiles(); TEST_ASSERT(errs == 0); } BOOST_LOG(rdInfoLog) << "done" << std::endl; diff --git a/External/FreeSASA/testFreeSASA.cpp b/External/FreeSASA/testFreeSASA.cpp index 6c79f3d14..ac612d653 100644 --- a/External/FreeSASA/testFreeSASA.cpp +++ b/External/FreeSASA/testFreeSASA.cpp @@ -31,6 +31,7 @@ #include "RDFreeSASA.h" #include +#include #include #include @@ -398,10 +399,13 @@ void testPDB() { std::cerr << " polar " << polard << std::endl; std::cerr << " apolar " << apolard << std::endl; - TEST_ASSERT(fabs(polard + apolard - 5000.340175) < 1e-5); - + delete polar; + delete apolar; delete m; delete mnoh; + + TEST_ASSERT(fabs(polard + apolard - 5000.340175) < 1e-5); + BOOST_LOG(rdInfoLog) << "Done" << std::endl; } diff --git a/External/INCHI-API/test.cpp b/External/INCHI-API/test.cpp index ea8501536..2191b7768 100644 --- a/External/INCHI-API/test.cpp +++ b/External/INCHI-API/test.cpp @@ -51,7 +51,7 @@ void runblock(const std::vector &mols, unsigned int count, } } }; -} +} // namespace #include #include @@ -165,10 +165,11 @@ void testGithubIssue8() { ROMol *m2 = InchiToMol(inchi, tmp2); TEST_ASSERT(m2); std::string smi = MolToSmiles(*m2, true); - TEST_ASSERT(smi == "[H]/N=c1\\cc2oc3cc(N)ccc3c(-c3ccccc3C(=O)O)c-2cc1[125I]"); + TEST_ASSERT(smi == + "[H]/N=c1\\cc2oc3cc(N)ccc3c(-c3ccccc3C(=O)O)c-2cc1[125I]"); inchi = MolToInchi(*m2, tmp2); - TEST_ASSERT(inchi == + TEST_ASSERT(inchi == "InChI=1S/C20H13IN2O3/" "c21-15-8-14-18(9-16(15)23)26-17-7-10(22)5-6-13(17)19(14)11-3-" "1-2-4-12(11)20(24)25/h1-9,23H,22H2,(H,24,25)/b23-16+/i21-2"); @@ -302,6 +303,7 @@ void testGithubIssue437() { std::string smi2 = MolToSmiles(*m, true); // std::cerr<<" smi1: "<