Fix SMARTS for the strict definition of rotatable bonds (#9096)

This commit is contained in:
Jessica Braun
2026-02-09 17:50:12 +01:00
committed by GitHub
parent e89c9f656a
commit e4401cd1fc
4 changed files with 12 additions and 20 deletions

View File

@@ -104,7 +104,7 @@ const NumRotatableBondsOptions DefaultStrictDefinition = NonStrict;
#endif
} // namespace
const std::string NumRotatableBondsVersion = "3.1.0";
const std::string NumRotatableBondsVersion = "3.2.0";
unsigned int calcNumRotatableBonds(const ROMol &mol,
NumRotatableBondsOptions strict) {
if (strict == Default) {
@@ -118,10 +118,10 @@ unsigned int calcNumRotatableBonds(const ROMol &mol,
} else if (strict == Strict) {
std::string strict_pattern =
"[!$(*#*)&!D1&!$(C(F)(F)F)&!$(C(Cl)(Cl)Cl)&!$(C(Br)(Br)Br)&!$(C([CH3])("
"[CH3])[CH3])&!$([CD3](=[N,O,S])-!@[#7,O,S!D1])&!$([#7,O,S!D1]-!@[CD3]="
"[CH3])[CH3])&!$([CH3])&!$([CD3](=[N,O,S])-!@[#7,O,S!D1])&!$([#7,O,S!D1]-!@[CD3]="
"[N,O,S])&!$([CD3](=[N+])-!@[#7!D1])&!$([#7!D1]-!@[CD3]=[N+])]-,:;!@[!$"
"(*#*)&!D1&!$(C(F)(F)F)&!$(C(Cl)(Cl)Cl)&!$(C(Br)(Br)Br)&!$(C([CH3])(["
"CH3])[CH3])]";
"CH3])[CH3])&!$([CH3])]";
pattern_flyweight m(strict_pattern);
return m.get().countMatches(mol);
} else {

View File

@@ -195,6 +195,8 @@ TEST_CASE(
"molecule") {
SECTION("basics") {
auto m1 = "c1ccccc1c1ccc(CCC)cc1"_smiles;
auto m2 = "CCCC"_smiles;
MolOps::addHs(*m2);
CHECK(Descriptors::calcNumRotatableBonds(
*m1, Descriptors::NumRotatableBondsOptions::NonStrict) == 3);
CHECK(Descriptors::calcNumRotatableBonds(
@@ -208,6 +210,8 @@ TEST_CASE(
*m1, Descriptors::NumRotatableBondsOptions::Strict) == 3);
CHECK(Descriptors::calcNumRotatableBonds(
*m1, Descriptors::NumRotatableBondsOptions::StrictLinkages) == 2);
CHECK(Descriptors::calcNumRotatableBonds(
*m2, Descriptors::NumRotatableBondsOptions::Strict) == 1);
}
SECTION("as reported") {
SmilesParserParams ps;
@@ -731,4 +735,4 @@ TEST_CASE("Github #7264: GETAWAY descriptors are non-deterministic") {
}
}
}
#endif
#endif