Skip to content

Commit

Permalink
fixes #7295 (#7303)
Browse files Browse the repository at this point in the history
  • Loading branch information
greglandrum committed Mar 28, 2024
1 parent eebad84 commit 0a0b158
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 1 addition & 3 deletions Code/GraphMol/SmilesParse/SmilesWrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ std::string FragmentSmilesConstruct(
if (params.canonical && params.doIsomericSmiles) {
Canon::canonicalizeEnhancedStereo(mol, &ranks);
}

Canon::canonicalizeFragment(mol, atomIdx, colors, ranks, molStack,
bondsInPlay, bondSymbols, params.doIsomericSmiles,
params.doRandom);
Expand Down Expand Up @@ -521,11 +520,10 @@ std::string MolToSmiles(const ROMol &mol, const SmilesWriteParams &params,
// but that should not be:
if (params.doIsomericSmiles) {
tmol->setProp(common_properties::_doIsoSmiles, 1);
if (!mol.hasProp(common_properties::_StereochemDone)) {
if (!tmol->hasProp(common_properties::_StereochemDone)) {
MolOps::assignStereochemistry(*tmol, true);
}
}

if (!doingCXSmiles) {
// remove any stereo groups that may be present. Otherwise they will be
// used in the canonicalization
Expand Down
16 changes: 16 additions & 0 deletions Code/GraphMol/SmilesParse/catch_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2790,4 +2790,20 @@ TEST_CASE("leaks on unclosed rings") {
auto m = "C1C)foo"_smiles;
REQUIRE(!m);
}
}

TEST_CASE("Github #7295") {
SECTION("basics") {
auto m = "C[C@@H]1CC[C@@H](C(=O)O)CC1.Cl"_smiles;
REQUIRE(m);
auto smi1 = MolToSmiles(*m);
m->clearComputedProps();
auto smi2 = MolToSmiles(*m);
CHECK(smi1 == smi2);
auto m2(*m);
bool cleanIt=true;
MolOps::assignStereochemistry(m2, cleanIt);
auto smi3 = MolToSmiles(m2);
CHECK(smi1 == smi3);
}
}

0 comments on commit 0a0b158

Please sign in to comment.