From c5794ad75df9bced7a0d5571729b5e66f21b6f91 Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Fri, 12 Apr 2024 15:18:09 +0900 Subject: [PATCH 1/3] fix(fmt/smi): use correct bond order sum for smiles string --- src/fmt/smiles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fmt/smiles.cpp b/src/fmt/smiles.cpp index a2a9c555..c827d3eb 100644 --- a/src/fmt/smiles.cpp +++ b/src/fmt/smiles.cpp @@ -446,7 +446,7 @@ void update_implicit_hydrogens(Molecule::MutableAtom atom) { // Required for correct bond order calculation atom.data().set_implicit_hydrogens(0); - int sum_bo = internal::sum_bond_order(atom, false), normal_valence; + int sum_bo = sum_bond_order(atom), normal_valence; switch (atom.data().atomic_number()) { case 0: From 4c6e5fc486070de5c98711d9feea50335dcc9f36 Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Fri, 12 Apr 2024 15:20:49 +0900 Subject: [PATCH 2/3] test(core): add stricter checks to sanitizer test --- test/core/molecule_test.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/core/molecule_test.cpp b/test/core/molecule_test.cpp index 89ae99f1..b996fb28 100644 --- a/test/core/molecule_test.cpp +++ b/test/core/molecule_test.cpp @@ -1120,6 +1120,13 @@ TEST(SanitizeTest, Samples) { for (auto atom: mol) EXPECT_EQ(atom.data().is_aromatic(), atom.id() != 0) << atom.id(); + for (int i: { 1, 2, 5, 6, 7 }) { + auto atom = mol.atom(i); + EXPECT_EQ(atom.data().hybridization(), kSP2) << i; + EXPECT_EQ(atom.data().implicit_hydrogens(), 0) << i; + EXPECT_EQ(atom.data().formal_charge(), 0) << i; + } + mol.clear(); { From 05b89cc2e26a24dc31c081f5694969ad40176255 Mon Sep 17 00:00:00 2001 From: Nuri Jung Date: Fri, 12 Apr 2024 15:23:43 +0900 Subject: [PATCH 3/3] test(fmt/smi): add test for implicit hydrogen count --- test/fmt/smiles_test.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/fmt/smiles_test.cpp b/test/fmt/smiles_test.cpp index 8f7f1632..63885e44 100644 --- a/test/fmt/smiles_test.cpp +++ b/test/fmt/smiles_test.cpp @@ -694,6 +694,11 @@ TEST_F(SmilesTest, DUDEExamplesTest) { std::string smi; NURI_FMT_TEST_NEXT_MOL("C02302104", 26, 29); + + // GH-298 + EXPECT_EQ(mol()[13].data().implicit_hydrogens(), 0); + EXPECT_EQ(mol()[13].data().formal_charge(), 0); + write_smiles(smi, mol()); set_test_string(smi);