From a75018fe385b0a36901bcb074ebbca0c4e84a9d5 Mon Sep 17 00:00:00 2001 From: Greg Landrum Date: Thu, 9 Jan 2020 22:07:55 +0100 Subject: [PATCH] Cleanups and additional tests to improve test coverage (#2852) * disable builds of the StructChecker code by default * operator"" _smarts() doesn't need to catch sanitization errors * remove unused function * turn back on some tests that shouldn't have been disabled * Remove unused code from SMARTS parser and simplify a bit SmilesParseOps::AddFragToMol is now used only from the SMARTS parser, so we can simplify the API * Removes obsolete special case code for SMARTS This was relevant when organic atoms in SMARTS queries were stored as two-part queries. * improve SMARTS testing make sure we can generate SMARTS from all the examples and then parse that again. * Fixes #2814 * Fixes #2815 * some additional smarts tests to improve coverage * test copy ctor and getPos * remove obsolete test_list files * include tests for the morgan invariant generators * more cleanups and coverage improvements * remove files that were mistakenly added --- CMakeLists.txt | 1 + Code/ChemicalFeatures/Wrap/test_list.py | 9 --- .../ChemicalFeatures/testChemicalFeatures.cpp | 22 ++++-- Code/ChemicalFeatures/test_list.py | 7 -- .../MetricMatrixCalc/Wrap/test_list.py | 9 --- Code/DataManip/MetricMatrixCalc/test_list.py | 9 --- Code/DataStructs/Wrap/test_list.py | 12 ---- Code/DataStructs/test_list.py | 9 --- .../RDKit/Basement/BinaryIO/test_list.py | 9 --- Code/DistGeom/Wrap/test_list.py | 9 --- Code/DistGeom/test_list.py | 14 ---- Code/Features/test_list.py | 11 --- Code/ForceField/UFF/test_list.py | 11 --- Code/ForceField/Wrap/test_list.py | 9 --- Code/Geometry/Wrap/test_list.py | 9 --- Code/Geometry/test_list.py | 12 ---- Code/GraphMol/CMakeLists.txt | 3 + Code/GraphMol/ChemReactions/Wrap/test_list.py | 15 ----- Code/GraphMol/ChemReactions/test_list.py | 14 ---- Code/GraphMol/ChemTransforms/test_list.py | 11 --- Code/GraphMol/Depictor/Wrap/test_list.py | 9 --- Code/GraphMol/Depictor/test_list.py | 9 --- Code/GraphMol/Descriptors/Wrap/test_list.py | 9 --- Code/GraphMol/Descriptors/test_list.py | 11 --- .../DistGeomHelpers/Wrap/test_list.py | 9 --- Code/GraphMol/DistGeomHelpers/test_list.py | 14 ---- Code/GraphMol/FileParsers/test_list.py | 15 ----- Code/GraphMol/FilterCatalog/Wrap/test_list.py | 9 --- .../Fingerprints/Wrap/testGenerators.py | 31 ++++++++- Code/GraphMol/Fingerprints/Wrap/test_list.py | 9 --- Code/GraphMol/Fingerprints/test_list.py | 9 --- .../ForceFieldHelpers/CrystalFF/test_list.py | 7 -- .../ForceFieldHelpers/MMFF/test_list.py | 11 --- .../ForceFieldHelpers/UFF/test_list.py | 11 --- .../ForceFieldHelpers/Wrap/test_list.py | 9 --- Code/GraphMol/FragCatalog/Wrap/test_list.py | 9 --- Code/GraphMol/FragCatalog/test_list.py | 9 --- Code/GraphMol/MolAlign/Wrap/test_list.py | 9 --- Code/GraphMol/MolAlign/test_list.py | 14 ---- Code/GraphMol/MolCatalog/Wrap/test_list.py | 9 --- Code/GraphMol/MolCatalog/test_list.py | 9 --- .../MolChemicalFeatures/Wrap/test_list.py | 9 --- .../GraphMol/MolChemicalFeatures/test_list.py | 14 ---- Code/GraphMol/MolDraw2D/Wrap/test_list.py | 9 --- Code/GraphMol/MolTransforms/Wrap/test_list.py | 9 --- Code/GraphMol/MolTransforms/test_list.py | 14 ---- .../GraphMol/PartialCharges/Wrap/test_list.py | 9 --- Code/GraphMol/SLNParse/Wrap/test_list.py | 11 --- Code/GraphMol/SLNParse/test_list.py | 17 ----- Code/GraphMol/ShapeHelpers/Wrap/test_list.py | 9 --- .../ShapeHelpers/testShapeHelpers.cpp | 25 +------ Code/GraphMol/ShapeHelpers/test_list.py | 14 ---- Code/GraphMol/SmilesParse/SmartsWrite.cpp | 64 +----------------- Code/GraphMol/SmilesParse/SmilesParse.h | 9 +-- Code/GraphMol/SmilesParse/SmilesParseOps.cpp | 67 ++++--------------- Code/GraphMol/SmilesParse/SmilesParseOps.h | 7 +- Code/GraphMol/SmilesParse/catch_tests.cpp | 16 ++++- .../GraphMol/SmilesParse/smarts.tab.cpp.cmake | 2 +- Code/GraphMol/SmilesParse/smarts.yy | 2 +- Code/GraphMol/SmilesParse/smatest.cpp | 22 +++--- Code/GraphMol/SmilesParse/test_list.py | 9 --- Code/GraphMol/Subgraphs/test_list.py | 12 ---- Code/GraphMol/Substruct/test_list.py | 9 --- Code/GraphMol/Wrap/rdmolfiles.cpp | 62 ++++++++--------- Code/GraphMol/Wrap/rdmolops.cpp | 8 +-- Code/GraphMol/Wrap/rough_test.py | 4 ++ Code/GraphMol/Wrap/test_list.py | 12 ---- Code/GraphMol/test_list.py | 49 -------------- Code/ML/InfoTheory/Wrap/test_list.py | 9 --- Code/ML/test_list.py | 12 ---- Code/Numerics/Alignment/Wrap/test_list.py | 9 --- Code/Numerics/Alignment/test_list.py | 14 ---- Code/Numerics/EigenSolvers/test_list.py | 11 --- Code/Numerics/Optimizer/test_list.py | 11 --- Code/Numerics/testMatrices.cpp | 39 ++++++++++- Code/Numerics/test_list.py | 12 ---- Code/Query/test_list.py | 9 --- Code/RDGeneral/test_list.py | 9 --- Code/SimDivPickers/Wrap/test_list.py | 9 --- Code/test_list.py | 28 -------- 80 files changed, 172 insertions(+), 930 deletions(-) delete mode 100644 Code/ChemicalFeatures/Wrap/test_list.py delete mode 100644 Code/ChemicalFeatures/test_list.py delete mode 100755 Code/DataManip/MetricMatrixCalc/Wrap/test_list.py delete mode 100755 Code/DataManip/MetricMatrixCalc/test_list.py delete mode 100755 Code/DataStructs/Wrap/test_list.py delete mode 100755 Code/DataStructs/test_list.py delete mode 100755 Code/Demos/RDKit/Basement/BinaryIO/test_list.py delete mode 100644 Code/DistGeom/Wrap/test_list.py delete mode 100755 Code/DistGeom/test_list.py delete mode 100644 Code/Features/test_list.py delete mode 100644 Code/ForceField/UFF/test_list.py delete mode 100644 Code/ForceField/Wrap/test_list.py delete mode 100644 Code/Geometry/Wrap/test_list.py delete mode 100644 Code/Geometry/test_list.py delete mode 100644 Code/GraphMol/ChemReactions/Wrap/test_list.py delete mode 100644 Code/GraphMol/ChemReactions/test_list.py delete mode 100644 Code/GraphMol/ChemTransforms/test_list.py delete mode 100755 Code/GraphMol/Depictor/Wrap/test_list.py delete mode 100755 Code/GraphMol/Depictor/test_list.py delete mode 100644 Code/GraphMol/Descriptors/Wrap/test_list.py delete mode 100644 Code/GraphMol/Descriptors/test_list.py delete mode 100644 Code/GraphMol/DistGeomHelpers/Wrap/test_list.py delete mode 100755 Code/GraphMol/DistGeomHelpers/test_list.py delete mode 100755 Code/GraphMol/FileParsers/test_list.py delete mode 100644 Code/GraphMol/FilterCatalog/Wrap/test_list.py delete mode 100644 Code/GraphMol/Fingerprints/Wrap/test_list.py delete mode 100755 Code/GraphMol/Fingerprints/test_list.py delete mode 100755 Code/GraphMol/ForceFieldHelpers/CrystalFF/test_list.py delete mode 100755 Code/GraphMol/ForceFieldHelpers/MMFF/test_list.py delete mode 100755 Code/GraphMol/ForceFieldHelpers/UFF/test_list.py delete mode 100644 Code/GraphMol/ForceFieldHelpers/Wrap/test_list.py delete mode 100755 Code/GraphMol/FragCatalog/Wrap/test_list.py delete mode 100755 Code/GraphMol/FragCatalog/test_list.py delete mode 100644 Code/GraphMol/MolAlign/Wrap/test_list.py delete mode 100644 Code/GraphMol/MolAlign/test_list.py delete mode 100755 Code/GraphMol/MolCatalog/Wrap/test_list.py delete mode 100755 Code/GraphMol/MolCatalog/test_list.py delete mode 100644 Code/GraphMol/MolChemicalFeatures/Wrap/test_list.py delete mode 100644 Code/GraphMol/MolChemicalFeatures/test_list.py delete mode 100644 Code/GraphMol/MolDraw2D/Wrap/test_list.py delete mode 100644 Code/GraphMol/MolTransforms/Wrap/test_list.py delete mode 100755 Code/GraphMol/MolTransforms/test_list.py delete mode 100755 Code/GraphMol/PartialCharges/Wrap/test_list.py delete mode 100644 Code/GraphMol/SLNParse/Wrap/test_list.py delete mode 100755 Code/GraphMol/SLNParse/test_list.py delete mode 100644 Code/GraphMol/ShapeHelpers/Wrap/test_list.py delete mode 100644 Code/GraphMol/ShapeHelpers/test_list.py delete mode 100755 Code/GraphMol/SmilesParse/test_list.py delete mode 100755 Code/GraphMol/Subgraphs/test_list.py delete mode 100755 Code/GraphMol/Substruct/test_list.py delete mode 100755 Code/GraphMol/Wrap/test_list.py delete mode 100755 Code/GraphMol/test_list.py delete mode 100755 Code/ML/InfoTheory/Wrap/test_list.py delete mode 100755 Code/ML/test_list.py delete mode 100644 Code/Numerics/Alignment/Wrap/test_list.py delete mode 100755 Code/Numerics/Alignment/test_list.py delete mode 100755 Code/Numerics/EigenSolvers/test_list.py delete mode 100755 Code/Numerics/Optimizer/test_list.py delete mode 100755 Code/Numerics/test_list.py delete mode 100755 Code/Query/test_list.py delete mode 100755 Code/RDGeneral/test_list.py delete mode 100755 Code/SimDivPickers/Wrap/test_list.py delete mode 100755 Code/test_list.py diff --git a/CMakeLists.txt b/CMakeLists.txt index a0e804758..86f157bab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ option(RDK_BUILD_FREESASA_SUPPORT "build the rdkit freesasa wrapper" OFF ) option(RDK_BUILD_COORDGEN_SUPPORT "build the rdkit coordgen wrapper" ON ) option(RDK_BUILD_MOLINTERCHANGE_SUPPORT "build in support for CommonChem molecule interchange" ON ) option(RDK_BUILD_YAEHMOP_SUPPORT "build support for the YAeHMOP wrapper" OFF) +option(RDK_BUILD_STRUCTCHECKER_SUPPORT "build in support for the StructChecker alpha (not recommended, use the MolVS integration instead)" OFF ) option(RDK_USE_URF "Build support for Florian Flachsenberg's URF library" ON) option(RDK_INSTALL_DEV_COMPONENT "install libraries and headers" ON) option(RDK_USE_BOOST_REGEX "use boost::regex instead of std::regex (needed for systems with g++-4.8)" OFF) diff --git a/Code/ChemicalFeatures/Wrap/test_list.py b/Code/ChemicalFeatures/Wrap/test_list.py deleted file mode 100644 index 0603a7c59..000000000 --- a/Code/ChemicalFeatures/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testFeatures.py", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/ChemicalFeatures/testChemicalFeatures.cpp b/Code/ChemicalFeatures/testChemicalFeatures.cpp index 31f32c0a2..18ed0f1f0 100644 --- a/Code/ChemicalFeatures/testChemicalFeatures.cpp +++ b/Code/ChemicalFeatures/testChemicalFeatures.cpp @@ -1,6 +1,5 @@ -// $Id$ // -// Copyright (C) 2005-2008 Greg Landrum and Rational Discovery LLC +// Copyright (C) 2005-2019 Greg Landrum and Rational Discovery LLC // // @@ All Rights Reserved @@ // This file is part of the RDKit. @@ -15,6 +14,7 @@ #include #include #include +#include using namespace ChemicalFeatures; @@ -22,26 +22,38 @@ void test1() { std::cout << "-----------------------------------------" << std::endl; std::cout << "Test1" << std::endl; - FreeChemicalFeature f1("foo", "bar", RDGeom::Point3D(0, 0, 0)); + FreeChemicalFeature f1("foo", "bar", RDGeom::Point3D(1, 1, 1)); TEST_ASSERT(f1.getId() == -1); TEST_ASSERT(f1.getFamily() == "foo"); TEST_ASSERT(f1.getType() == "bar"); + TEST_ASSERT(RDKit::feq(f1.getPos().x, 1.0)); + TEST_ASSERT(RDKit::feq(f1.getPos().y, 1.0)); + TEST_ASSERT(RDKit::feq(f1.getPos().z, 1.0)); - FreeChemicalFeature f2("foo", "bar", RDGeom::Point3D(0, 0, 0), 123); + FreeChemicalFeature f2("foo", "bar", RDGeom::Point3D(1, 1, 1), 123); TEST_ASSERT(f2.getId() == 123); TEST_ASSERT(f2.getFamily() == "foo"); TEST_ASSERT(f2.getType() == "bar"); + TEST_ASSERT(RDKit::feq(f2.getPos().x, 1.0)); + TEST_ASSERT(RDKit::feq(f2.getPos().y, 1.0)); + TEST_ASSERT(RDKit::feq(f2.getPos().z, 1.0)); FreeChemicalFeature f3; f3.initFromString(f2.toString()); TEST_ASSERT(f3.getId() == 123); TEST_ASSERT(f3.getFamily() == "foo"); TEST_ASSERT(f3.getType() == "bar"); + TEST_ASSERT(RDKit::feq(f3.getPos().x, 1.0)); + TEST_ASSERT(RDKit::feq(f3.getPos().y, 1.0)); + TEST_ASSERT(RDKit::feq(f3.getPos().z, 1.0)); - FreeChemicalFeature f4(f2.toString()); + FreeChemicalFeature f4(f2); TEST_ASSERT(f4.getId() == 123); TEST_ASSERT(f4.getFamily() == "foo"); TEST_ASSERT(f4.getType() == "bar"); + TEST_ASSERT(RDKit::feq(f4.getPos().x, 1.0)); + TEST_ASSERT(RDKit::feq(f4.getPos().y, 1.0)); + TEST_ASSERT(RDKit::feq(f4.getPos().z, 1.0)); std::cout << "Done" << std::endl; } diff --git a/Code/ChemicalFeatures/test_list.py b/Code/ChemicalFeatures/test_list.py deleted file mode 100644 index 634fb4177..000000000 --- a/Code/ChemicalFeatures/test_list.py +++ /dev/null @@ -1,7 +0,0 @@ -tests = [("testExecs/main.exe", "", {}), ] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/DataManip/MetricMatrixCalc/Wrap/test_list.py b/Code/DataManip/MetricMatrixCalc/Wrap/test_list.py deleted file mode 100755 index f3da8ff2f..000000000 --- a/Code/DataManip/MetricMatrixCalc/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testMatricCalc.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/DataManip/MetricMatrixCalc/test_list.py b/Code/DataManip/MetricMatrixCalc/test_list.py deleted file mode 100755 index 32a32588a..000000000 --- a/Code/DataManip/MetricMatrixCalc/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("testExecs/testMatCalc.exe", "", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/DataStructs/Wrap/test_list.py b/Code/DataStructs/Wrap/test_list.py deleted file mode 100755 index ae23f0575..000000000 --- a/Code/DataStructs/Wrap/test_list.py +++ /dev/null @@ -1,12 +0,0 @@ -tests = [ - ("python", "testBV.py", {}), - ("python", "testDiscreteValueVect.py", {}), - ("python", "testSparseIntVect.py", {}), -] - -longTests = [] -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/DataStructs/test_list.py b/Code/DataStructs/test_list.py deleted file mode 100755 index 7ad282b65..000000000 --- a/Code/DataStructs/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("testExecs/test.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/Demos/RDKit/Basement/BinaryIO/test_list.py b/Code/Demos/RDKit/Basement/BinaryIO/test_list.py deleted file mode 100755 index 08dcffa82..000000000 --- a/Code/Demos/RDKit/Basement/BinaryIO/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("testExecs/iotest.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/DistGeom/Wrap/test_list.py b/Code/DistGeom/Wrap/test_list.py deleted file mode 100644 index ed2480c3f..000000000 --- a/Code/DistGeom/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "rough_test.py", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/DistGeom/test_list.py b/Code/DistGeom/test_list.py deleted file mode 100755 index 39dd8fca7..000000000 --- a/Code/DistGeom/test_list.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys - -tests = [ - ("testExecs/main.exe", "", {}), - ("python", "test_list.py", {'dir': 'Wrap'}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/Features/test_list.py b/Code/Features/test_list.py deleted file mode 100644 index d771f9697..000000000 --- a/Code/Features/test_list.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys - -tests = [("testExecs/testFeatures.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/ForceField/UFF/test_list.py b/Code/ForceField/UFF/test_list.py deleted file mode 100644 index 964eaef44..000000000 --- a/Code/ForceField/UFF/test_list.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys - -tests = [("testExecs/testUFFForceField.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/ForceField/Wrap/test_list.py b/Code/ForceField/Wrap/test_list.py deleted file mode 100644 index a8d0115e7..000000000 --- a/Code/ForceField/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testConstraints.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/Geometry/Wrap/test_list.py b/Code/Geometry/Wrap/test_list.py deleted file mode 100644 index 373d63490..000000000 --- a/Code/Geometry/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testGeometry.py", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/Geometry/test_list.py b/Code/Geometry/test_list.py deleted file mode 100644 index ef1cc67f2..000000000 --- a/Code/Geometry/test_list.py +++ /dev/null @@ -1,12 +0,0 @@ -tests = [ - ("testExecs/testTransforms.exe", "", {}), - ("testExecs/testGrid.exe", "", {}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/CMakeLists.txt b/Code/GraphMol/CMakeLists.txt index cf3f7241e..695261997 100644 --- a/Code/GraphMol/CMakeLists.txt +++ b/Code/GraphMol/CMakeLists.txt @@ -79,7 +79,10 @@ add_subdirectory(MolDraw2D) add_subdirectory(FMCS) add_subdirectory(MolHash) add_subdirectory(MMPA) + +if(RDK_BUILD_STRUCTCHECKER_SUPPORT) add_subdirectory(StructChecker) +endif() add_subdirectory(ReducedGraphs) add_subdirectory(Trajectory) diff --git a/Code/GraphMol/ChemReactions/Wrap/test_list.py b/Code/GraphMol/ChemReactions/Wrap/test_list.py deleted file mode 100644 index e54208bf7..000000000 --- a/Code/GraphMol/ChemReactions/Wrap/test_list.py +++ /dev/null @@ -1,15 +0,0 @@ -import sys - -tests=[ - ("python", "testReactionWrapper.py",{}), - ("python", "testEnumerations.py",{}), - ] - -longTests=[ - ] - -if __name__=='__main__': - import sys - from rdkit import TestRunner - failed,tests = TestRunner.RunScript('test_list.py',0,1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/ChemReactions/test_list.py b/Code/GraphMol/ChemReactions/test_list.py deleted file mode 100644 index 088f6b8b2..000000000 --- a/Code/GraphMol/ChemReactions/test_list.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys - -tests = [ - ("testExecs/testReaction.exe", "", {}), - ("python", "test_list.py", {'dir': 'Wrap'}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/ChemTransforms/test_list.py b/Code/GraphMol/ChemTransforms/test_list.py deleted file mode 100644 index 4872a348d..000000000 --- a/Code/GraphMol/ChemTransforms/test_list.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys - -tests = [("testExecs/main.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/Depictor/Wrap/test_list.py b/Code/GraphMol/Depictor/Wrap/test_list.py deleted file mode 100755 index f57f26495..000000000 --- a/Code/GraphMol/Depictor/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testDepictor.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/Depictor/test_list.py b/Code/GraphMol/Depictor/test_list.py deleted file mode 100755 index 96bc69f50..000000000 --- a/Code/GraphMol/Depictor/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("testExecs/testDepictor.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/Descriptors/Wrap/test_list.py b/Code/GraphMol/Descriptors/Wrap/test_list.py deleted file mode 100644 index 0690833d3..000000000 --- a/Code/GraphMol/Descriptors/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testMolDescriptors.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/Descriptors/test_list.py b/Code/GraphMol/Descriptors/test_list.py deleted file mode 100644 index 46b965620..000000000 --- a/Code/GraphMol/Descriptors/test_list.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys - -tests = [("testExecs/testDescriptors.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/DistGeomHelpers/Wrap/test_list.py b/Code/GraphMol/DistGeomHelpers/Wrap/test_list.py deleted file mode 100644 index 127ac01b6..000000000 --- a/Code/GraphMol/DistGeomHelpers/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testDistGeom.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/DistGeomHelpers/test_list.py b/Code/GraphMol/DistGeomHelpers/test_list.py deleted file mode 100755 index 39dd8fca7..000000000 --- a/Code/GraphMol/DistGeomHelpers/test_list.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys - -tests = [ - ("testExecs/main.exe", "", {}), - ("python", "test_list.py", {'dir': 'Wrap'}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/FileParsers/test_list.py b/Code/GraphMol/FileParsers/test_list.py deleted file mode 100755 index e85ad5e11..000000000 --- a/Code/GraphMol/FileParsers/test_list.py +++ /dev/null @@ -1,15 +0,0 @@ -tests = [ - ("testExecs/test1.exe", "", {}), - ("testExecs/testMolSupplier.exe", "", {}), - ("testExecs/testMolWriter.exe", "", {}), - ("testExecs/testTplParser.exe", "", {}), - ("testExecs/testMol2ToMol.exe", "", {}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/FilterCatalog/Wrap/test_list.py b/Code/GraphMol/FilterCatalog/Wrap/test_list.py deleted file mode 100644 index ed2480c3f..000000000 --- a/Code/GraphMol/FilterCatalog/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "rough_test.py", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/Fingerprints/Wrap/testGenerators.py b/Code/GraphMol/Fingerprints/Wrap/testGenerators.py index f6bc745bb..772171db7 100644 --- a/Code/GraphMol/Fingerprints/Wrap/testGenerators.py +++ b/Code/GraphMol/Fingerprints/Wrap/testGenerators.py @@ -61,11 +61,38 @@ class TestCase(unittest.TestCase): self.assertNotEqual(nz.keys(), nzChirality.keys()) def testMorganGenerator(self): - m = Chem.MolFromSmiles('CCCCC') + m = Chem.MolFromSmiles('CCCC(=O)O') g = rdFingerprintGenerator.GetMorganGenerator(3) fp = g.GetSparseCountFingerprint(m) nz = fp.GetNonzeroElements() - self.assertEqual(len(nz), 7) + self.assertEqual(len(nz), 14) + + invgen = rdFingerprintGenerator.GetMorganAtomInvGen() + g = rdFingerprintGenerator.GetMorganGenerator(radius=3, atomInvariantsGenerator=invgen) + fp = g.GetSparseCountFingerprint(m) + nz = fp.GetNonzeroElements() + self.assertEqual(len(nz), 14) + + invgen = rdFingerprintGenerator.GetMorganFeatureAtomInvGen() + g = rdFingerprintGenerator.GetMorganGenerator(radius=3, atomInvariantsGenerator=invgen) + fp = g.GetSparseCountFingerprint(m) + nz = fp.GetNonzeroElements() + self.assertEqual(len(nz), 13) + + ms = [Chem.MolFromSmiles(x, sanitize=False) for x in ('C1=CC=CN=N1', 'C1C=CC=NN=1')] + for m in ms: + m.UpdatePropertyCache() + Chem.GetSymmSSSR(m) + + g = rdFingerprintGenerator.GetMorganGenerator(radius=2, useBondTypes=True) + self.assertNotEqual(g.GetSparseCountFingerprint(ms[0]), g.GetSparseCountFingerprint(ms[1])) + g = rdFingerprintGenerator.GetMorganGenerator(radius=2, useBondTypes=False) + self.assertEqual(g.GetSparseCountFingerprint(ms[0]), g.GetSparseCountFingerprint(ms[1])) + + binvgen = rdFingerprintGenerator.GetMorganBondInvGen(useBondTypes=False) + g2 = rdFingerprintGenerator.GetMorganGenerator(radius=2, bondInvariantsGenerator=binvgen) + self.assertEqual(g.GetSparseCountFingerprint(ms[0]), g2.GetSparseCountFingerprint(ms[0])) + self.assertEqual(g.GetSparseCountFingerprint(ms[1]), g2.GetSparseCountFingerprint(ms[1])) def testRDKitFPGenerator(self): m = Chem.MolFromSmiles('CCCCC') diff --git a/Code/GraphMol/Fingerprints/Wrap/test_list.py b/Code/GraphMol/Fingerprints/Wrap/test_list.py deleted file mode 100644 index d6b290a1b..000000000 --- a/Code/GraphMol/Fingerprints/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testGenerators.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/Fingerprints/test_list.py b/Code/GraphMol/Fingerprints/test_list.py deleted file mode 100755 index 8e7e0d46c..000000000 --- a/Code/GraphMol/Fingerprints/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("testExecs/test1.exe", "", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/ForceFieldHelpers/CrystalFF/test_list.py b/Code/GraphMol/ForceFieldHelpers/CrystalFF/test_list.py deleted file mode 100755 index 8f5d7038e..000000000 --- a/Code/GraphMol/ForceFieldHelpers/CrystalFF/test_list.py +++ /dev/null @@ -1,7 +0,0 @@ -import sys - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/ForceFieldHelpers/MMFF/test_list.py b/Code/GraphMol/ForceFieldHelpers/MMFF/test_list.py deleted file mode 100755 index 8770361c6..000000000 --- a/Code/GraphMol/ForceFieldHelpers/MMFF/test_list.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys - -tests = [("testExecs/testMMFFHelpers.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/ForceFieldHelpers/UFF/test_list.py b/Code/GraphMol/ForceFieldHelpers/UFF/test_list.py deleted file mode 100755 index 579ae9e24..000000000 --- a/Code/GraphMol/ForceFieldHelpers/UFF/test_list.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys - -tests = [("testExecs/testUFFHelpers.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/ForceFieldHelpers/Wrap/test_list.py b/Code/GraphMol/ForceFieldHelpers/Wrap/test_list.py deleted file mode 100644 index 9357b677e..000000000 --- a/Code/GraphMol/ForceFieldHelpers/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testHelpers.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/FragCatalog/Wrap/test_list.py b/Code/GraphMol/FragCatalog/Wrap/test_list.py deleted file mode 100755 index ed2480c3f..000000000 --- a/Code/GraphMol/FragCatalog/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "rough_test.py", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/FragCatalog/test_list.py b/Code/GraphMol/FragCatalog/test_list.py deleted file mode 100755 index 8e7e0d46c..000000000 --- a/Code/GraphMol/FragCatalog/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("testExecs/test1.exe", "", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/MolAlign/Wrap/test_list.py b/Code/GraphMol/MolAlign/Wrap/test_list.py deleted file mode 100644 index 195d29968..000000000 --- a/Code/GraphMol/MolAlign/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testMolAlign.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/MolAlign/test_list.py b/Code/GraphMol/MolAlign/test_list.py deleted file mode 100644 index 3bbaee937..000000000 --- a/Code/GraphMol/MolAlign/test_list.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys - -tests = [ - ("testExecs/testMolAlign.exe", "", {}), - ("python", "test_list.py", {'dir': 'Wrap'}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/MolCatalog/Wrap/test_list.py b/Code/GraphMol/MolCatalog/Wrap/test_list.py deleted file mode 100755 index ed2480c3f..000000000 --- a/Code/GraphMol/MolCatalog/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "rough_test.py", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/MolCatalog/test_list.py b/Code/GraphMol/MolCatalog/test_list.py deleted file mode 100755 index 8e7e0d46c..000000000 --- a/Code/GraphMol/MolCatalog/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("testExecs/test1.exe", "", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/MolChemicalFeatures/Wrap/test_list.py b/Code/GraphMol/MolChemicalFeatures/Wrap/test_list.py deleted file mode 100644 index c0c021336..000000000 --- a/Code/GraphMol/MolChemicalFeatures/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testChemicalFeatures.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/MolChemicalFeatures/test_list.py b/Code/GraphMol/MolChemicalFeatures/test_list.py deleted file mode 100644 index b9d58f0dc..000000000 --- a/Code/GraphMol/MolChemicalFeatures/test_list.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys - -tests = [ - ("testExecs/testFeatures.exe", "", {}), - ("python", "test_list.py", {'dir': 'Wrap'}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/MolDraw2D/Wrap/test_list.py b/Code/GraphMol/MolDraw2D/Wrap/test_list.py deleted file mode 100644 index 9ce4168bd..000000000 --- a/Code/GraphMol/MolDraw2D/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testMolDraw2D.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/MolTransforms/Wrap/test_list.py b/Code/GraphMol/MolTransforms/Wrap/test_list.py deleted file mode 100644 index 9094827e2..000000000 --- a/Code/GraphMol/MolTransforms/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testMolTransforms.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/MolTransforms/test_list.py b/Code/GraphMol/MolTransforms/test_list.py deleted file mode 100755 index e9b5120f8..000000000 --- a/Code/GraphMol/MolTransforms/test_list.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys - -tests = [ - ("testExecs/testMolTransform.exe", "", {}), - ("python", "test_list.py", {'dir': 'Wrap'}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/PartialCharges/Wrap/test_list.py b/Code/GraphMol/PartialCharges/Wrap/test_list.py deleted file mode 100755 index 2fe6e7d5a..000000000 --- a/Code/GraphMol/PartialCharges/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testPartialCharges.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/SLNParse/Wrap/test_list.py b/Code/GraphMol/SLNParse/Wrap/test_list.py deleted file mode 100644 index a817b8df3..000000000 --- a/Code/GraphMol/SLNParse/Wrap/test_list.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys - -tests = [("python", "testSLN.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/SLNParse/test_list.py b/Code/GraphMol/SLNParse/test_list.py deleted file mode 100755 index b4be6b56d..000000000 --- a/Code/GraphMol/SLNParse/test_list.py +++ /dev/null @@ -1,17 +0,0 @@ -import sys - -tests = [ - ("testExecs/test.exe", "", {}), - ("python", "test_list.py", {'dir': 'Wrap'}), -] - -if sys.platform != 'win32': - pass - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/ShapeHelpers/Wrap/test_list.py b/Code/GraphMol/ShapeHelpers/Wrap/test_list.py deleted file mode 100644 index 048acb3a5..000000000 --- a/Code/GraphMol/ShapeHelpers/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testShapeHelpers.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/ShapeHelpers/testShapeHelpers.cpp b/Code/GraphMol/ShapeHelpers/testShapeHelpers.cpp index dc3210057..42b91945e 100644 --- a/Code/GraphMol/ShapeHelpers/testShapeHelpers.cpp +++ b/Code/GraphMol/ShapeHelpers/testShapeHelpers.cpp @@ -1,6 +1,5 @@ -// $Id$ // -// Copyright (C) 2005-2006 Rational Discovery LLC +// Copyright (C) 2005-2019 Rational Discovery LLC // // @@ All Rights Reserved @@ // This file is part of the RDKit. @@ -14,10 +13,7 @@ #include "ShapeEncoder.h" #include "ShapeUtils.h" #include -//#include #include -//#include -//#include #include #include #include @@ -37,8 +33,6 @@ void test1Encode() { MolShapes::EncodeShape(*m, grd, 0); delete m; - // RDGeom::writeGridToFile(grd, "junk.grd"); - // MolToMolFile(m, "junk.mol", 0); CHECK_INVARIANT(grd.getOccupancyVect()->getTotalVal() == 7405, ""); } @@ -89,22 +83,6 @@ void test2Compare() { delete m2; } -void test3Methane() { - std::string rdbase = getenv("RDBASE"); - std::string fname = - rdbase + "/Code/GraphMol/ShapeHelpers/test_data/methane.mol"; - ROMol *m = MolFileToMol(fname); - RDGeom::Point3D dims, offSet; - MolShapes::computeConfDimsAndOffset(m->getConformer(), dims, offSet, nullptr, - 3.0); - std::cout << dims << " " << offSet << "\n"; - RDGeom::UniformGrid3D grd(6.5, 6.5, 6.5); - // 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() { #if 1 std::cout << "***********************************************************\n"; @@ -119,6 +97,5 @@ int main() { test2Compare(); std::cout << "***********************************************************\n"; #endif - // test3Methane(); return 0; } diff --git a/Code/GraphMol/ShapeHelpers/test_list.py b/Code/GraphMol/ShapeHelpers/test_list.py deleted file mode 100644 index 39dd8fca7..000000000 --- a/Code/GraphMol/ShapeHelpers/test_list.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys - -tests = [ - ("testExecs/main.exe", "", {}), - ("python", "test_list.py", {'dir': 'Wrap'}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/SmilesParse/SmartsWrite.cpp b/Code/GraphMol/SmilesParse/SmartsWrite.cpp index af819fc10..658335112 100644 --- a/Code/GraphMol/SmilesParse/SmartsWrite.cpp +++ b/Code/GraphMol/SmilesParse/SmartsWrite.cpp @@ -1,5 +1,5 @@ // -// Copyright (C) 2002-2018 Greg Landrum and Rational Discovery LLC +// Copyright (C) 2002-2019 Greg Landrum and Rational Discovery LLC // // @@ All Rights Reserved @@ // This file is part of the RDKit. @@ -95,42 +95,6 @@ void describeQuery(const T *query, std::string leader = "\t") { } } -// called with the children of AND queries: -std::string smartsOrganicAtom(const QueryAtom::QUERYATOM_QUERY *child1, - const QueryAtom::QUERYATOM_QUERY *child2) { - PRECONDITION(child1 && child2, "bad query"); - - std::string desc1 = child1->getDescription(); - std::string desc2 = child2->getDescription(); - const QueryAtom::QUERYATOM_QUERY *origA, *otherA; - if (desc1 == "AtomAtomicNum") { - origA = child1; - otherA = child2; - } else { - origA = child2; - otherA = child1; - } - - std::string odsc = otherA->getDescription(); - CHECK_INVARIANT(((odsc == "AtomIsAliphatic") || (odsc == "AtomIsAromatic")), - "Should be either an aromatic or Aliphatic atom"); - - const ATOM_EQUALS_QUERY *torig = - static_cast(origA); - int val = torig->getVal(); - std::string res = PeriodicTable::getTable()->getElementSymbol(val); - if (odsc == "AtomIsAromatic") { - // if aromatic convert the first leter to a small letter - res[0] += ('a' - 'A'); - if (res.length() > 1) { - res = "[" + res + "]"; - } - } - if (torig->getNegation()) { - res = "!" + res; - } - return res; -} const static std::string _qatomHasStereoSet = "_qatomHasStereoSet"; std::string getAtomSmartsSimple(const QueryAtom *qatom, const ATOM_EQUALS_QUERY *query, @@ -476,32 +440,6 @@ std::string _recurseGetSmarts(const QueryAtom *qatom, std::string csmarts1, csmarts2; bool needParen; - - // deal with any special AND cases - // 1. This "node" is an AtomAnd between a AliphaticAtom (or AromaticAtom) - // and - // an organic atom e.g. "C" - if (descrip == "AtomAnd") { - bool specialCase = false; - // case 1 - if ((!child1->getNegation() && !child2->getNegation()) && - (((dsc1 == "AtomAtomicNum") && - ((dsc2 == "AtomIsAliphatic") || (dsc2 == "AtomIsAromatic"))) || - ((dsc2 == "AtomAtomicNum") && - ((dsc1 == "AtomIsAliphatic") || (dsc1 == "AtomIsAromatic"))))) { - // we trap this one because it's nicer to see - // "CC" in the output than "[#6&A][#6&A]" - res = smartsOrganicAtom(child1, child2); - specialCase = true; - } - if (specialCase) { - if (negate) { - res = "!" + res; - } - return res; - } - } - // deal with the first child if (dsc1 == "RecursiveStructure") { csmarts1 = getRecursiveStructureQuerySmarts(child1); diff --git a/Code/GraphMol/SmilesParse/SmilesParse.h b/Code/GraphMol/SmilesParse/SmilesParse.h index da143aa40..8e59397d3 100644 --- a/Code/GraphMol/SmilesParse/SmilesParse.h +++ b/Code/GraphMol/SmilesParse/SmilesParse.h @@ -127,12 +127,9 @@ inline std::unique_ptr operator"" _smiles(const char *text, inline std::unique_ptr operator"" _smarts(const char *text, size_t len) { std::string smi(text, len); - RWMol *ptr = nullptr; - try { - ptr = SmartsToMol(smi); - } catch (const RDKit::MolSanitizeException &) { - ptr = nullptr; - } + // no need for exception handling here: SmartsToMol() doesn't do + // sanitization + RWMol *ptr = SmartsToMol(smi); return std::unique_ptr(ptr); } diff --git a/Code/GraphMol/SmilesParse/SmilesParseOps.cpp b/Code/GraphMol/SmilesParse/SmilesParseOps.cpp index 7493ceb10..a3321f70a 100644 --- a/Code/GraphMol/SmilesParse/SmilesParseOps.cpp +++ b/Code/GraphMol/SmilesParse/SmilesParseOps.cpp @@ -1,5 +1,5 @@ // -// Copyright (C) 2001-2016 Greg Landrum and Rational Discovery LLC +// Copyright (C) 2001-2019 Greg Landrum and Rational Discovery LLC // // @@ All Rights Reserved @@ // This file is part of the RDKit. @@ -88,7 +88,7 @@ void CleanupAfterParseError(RWMol *mol) { // between the fragment and the molecule // void AddFragToMol(RWMol *mol, RWMol *frag, Bond::BondType bondOrder, - Bond::BondDir bondDir, bool closeRings, bool doingQuery) { + Bond::BondDir bondDir) { PRECONDITION(mol, "no molecule"); PRECONDITION(frag, "no fragment"); PRECONDITION(mol->getActiveAtom(), "no active atom"); @@ -96,13 +96,6 @@ void AddFragToMol(RWMol *mol, RWMol *frag, Bond::BondType bondOrder, int nOrigAtoms = mol->getNumAtoms(); int nOrigBonds = mol->getNumBonds(); - // - // close any rings we can in the fragment - // - if (closeRings) { - CloseMolRings(frag, true); - } - // // Add the fragment's atoms and bonds to the molecule: // @@ -150,17 +143,18 @@ void AddFragToMol(RWMol *mol, RWMol *frag, Bond::BondType bondOrder, } mol->clearBondBookmark(ci_LEADING_BOND); } else { - if (!doingQuery) { - if (bondOrder == Bond::UNSPECIFIED) { - // no bond order provided, figure it out ourselves - if (lastAt->getIsAromatic() && firstAt->getIsAromatic()) { - bo = Bond::AROMATIC; - } else { - bo = Bond::SINGLE; - } - } else { - bo = bondOrder; - } + // SMARTS semantics: unspecified bonds can be single or aromatic + if (bondOrder == Bond::UNSPECIFIED) { + auto *newB = new QueryBond(Bond::SINGLE); + newB->expandQuery(makeBondOrderEqualsQuery(Bond::AROMATIC), + Queries::COMPOSITE_OR, true); + newB->setOwningMol(mol); + newB->setBeginAtomIdx(atomIdx1); + newB->setEndAtomIdx(atomIdx2); + mol->addBond(newB); + delete newB; + } else { + bo = bondOrder; if (bo == Bond::DATIVEL) { int tmp = atomIdx2; atomIdx2 = atomIdx1; @@ -171,31 +165,6 @@ void AddFragToMol(RWMol *mol, RWMol *frag, Bond::BondType bondOrder, } int idx = mol->addBond(atomIdx2, atomIdx1, bo) - 1; mol->getBondWithIdx(idx)->setBondDir(bondDir); - } else { - // semantics are different in SMARTS, unspecified bonds can be single or - // aromatic: - if (bondOrder == Bond::UNSPECIFIED) { - auto *newB = new QueryBond(Bond::SINGLE); - newB->expandQuery(makeBondOrderEqualsQuery(Bond::AROMATIC), - Queries::COMPOSITE_OR, true); - newB->setOwningMol(mol); - newB->setBeginAtomIdx(atomIdx1); - newB->setEndAtomIdx(atomIdx2); - mol->addBond(newB); - delete newB; - } else { - bo = bondOrder; - if (bo == Bond::DATIVEL) { - int tmp = atomIdx2; - atomIdx2 = atomIdx1; - atomIdx1 = tmp; - bo = Bond::DATIVE; - } else if (bo == Bond::DATIVER) { - bo = Bond::DATIVE; - } - int idx = mol->addBond(atomIdx2, atomIdx1, bo) - 1; - mol->getBondWithIdx(idx)->setBondDir(bondDir); - } } } } @@ -236,14 +205,6 @@ void AddFragToMol(RWMol *mol, RWMol *frag, Bond::BondType bondOrder, frag->clearAllBondBookmarks(); }; -void _invChiralRingAtomWithHs(Atom *atom) { - PRECONDITION(atom, "bad atom"); - // we will assume that this function is called on a ring atom with a - // ring closure bond - if (atom->getNumExplicitHs() == 1) { - atom->invertChirality(); - } -} typedef std::pair SIZET_PAIR; typedef std::pair INT_PAIR; template diff --git a/Code/GraphMol/SmilesParse/SmilesParseOps.h b/Code/GraphMol/SmilesParse/SmilesParseOps.h index 1673cd3dd..a83530cf5 100644 --- a/Code/GraphMol/SmilesParse/SmilesParseOps.h +++ b/Code/GraphMol/SmilesParse/SmilesParseOps.h @@ -1,5 +1,5 @@ // -// Copyright (C) 2001-2016 Greg Landrum and Rational Discovery LLC +// Copyright (C) 2001-2019 Greg Landrum and Rational Discovery LLC // // @@ All Rights Reserved @@ // This file is part of the RDKit. @@ -20,10 +20,11 @@ namespace SmilesParseOps { void CheckRingClosureBranchStatus(RDKit::Atom *atom, RDKit::RWMol *mp); void ReportParseError(const char *message, bool throwIt = true); void CleanupAfterParseError(RDKit::RWMol *mol); +// This uses SMARTS semantics: unspecified bonds are treated as +// aromatic or single. void AddFragToMol(RDKit::RWMol *mol, RDKit::RWMol *frag, RDKit::Bond::BondType bondOrder = RDKit::Bond::UNSPECIFIED, - RDKit::Bond::BondDir bondDir = RDKit::Bond::NONE, - bool closeRings = false, bool doingQuery = false); + RDKit::Bond::BondDir bondDir = RDKit::Bond::NONE); RDKit::Bond::BondType GetUnspecifiedBondType(const RDKit::RWMol *mol, const RDKit::Atom *atom1, const RDKit::Atom *atom2); diff --git a/Code/GraphMol/SmilesParse/catch_tests.cpp b/Code/GraphMol/SmilesParse/catch_tests.cpp index 0c3dba939..e7c742b3d 100644 --- a/Code/GraphMol/SmilesParse/catch_tests.cpp +++ b/Code/GraphMol/SmilesParse/catch_tests.cpp @@ -553,8 +553,20 @@ TEST_CASE("github #2604: support range-based charge queries from SMARTS", } } -TEST_CASE("github #2801: MolToSmarts may generate invalid SMARTS for bond queries", - "[bug,smarts]") { +TEST_CASE("_smarts fails gracefully", "[smarts]") { + SECTION("empty") { + auto mol = ""_smarts; + REQUIRE(mol); + } + SECTION("syntax error") { + auto mol = "C1C"_smarts; + REQUIRE(!mol); + } +} + +TEST_CASE( + "github #2801: MolToSmarts may generate invalid SMARTS for bond queries", + "[bug,smarts]") { SECTION("original_report") { auto q1 = "*~CCC"_smarts; REQUIRE(q1); diff --git a/Code/GraphMol/SmilesParse/smarts.tab.cpp.cmake b/Code/GraphMol/SmilesParse/smarts.tab.cpp.cmake index 06c2fb523..40fbced0f 100644 --- a/Code/GraphMol/SmilesParse/smarts.tab.cpp.cmake +++ b/Code/GraphMol/SmilesParse/smarts.tab.cpp.cmake @@ -1924,7 +1924,7 @@ yyreduce: { RWMol *m1_p = (*molList)[(yyval.moli)],*m2_p=(*molList)[(yyvsp[0].moli)]; // FIX: handle generic bonds here - SmilesParseOps::AddFragToMol(m1_p,m2_p,Bond::UNSPECIFIED,Bond::NONE,false,true); + SmilesParseOps::AddFragToMol(m1_p,m2_p,Bond::UNSPECIFIED,Bond::NONE); delete m2_p; int sz = molList->size(); if ( sz==(yyvsp[0].moli)+1) { diff --git a/Code/GraphMol/SmilesParse/smarts.yy b/Code/GraphMol/SmilesParse/smarts.yy index 05767455d..2dc8299c0 100644 --- a/Code/GraphMol/SmilesParse/smarts.yy +++ b/Code/GraphMol/SmilesParse/smarts.yy @@ -271,7 +271,7 @@ mol: atomd { | mol branch { RWMol *m1_p = (*molList)[$$],*m2_p=(*molList)[$2]; // FIX: handle generic bonds here - SmilesParseOps::AddFragToMol(m1_p,m2_p,Bond::UNSPECIFIED,Bond::NONE,false,true); + SmilesParseOps::AddFragToMol(m1_p,m2_p,Bond::UNSPECIFIED,Bond::NONE); delete m2_p; int sz = molList->size(); if ( sz==$2+1) { diff --git a/Code/GraphMol/SmilesParse/smatest.cpp b/Code/GraphMol/SmilesParse/smatest.cpp index c0dfd461c..d4c413883 100644 --- a/Code/GraphMol/SmilesParse/smatest.cpp +++ b/Code/GraphMol/SmilesParse/smatest.cpp @@ -69,6 +69,9 @@ void testPass() { "[C;!$(C-[OH])]=O", "[#6]-!:[#6]", "[C^3]", + "[*^0]", + "[*^1]", + "[*^2]", "[*^4]", "[*^5]", "[se]", @@ -125,7 +128,6 @@ void testPass() { { // finally make sure that we can create parsable SMARTS from it: auto outSmarts = MolToSmarts(*mol); - std::cerr << smi << " " << outSmarts << std::endl; auto mol2 = SmartsToMol(outSmarts); TEST_ASSERT(mol2); delete mol2; @@ -2798,16 +2800,16 @@ void testSmartsStereoBonds() { } void testRingBondCrash() { - BOOST_LOG(rdInfoLog) << "-------------------------------------" << std::endl; - BOOST_LOG(rdInfoLog) - << "Testing a crash arising from negated ring bond queries" << std::endl; - { - auto m2 = "CC"_smiles; - auto q = "[C]@[Cl]"_smarts; - auto matches0 = SubstructMatch(*m2, *q); - } + BOOST_LOG(rdInfoLog) << "-------------------------------------" << std::endl; + BOOST_LOG(rdInfoLog) + << "Testing a crash arising from negated ring bond queries" << std::endl; + { + auto m2 = "CC"_smiles; + auto q = "[C]@[Cl]"_smarts; + auto matches0 = SubstructMatch(*m2, *q); + } - BOOST_LOG(rdInfoLog) << "done" << std::endl; + BOOST_LOG(rdInfoLog) << "done" << std::endl; } int main(int argc, char *argv[]) { diff --git a/Code/GraphMol/SmilesParse/test_list.py b/Code/GraphMol/SmilesParse/test_list.py deleted file mode 100755 index 862d31a3b..000000000 --- a/Code/GraphMol/SmilesParse/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("testExecs/test.exe", "", {}), ("testExecs/smatest.exe", "", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/Subgraphs/test_list.py b/Code/GraphMol/Subgraphs/test_list.py deleted file mode 100755 index 26518cfb1..000000000 --- a/Code/GraphMol/Subgraphs/test_list.py +++ /dev/null @@ -1,12 +0,0 @@ -tests = [ - ("testExecs/test1.exe", "", {}), - ("testExecs/test2.exe", "", {}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/Substruct/test_list.py b/Code/GraphMol/Substruct/test_list.py deleted file mode 100755 index c62b01468..000000000 --- a/Code/GraphMol/Substruct/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("testExecs/test1.exe", "", {})] - -longTests = [("testExecs/test1.exe", "-l", {}), ] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/Wrap/rdmolfiles.cpp b/Code/GraphMol/Wrap/rdmolfiles.cpp index 3394b6e5e..ee9d0c83d 100644 --- a/Code/GraphMol/Wrap/rdmolfiles.cpp +++ b/Code/GraphMol/Wrap/rdmolfiles.cpp @@ -36,11 +36,6 @@ namespace python = boost::python; using namespace RDKit; -void rdSanitExceptionTranslator(RDKit::MolSanitizeException const &x) { - std::ostringstream ss; - ss << "Sanitization error: " << x.message(); - PyErr_SetString(PyExc_ValueError, ss.str().c_str()); -} void rdBadFileExceptionTranslator(RDKit::BadFileException const &x) { std::ostringstream ss; ss << "File error: " << x.message(); @@ -252,14 +247,15 @@ ROMol *MolFromHELM(python::object seq, bool sanitize) { std::string molFragmentToSmarts(const ROMol &mol, python::object atomsToUse, python::object bondsToUse, - bool doIsomericSmarts = true) -{ - auto atomIndices = pythonObjectToVect(atomsToUse, static_cast(mol.getNumAtoms())); - auto bondIndices = pythonObjectToVect(bondsToUse, static_cast(mol.getNumBonds())); - return RDKit::MolFragmentToSmarts(mol, *atomIndices, bondIndices.get(), doIsomericSmarts); + bool doIsomericSmarts = true) { + auto atomIndices = + pythonObjectToVect(atomsToUse, static_cast(mol.getNumAtoms())); + auto bondIndices = + pythonObjectToVect(bondsToUse, static_cast(mol.getNumBonds())); + return RDKit::MolFragmentToSmarts(mol, *atomIndices, bondIndices.get(), + doIsomericSmarts); } - struct smilesfrag_gen { std::string operator()(const ROMol &mol, const std::vector &atomsToUse, const std::vector *bondsToUse, @@ -293,11 +289,13 @@ std::string MolFragmentToSmilesHelper( python::object atomSymbols, python::object bondSymbols, bool doIsomericSmiles, bool doKekule, int rootedAtAtom, bool canonical, bool allBondsExplicit, bool allHsExplicit) { - auto avect = pythonObjectToVect(atomsToUse, static_cast(mol.getNumAtoms())); + auto avect = + pythonObjectToVect(atomsToUse, static_cast(mol.getNumAtoms())); if (!avect.get() || !(avect->size())) { throw_value_error("atomsToUse must not be empty"); } - auto bvect = pythonObjectToVect(bondsToUse, static_cast(mol.getNumBonds())); + auto bvect = + pythonObjectToVect(bondsToUse, static_cast(mol.getNumBonds())); std::unique_ptr> asymbols = pythonObjectToVect(atomSymbols); std::unique_ptr> bsymbols = @@ -325,13 +323,10 @@ std::vector CanonicalRankAtoms(const ROMol &mol, return ranks; } -std::vector CanonicalRankAtomsInFragment(const ROMol &mol, - python::object atomsToUse, - python::object bondsToUse, - python::object atomSymbols, - bool breakTies = true, - bool includeChirality = true, - bool includeIsotopes = true) +std::vector CanonicalRankAtomsInFragment( + const ROMol &mol, python::object atomsToUse, python::object bondsToUse, + python::object atomSymbols, bool breakTies = true, + bool includeChirality = true, bool includeIsotopes = true) { std::unique_ptr> avect = @@ -355,8 +350,8 @@ std::vector CanonicalRankAtomsInFragment(const ROMol &mol, bonds[(*bvect)[i]] = true; std::vector ranks(mol.getNumAtoms()); - Canon::rankFragmentAtoms(mol, ranks, atoms, bonds, asymbols.get(), - breakTies, includeChirality, includeIsotopes); + Canon::rankFragmentAtoms(mol, ranks, atoms, bonds, asymbols.get(), breakTies, + includeChirality, includeIsotopes); std::vector resRanks(mol.getNumAtoms()); // set unused ranks to -1 for the Python interface @@ -409,7 +404,6 @@ BOOST_PYTHON_MODULE(rdmolfiles) { python::register_exception_translator( &rdFileParseExceptionTranslator); - docString = "Construct a molecule from a TPL file.\n\n\ ARGUMENTS:\n\ @@ -1017,9 +1011,11 @@ BOOST_PYTHON_MODULE(rdmolfiles) { \n\ a string\n\ \n"; - python::def("MolFragmentToSmarts", molFragmentToSmarts, - (python::arg("mol"), python::arg("atomsToUse"), python::arg("bondsToUse") = 0, python::arg("isomericSmarts") = true), - docString.c_str()); + python::def( + "MolFragmentToSmarts", molFragmentToSmarts, + (python::arg("mol"), python::arg("atomsToUse"), + python::arg("bondsToUse") = 0, python::arg("isomericSmarts") = true), + docString.c_str()); docString = "Writes a molecule to a TPL file.\n\n\ @@ -1341,13 +1337,13 @@ BOOST_PYTHON_MODULE(rdmolfiles) { \n\ a string\n\ \n"; - python::def("CanonicalRankAtomsInFragment", CanonicalRankAtomsInFragment, - (python::arg("mol"), python::arg("atomsToUse"), - python::arg("bondsToUse") = 0, python::arg("atomSymbols") = 0, - python::arg("breakTies") = true, - python::arg("includeChirality") = true, - python::arg("includeIsotopes") = true), - docString.c_str()); + python::def( + "CanonicalRankAtomsInFragment", CanonicalRankAtomsInFragment, + (python::arg("mol"), python::arg("atomsToUse"), + python::arg("bondsToUse") = 0, python::arg("atomSymbols") = 0, + python::arg("breakTies") = true, python::arg("includeChirality") = true, + python::arg("includeIsotopes") = true), + docString.c_str()); python::def( "CreateAtomIntPropertyList", FileParserUtils::createAtomIntPropertyList, diff --git a/Code/GraphMol/Wrap/rdmolops.cpp b/Code/GraphMol/Wrap/rdmolops.cpp index 9bbc531f1..d63050a21 100644 --- a/Code/GraphMol/Wrap/rdmolops.cpp +++ b/Code/GraphMol/Wrap/rdmolops.cpp @@ -1,5 +1,5 @@ // -// Copyright (C) 2003-2013 Greg Landrum and Rational Discovery LLC +// Copyright (C) 2003-2019 Greg Landrum and Rational Discovery LLC // // @@ All Rights Reserved @@ // This file is part of the RDKit. @@ -21,12 +21,6 @@ namespace python = boost::python; using namespace RDKit; -void rdSanitExceptionTranslator(RDKit::MolSanitizeException const& x) { - std::ostringstream ss; - ss << "Sanitization error: " << x.message(); - PyErr_SetString(PyExc_ValueError, ss.str().c_str()); -} - void wrap_molops(); BOOST_PYTHON_MODULE(rdmolops) { diff --git a/Code/GraphMol/Wrap/rough_test.py b/Code/GraphMol/Wrap/rough_test.py index f47619231..604c6d6e2 100644 --- a/Code/GraphMol/Wrap/rough_test.py +++ b/Code/GraphMol/Wrap/rough_test.py @@ -2089,6 +2089,7 @@ CAS<~> self.assertFalse(ri.IsBondInRingOfSize(1, 3)) self.assertFalse(ri.IsBondInRingOfSize(2, 3)) if hasattr(Chem,'FindRingFamilies'): self.assertEquals(ri.AtomRingFamilies(),()) + if hasattr(Chem,'FindRingFamilies'): self.assertEquals(ri.BondRingFamilies(),()) smi = 'C1CC2C1C2' @@ -2114,6 +2115,9 @@ CAS<~> self.assertTrue(ri.AreRingFamiliesInitialized()) self.assertEquals(ri.NumRingFamilies(),2) self.assertEquals(sorted(ri.AtomRingFamilies()),[(0, 1, 2, 3), (2, 3, 4)]) + self.assertEquals(sorted(ri.BondRingFamilies()),[(0, 1, 2, 4), (2, 3, 5)]) + + def test46ReplaceCore(self): """ test the ReplaceCore functionality diff --git a/Code/GraphMol/Wrap/test_list.py b/Code/GraphMol/Wrap/test_list.py deleted file mode 100755 index 52af218e6..000000000 --- a/Code/GraphMol/Wrap/test_list.py +++ /dev/null @@ -1,12 +0,0 @@ -tests = [ - ("python", "rough_test.py", {}), - ("python", "testConformer.py", {}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/GraphMol/test_list.py b/Code/GraphMol/test_list.py deleted file mode 100755 index 67d9ab65a..000000000 --- a/Code/GraphMol/test_list.py +++ /dev/null @@ -1,49 +0,0 @@ -import sys - -tests = [ - ("testExecs/itertest.exe", "", {}), - ("testExecs/MolOpsTest.exe", "", {}), - ("testExecs/testCanon.exe", "C1OCCC1 C1CCOC1", {}), - ("testExecs/testPickler.exe", "", {}), - ("testExecs/test1.exe", "", {}), - ("testExecs/testChirality.exe", "", {}), - ("python", "test_list.py", {'dir': 'Depictor'}), - ("python", "test_list.py", {'dir': 'FileParsers'}), - ("python", "test_list.py", {'dir': 'SmilesParse'}), - ("python", "test_list.py", {'dir': 'Substruct'}), - ("python", "test_list.py", {'dir': 'Subgraphs'}), - ("python", "test_list.py", {'dir': 'FragCatalog'}), - ("python", "test_list.py", {'dir': 'Fingerprints'}), - ("python", "test_list.py", {'dir': 'MolTransforms'}), - ("python", "test_list.py", {'dir': 'Wrap'}), - ("python", "test_list.py", {'dir': 'Depictor/Wrap'}), - ("python", "test_list.py", {'dir': 'FragCatalog/Wrap'}), - ("python", "test_list.py", {'dir': 'PartialCharges/Wrap'}), - ("python", "test_list.py", {'dir': 'ForceFieldHelpers'}), - ("python", "test_list.py", {'dir': 'DistGeomHelpers'}), - ("python", "test_list.py", {'dir': 'Descriptors'}), - ("python", "test_list.py", {'dir': 'Descriptors/Wrap'}), - ("python", "test_list.py", {'dir': 'MolChemicalFeatures'}), - ("python", "test_list.py", {'dir': 'MolAlign'}), - ("python", "test_list.py", {'dir': 'ShapeHelpers'}), - ("python", "test_list.py", {'dir': 'ChemTransforms'}), - ("python", "test_list.py", {'dir': 'MolCatalog'}), - ("python", "test_list.py", {'dir': 'MolCatalog/Wrap'}), - ("python", "test_list.py", {'dir': 'ChemReactions'}), - ("python", "test_list.py", {'dir': 'SLNParse'}), - ("python", "test_list.py", {'dir': 'SLNParse/Wrap'}), -] - -if sys.platform != 'win32': - tests.extend([ - ("testExecs/cptest.exe", "", {}), - ("testExecs/querytest.exe", "", {}), - ]) - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/ML/InfoTheory/Wrap/test_list.py b/Code/ML/InfoTheory/Wrap/test_list.py deleted file mode 100755 index be95a1eb3..000000000 --- a/Code/ML/InfoTheory/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testRanker.py", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/ML/test_list.py b/Code/ML/test_list.py deleted file mode 100755 index bb33be9ce..000000000 --- a/Code/ML/test_list.py +++ /dev/null @@ -1,12 +0,0 @@ -tests = [ - ("python", "test_list.py", {'dir': 'InfoTheory/Wrap'}), - ("python", "test_list.py", {'dir': 'FeatureSelect/Wrap'}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/Numerics/Alignment/Wrap/test_list.py b/Code/Numerics/Alignment/Wrap/test_list.py deleted file mode 100644 index 4043fb508..000000000 --- a/Code/Numerics/Alignment/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testAlignment.py", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/Numerics/Alignment/test_list.py b/Code/Numerics/Alignment/test_list.py deleted file mode 100755 index 39dd8fca7..000000000 --- a/Code/Numerics/Alignment/test_list.py +++ /dev/null @@ -1,14 +0,0 @@ -import sys - -tests = [ - ("testExecs/main.exe", "", {}), - ("python", "test_list.py", {'dir': 'Wrap'}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/Numerics/EigenSolvers/test_list.py b/Code/Numerics/EigenSolvers/test_list.py deleted file mode 100755 index 4872a348d..000000000 --- a/Code/Numerics/EigenSolvers/test_list.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys - -tests = [("testExecs/main.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/Numerics/Optimizer/test_list.py b/Code/Numerics/Optimizer/test_list.py deleted file mode 100755 index 5ee7d858c..000000000 --- a/Code/Numerics/Optimizer/test_list.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys - -tests = [("testExecs/testOptimizer.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/Numerics/testMatrices.cpp b/Code/Numerics/testMatrices.cpp index 871de3b32..05d119e87 100644 --- a/Code/Numerics/testMatrices.cpp +++ b/Code/Numerics/testMatrices.cpp @@ -1,6 +1,5 @@ -// $Id$ // -// Copyright (C) 2004-2006 Rational Discovery LLC +// Copyright (C) 2004-2019 Rational Discovery LLC // // @@ All Rights Reserved @@ // This file is part of the RDKit. @@ -99,6 +98,42 @@ void test2Matrix() { CHECK_INVARIANT(RDKit::feq(C.getVal(0, 1), 10), ""); CHECK_INVARIANT(RDKit::feq(C.getVal(1, 0), 10), ""); CHECK_INVARIANT(RDKit::feq(C.getVal(1, 1), 10.25), ""); + + auto Ccp(C); + Ccp += C; + CHECK_INVARIANT(RDKit::feq(Ccp.getVal(0, 0), 20.5), ""); + CHECK_INVARIANT(RDKit::feq(Ccp.getVal(0, 1), 20), ""); + CHECK_INVARIANT(RDKit::feq(Ccp.getVal(1, 0), 20), ""); + CHECK_INVARIANT(RDKit::feq(Ccp.getVal(1, 1), 20.5), ""); + + Ccp -= C; + CHECK_INVARIANT(RDKit::feq(Ccp.getVal(0, 0), 10.25), ""); + CHECK_INVARIANT(RDKit::feq(Ccp.getVal(0, 1), 10), ""); + CHECK_INVARIANT(RDKit::feq(Ccp.getVal(1, 0), 10), ""); + CHECK_INVARIANT(RDKit::feq(Ccp.getVal(1, 1), 10.25), ""); + + C *= 2.; + CHECK_INVARIANT(RDKit::feq(C.getVal(0, 0), 20.5), ""); + CHECK_INVARIANT(RDKit::feq(C.getVal(0, 1), 20), ""); + CHECK_INVARIANT(RDKit::feq(C.getVal(1, 0), 20), ""); + CHECK_INVARIANT(RDKit::feq(C.getVal(1, 1), 20.5), ""); + + C /= 2.; + CHECK_INVARIANT(RDKit::feq(C.getVal(0, 0), 10.25), ""); + CHECK_INVARIANT(RDKit::feq(C.getVal(0, 1), 10), ""); + CHECK_INVARIANT(RDKit::feq(C.getVal(1, 0), 10), ""); + CHECK_INVARIANT(RDKit::feq(C.getVal(1, 1), 10.25), ""); + + Vector tRow(A.numCols()); + A.getRow(1, tRow); + for (unsigned int i = 0; i < A.numCols(); ++i) { + TEST_ASSERT(RDKit::feq(A.getVal(1, i), tRow.getVal(i))); + } + Vector tCol(A.numRows()); + A.getCol(1, tCol); + for (unsigned int i = 0; i < A.numRows(); ++i) { + TEST_ASSERT(RDKit::feq(A.getVal(i, 1), tCol.getVal(i))); + } } void test3SquareMatrix() { diff --git a/Code/Numerics/test_list.py b/Code/Numerics/test_list.py deleted file mode 100755 index 839c2883c..000000000 --- a/Code/Numerics/test_list.py +++ /dev/null @@ -1,12 +0,0 @@ -tests = [ - ("python", "test_list.py", {'dir': 'Optimizer'}), - ("python", "test_list.py", {'dir': 'EigenSolvers'}), - ("python", "test_list.py", {'dir': 'Alignment'}), - ("testExecs/main.exe", "", {}), -] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/Query/test_list.py b/Code/Query/test_list.py deleted file mode 100755 index 7ad282b65..000000000 --- a/Code/Query/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("testExecs/test.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/RDGeneral/test_list.py b/Code/RDGeneral/test_list.py deleted file mode 100755 index 379655460..000000000 --- a/Code/RDGeneral/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("testExecs/testDict.exe", "", {}), ] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/SimDivPickers/Wrap/test_list.py b/Code/SimDivPickers/Wrap/test_list.py deleted file mode 100755 index 6676f30be..000000000 --- a/Code/SimDivPickers/Wrap/test_list.py +++ /dev/null @@ -1,9 +0,0 @@ -tests = [("python", "testPickers.py", {}), ("python", "testMaxMin.py", {})] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed)) diff --git a/Code/test_list.py b/Code/test_list.py deleted file mode 100755 index 39000a579..000000000 --- a/Code/test_list.py +++ /dev/null @@ -1,28 +0,0 @@ -tests = [ - ("python", "test_list.py", {'dir': 'RDGeneral'}), - ("python", "test_list.py", {'dir': 'Geometry'}), - ("python", "test_list.py", {'dir': 'Geometry/Wrap'}), - ("python", "test_list.py", {'dir': 'DataStructs'}), - ("python", "test_list.py", {'dir': 'DataStructs/Wrap'}), - ("python", "test_list.py", {'dir': 'Query'}), - ("python", "test_list.py", {'dir': 'DataManip/MetricMatrixCalc'}), - ("python", "test_list.py", {'dir': 'DataManip/MetricMatrixCalc/Wrap'}), - ("python", "test_list.py", {'dir': 'ML/InfoTheory/Wrap'}), - ("python", "test_list.py", {'dir': 'Numerics'}), - ("python", "test_list.py", {'dir': 'ForceField'}), - ("python", "test_list.py", {'dir': 'DistGeom'}), - ("python", "test_list.py", {'dir': 'ChemicalFeatures'}), - ("python", "test_list.py", {'dir': 'ChemicalFeatures/Wrap'}), - #("python","test_list.py",{'dir':'PgSQL/RDLib'}), - ("python", "test_list.py", {'dir': 'SimDivPickers/Wrap'}), - ("python", "test_list.py", {'dir': 'ML'}), - ("python", "test_list.py", {'dir': 'GraphMol'}), -] - -longTests = [] - -if __name__ == '__main__': - import sys - from rdkit import TestRunner - failed, tests = TestRunner.RunScript('test_list.py', 0, 1) - sys.exit(len(failed))