mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
Fix indexing of heavy atoms in PubChemShape (#8417)
* Fix indexing of heavy atoms. * Increment j. Doh! * Add include guard for the hpp. --------- Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
This commit is contained in:
9
External/pubchem_shape/PubChemShape.cpp
vendored
9
External/pubchem_shape/PubChemShape.cpp
vendored
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
5
External/pubchem_shape/PubChemShape.hpp
vendored
5
External/pubchem_shape/PubChemShape.hpp
vendored
@@ -2,6 +2,9 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#ifndef RDKIT_PUBCHEMSHAPE_GUARD
|
||||
#define RDKIT_PUBCHEMSHAPE_GUARD
|
||||
|
||||
//! The input for the pubchem shape alignment code
|
||||
struct RDKIT_PUBCHEMSHAPE_EXPORT ShapeInput {
|
||||
std::vector<float> coord;
|
||||
@@ -66,3 +69,5 @@ RDKIT_PUBCHEMSHAPE_EXPORT std::pair<double, double> 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
|
||||
4
External/pubchem_shape/test.cpp
vendored
4
External/pubchem_shape/test.cpp
vendored
@@ -278,7 +278,7 @@ TEST_CASE("Github #8096") {
|
||||
REQUIRE(m2);
|
||||
std::vector<float> 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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user