Skip to content

Commit

Permalink
Fixes rdkit#7414
Browse files Browse the repository at this point in the history
  • Loading branch information
greglandrum committed May 2, 2024
1 parent 187d2ca commit b16fbc3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Code/GraphMol/MolDraw2D/Wrap/testMolDraw2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,13 @@ def testQueryColour(self):
text = d2d.GetDrawingText()
self.assertTrue("#7F7F7F" not in text)

def testGithub7409(self):
m = Chem.MolFromSmiles('CC |(-0.75,0,;0.75,0,)|')
m.GetConformer().SetId(5)
d2d = rdMolDraw2D.MolDraw2DCairo(200, 200)
# it's enough to check that this doesn't throw an exception
d2d.DrawMolecule(m)


if __name__ == "__main__":
unittest.main()
15 changes: 15 additions & 0 deletions Code/GraphMol/MolDraw2D/catch_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9506,3 +9506,18 @@ M END)CTAB"_ctab;
outs.close();
}
}

#ifdef RDK_BUILD_CAIRO_SUPPORT
TEST_CASE(
"github #7409: drawing mol with a non zero confID results in bad confID error") {
SECTION("basics") {
auto m = "CC |(-0.75,0,;0.75,0,)|"_smiles;
REQUIRE(m);
CHECK(m->getNumConformers() == 1);
m->getConformer().setId(5);
MolDraw2DCairo drawer(350, 300);
// it's enough to test that this doesn't throw
drawer.drawMolecule(*m);
}
}
#endif
2 changes: 1 addition & 1 deletion Code/GraphMol/SmilesParse/CXSmilesOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ std::string get_bond_config_block(
int dirCode;
bool reverse;
Chirality::GetMolFileBondStereoInfo(
bond, wedgeBonds, &mol.getConformer(0), dirCode, reverse);
bond, wedgeBonds, &mol.getConformer(), dirCode, reverse);
switch (dirCode) {
case 1:
bd = Bond::BondDir::BEGINWEDGE;
Expand Down
10 changes: 10 additions & 0 deletions Code/GraphMol/SmilesParse/cxsmiles_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1468,3 +1468,13 @@ TEST_CASE("write attachment points") {
m->getAtomWithIdx(5)->setProp(common_properties::_fromAttachPoint, 2);
CHECK(MolToCXSmiles(*m) == "*N[C@@H](C)C(*)=O |$_AP1;;;;;_AP2;$|");
}

TEST_CASE("github #7414: CXSmiles writer does not use default conformer ID") {
SECTION("basics") {
auto m = "CC |(-0.75,0,;0.75,0,)|"_smiles;
REQUIRE(m);
CHECK(m->getNumConformers() == 1);
m->getConformer().setId(5);
CHECK(MolToCXSmiles(*m) == "CC |(-0.75,0,;0.75,0,)|");
}
}

0 comments on commit b16fbc3

Please sign in to comment.