Fixes the problems with wiggly bonds and EnumerateStereoisomers from #8508 (#8598)

This commit is contained in:
Greg Landrum
2025-06-25 09:25:11 +02:00
committed by GitHub
parent 42a2874045
commit 05be3872f0
4 changed files with 50 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
//
// Copyright (C) David Cosgrove 2025.
// Copyright (C) 2025 David Cosgrove and other RDKit contributors.
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
@@ -34,7 +34,8 @@ StereoisomerEnumerator::StereoisomerEnumerator(
atom->clearProp("_CIPCode");
}
for (auto bond : d_mol.bonds()) {
if (bond->getBondDir() == Bond::BondDir::EITHERDOUBLE) {
if (bond->getBondDir() == Bond::BondDir::EITHERDOUBLE ||
bond->getBondDir() == Bond::BondDir::UNKNOWN) {
bond->setBondDir(Bond::BondDir::NONE);
}
}

View File

@@ -1,5 +1,5 @@
//
// Copyright (C) David Cosgrove 2025.
// Copyright (C) 2025 David Cosgrove and other RDKit contributors.
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
@@ -522,3 +522,34 @@ M END)CTAB"_ctab;
CHECK(got.size() == 2);
}
}
TEST_CASE("wiggly bonds and EnumerateStereoisomers") {
SECTION("as reported (bonds)") {
auto m1 = "CC=CC |w:1.0|"_smiles;
REQUIRE(m1);
StereoEnumerationOptions opts;
opts.onlyUnassigned = false;
StereoisomerEnumerator enu1(*m1, opts);
std::vector<std::string> got;
while (auto isomer = enu1.next()) {
got.push_back(MolToSmiles(*isomer));
}
CHECK(got.size() == 2);
CHECK(std::find(got.begin(), got.end(), "C/C=C/C") != got.end());
CHECK(std::find(got.begin(), got.end(), "C/C=C\\C") != got.end());
}
SECTION("chiral centers") {
auto m1 = "CC(F)(Cl)(Br) |w:1.0|"_smiles;
REQUIRE(m1);
StereoEnumerationOptions opts;
opts.onlyUnassigned = false;
StereoisomerEnumerator enu1(*m1, opts);
std::vector<std::string> got;
while (auto isomer = enu1.next()) {
got.push_back(MolToSmiles(*isomer));
}
CHECK(got.size() == 2);
CHECK(std::find(got.begin(), got.end(), "C[C@](F)(Cl)Br") != got.end());
CHECK(std::find(got.begin(), got.end(), "C[C@@](F)(Cl)Br") != got.end());
}
}