mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
normalizeDepiction() should always center coordinates on the coordinate centroid, irrespective of the canonicalize parameter (#8107)
* normalizeDepiction() should always center coordinates on the coordinate centroid, irrespective of the canonicalize parameter * Update Code/GraphMol/Depictor/catch_tests.cpp Co-authored-by: Greg Landrum <greg.landrum@gmail.com> * fix catch test --------- Co-authored-by: ptosco <paolo.tosco@novartis.com> Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
This commit is contained in:
@@ -1295,14 +1295,17 @@ double normalizeDepiction(RDKit::ROMol &mol, int confId, int canonicalize,
|
||||
}
|
||||
}
|
||||
std::unique_ptr<RDGeom::Transform3D> canonTrans;
|
||||
auto ctd = MolTransforms::computeCentroid(conf);
|
||||
if (canonicalize) {
|
||||
auto ctd = MolTransforms::computeCentroid(conf);
|
||||
canonTrans.reset(MolTransforms::computeCanonicalTransform(conf, &ctd));
|
||||
if (canonicalize < 0) {
|
||||
RDGeom::Transform3D rotate90;
|
||||
rotate90.SetRotation(0., 1., RDGeom::Point3D(0., 0., 1.));
|
||||
*canonTrans *= rotate90;
|
||||
}
|
||||
} else {
|
||||
canonTrans.reset(new RDGeom::Transform3D());
|
||||
canonTrans->SetTranslation(-ctd);
|
||||
}
|
||||
bool isScaleFactorSane = (scaleFactor > SCALE_FACTOR_THRESHOLD);
|
||||
if (isScaleFactorSane && fabs(scaleFactor - 1.0) > SCALE_FACTOR_THRESHOLD) {
|
||||
|
||||
@@ -2272,3 +2272,68 @@ M END
|
||||
*methotrexateAnalog, *methotrexate, -1, refPatt.get(), p);
|
||||
CHECK(match == expected);
|
||||
}
|
||||
|
||||
TEST_CASE("Normalize should always center in centroid, irrespective of canonicalize parameter") {
|
||||
auto m = R"CTAB(
|
||||
RDKit 2D
|
||||
|
||||
25 27 0 0 0 0 0 0 0 0999 V2000
|
||||
18.2425 6.6594 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
16.8948 6.0009 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
16.3808 7.4101 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
14.8817 7.3567 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
14.4692 5.9146 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
15.7134 5.0766 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
13.0271 6.3270 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
13.4395 7.7692 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
12.7114 9.0806 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
11.7156 5.5989 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
10.4294 6.3705 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
10.4545 7.8703 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
9.1179 5.6424 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
7.8316 6.4141 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
7.8568 7.9139 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
6.5705 8.6855 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
5.2591 7.9574 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
5.2339 6.4576 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
6.5202 5.6860 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
3.9728 8.7291 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
9.0928 4.1426 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
17.2187 8.6543 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
16.5602 10.0020 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
18.7151 8.5507 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
17.6905 4.7294 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 2 1 0
|
||||
2 3 1 0
|
||||
3 4 1 0
|
||||
4 5 1 0
|
||||
5 6 1 6
|
||||
5 7 1 0
|
||||
7 8 1 0
|
||||
8 9 2 0
|
||||
7 10 1 6
|
||||
10 11 1 0
|
||||
11 12 2 0
|
||||
11 13 1 0
|
||||
13 14 1 0
|
||||
14 15 2 0
|
||||
15 16 1 0
|
||||
16 17 2 0
|
||||
17 18 1 0
|
||||
18 19 2 0
|
||||
17 20 1 0
|
||||
13 21 1 6
|
||||
3 22 1 1
|
||||
22 23 2 0
|
||||
22 24 1 0
|
||||
2 25 1 0
|
||||
6 2 1 0
|
||||
8 4 1 0
|
||||
19 14 1 0
|
||||
M END)CTAB"_ctab;
|
||||
REQUIRE(m);
|
||||
RDDepict::normalizeDepiction(*m, -1, 0);
|
||||
auto ctd = MolTransforms::computeCentroid(m->getConformer());
|
||||
CHECK_THAT(ctd.x, Catch::Matchers::WithinAbs(0.0, 1.0e-4));
|
||||
CHECK_THAT(ctd.y, Catch::Matchers::WithinAbs(0.0, 1.0e-4));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user