diff --git a/External/pubchem_shape/PubChemShape.cpp b/External/pubchem_shape/PubChemShape.cpp index 014fa3676..e25b44c18 100644 --- a/External/pubchem_shape/PubChemShape.cpp +++ b/External/pubchem_shape/PubChemShape.cpp @@ -283,15 +283,16 @@ ShapeInput PrepareConformer(const ROMol &mol, int confId, bool useColors) { res.shift = {-ave.x, -ave.y, -ave.z}; res.coord.resize(nAlignmentAtoms * 3); - for (unsigned i = 0; i < nAtoms; ++i) { + for (unsigned i = 0, j = 0; i < nAtoms; ++i) { // use only non-H for alignment if (mol.getAtomWithIdx(i)->getAtomicNum() > 1) { RDGeom::Point3D pos = conformer.getAtomPos(i); pos -= ave; - res.coord[i * 3] = pos.x; - res.coord[(i * 3) + 1] = pos.y; - res.coord[(i * 3) + 2] = pos.z; + res.coord[j * 3] = pos.x; + res.coord[(j * 3) + 1] = pos.y; + res.coord[(j * 3) + 2] = pos.z; + ++j; } } diff --git a/External/pubchem_shape/PubChemShape.hpp b/External/pubchem_shape/PubChemShape.hpp index 245dba9d0..a55064f9d 100644 --- a/External/pubchem_shape/PubChemShape.hpp +++ b/External/pubchem_shape/PubChemShape.hpp @@ -2,6 +2,9 @@ #include #include +#ifndef RDKIT_PUBCHEMSHAPE_GUARD +#define RDKIT_PUBCHEMSHAPE_GUARD + //! The input for the pubchem shape alignment code struct RDKIT_PUBCHEMSHAPE_EXPORT ShapeInput { std::vector coord; @@ -66,3 +69,5 @@ RDKIT_PUBCHEMSHAPE_EXPORT std::pair AlignMolecule( int refConfId = -1, int fitConfId = -1, bool useColors = true, double opt_param = 1.0, unsigned int max_preiters = 10u, unsigned int max_postiters = 30u); + +#endif \ No newline at end of file diff --git a/External/pubchem_shape/test.cpp b/External/pubchem_shape/test.cpp index 9dd34e290..737b09415 100644 --- a/External/pubchem_shape/test.cpp +++ b/External/pubchem_shape/test.cpp @@ -278,7 +278,7 @@ TEST_CASE("Github #8096") { REQUIRE(m2); std::vector matrix(12, 0.0); auto [nbr_st, nbr_ct] = AlignMolecule(*m1, *m2, matrix); - CHECK_THAT(nbr_st, Catch::Matchers::WithinAbs(0.940, 0.005)); - CHECK_THAT(nbr_ct, Catch::Matchers::WithinAbs(0.902, 0.005)); + CHECK_THAT(nbr_st, Catch::Matchers::WithinAbs(1.0, 0.005)); + CHECK_THAT(nbr_ct, Catch::Matchers::WithinAbs(1.0, 0.005)); } }