Skip to content

Commit

Permalink
Fix for removing bad stereo indications from Atropisomer parsing (rdk…
Browse files Browse the repository at this point in the history
…it#7984)

* Fix for removing bad stereo indications

* removed one unneed change

* removed mistaken change
  • Loading branch information
tadhurst-cdd authored Dec 22, 2024
1 parent 454fe1c commit bebd2eb
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 1 deletion.
92 changes: 92 additions & 0 deletions Code/GraphMol/FileParsers/testAtropisomers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,84 @@ class MolAtropTest {
return;
}

void testAromAtropMolFile(const MolTest *molFileTest) {
BOOST_LOG(rdInfoLog) << "testing aromtizing mol files with atropisomers"
<< std::endl;

std::string rdbase = getenv("RDBASE");
std::string fName = rdbase +
"/Code/GraphMol/FileParsers/test_data/atropisomers/" +
molFileTest->fileName;

UseLegacyStereoPerceptionFixture useLegacy(false);

std::unique_ptr<RWMol> mol =
std::unique_ptr<RWMol>(MolFileToMol(fName, false, false, false));

TEST_ASSERT(mol->getNumAtoms() == molFileTest->atomCount)
TEST_ASSERT(mol->getNumBonds() == molFileTest->bondCount)

testAromAtropMol(mol.get(), molFileTest->expectedResult, fName);
}

void testAromAtropMol(RWMol *mol, bool expectedResult, std::string fName) {
try {
RDKit::Chirality::removeNonExplicit3DChirality(*mol);

auto sanitizeOps =
MolOps::SANITIZE_SETAROMATICITY + MolOps::SANITIZE_CLEANUPCHIRALITY +
MolOps::SANITIZE_SETHYBRIDIZATION + MolOps::SANITIZE_SETCONJUGATION;

unsigned int operationThatFailed = 0;
RDKit::MolOps::sanitizeMol(*mol, operationThatFailed, sanitizeOps);
for (const auto &atom : mol->atoms()) {
if (atom->getChiralTag() != Atom::CHI_UNSPECIFIED) {
BOOST_LOG(rdInfoLog) << "atom with stereo" << std::endl;
}
}
for (const auto &bond : mol->bonds()) {
if (bond->getBondDir() != Bond::BondDir::NONE) {
BOOST_LOG(rdInfoLog) << "bond with wedging" << std::endl;
}
}
{
SmilesWriteParams ps;
ps.canonical = true;
ps.doKekule = false;
ps.allBondsExplicit = false;
ps.allHsExplicit = false;
ps.doIsomericSmiles = true;
ps.doKekule = false;
ps.doRandom = false;
ps.rootedAtAtom = -1;

unsigned int flags = SmilesWrite::CXSmilesFields::CX_COORDS |
SmilesWrite::CXSmilesFields::CX_MOLFILE_VALUES |
SmilesWrite::CXSmilesFields::CX_ATOM_PROPS |
SmilesWrite::CXSmilesFields::CX_BOND_CFG |
SmilesWrite::CXSmilesFields::CX_ENHANCEDSTEREO;

std::string smilesOut =
MolToCXSmiles(*mol, ps, flags, RestoreBondDirOptionClear);
std::string expectedFileName = fName + ".expectedArom.cxsmi";

generateNewExpectedFilesIfSoSpecified(fName + ".NEWArom.cxsmi",
smilesOut);

TEST_ASSERT(GetExpectedValue(fName + ".expectedArom.cxsmi") ==
smilesOut);
}

BOOST_LOG(rdInfoLog) << "done" << std::endl;
} catch (const std::exception &e) {
if (expectedResult != false) {
throw;
}
return;
}
TEST_ASSERT(expectedResult == true);
}

void testKekuleWedgeError(RWMol *mol, std::string expectedSmi,
bool expectedResult, unsigned int expectedAtomCount,
unsigned int expectedBondCount) {
Expand Down Expand Up @@ -381,6 +459,20 @@ class MolAtropTest {
}
}

if (testToRun == "" || testToRun == "AromAtropMol") {
std::list<MolTest> sdfTests{
MolTest("BMS-986142_atrop1.sdf", true, 42, 47),
MolTest("BMS-986142_3d_chiral.sdf", true, 72, 77),
MolTest("BMS-986142_3d.sdf", true, 72, 77),
};

for (auto sdfTest : sdfTests) {
BOOST_LOG(rdInfoLog) << "Test: " << sdfTest.fileName << std::endl;

testAromAtropMolFile(&sdfTest);
}
}

if (testToRun == "" || testToRun == "KekuleWedgeError") {
std::list<KekuleTest> kekuleTests{
KekuleTest(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[H]OC(C([H])([H])[H])(C([H])([H])[H])C1([H])C([H])([H])c2c(c3c(-c4c([H])c([H])c([H])c(-n5c(=O)c6c([H])c([H])c([H])c(F)c6n(C([H])([H])[H])c5=O)c4C([H])([H])[H])c(F)c([H])c(C(=O)N([H])[H])c3n2[H])C([H])([H])C1([H])[H] |(-2.128,1.9287,2.9199;-2.112,1.5747,2.4382;-2.4335,2.0277,1.7578;-1.9128,2.8014,1.6418;-2.0588,3.1185,1.0662;-1.2527,2.6718,1.666;-2.0211,3.2354,2.1466;-3.3209,2.2556,1.9643;-3.6328,2.5429,1.4415;-3.3403,2.6896,2.48;-3.6795,1.7235,2.1686;-2.4007,1.4836,0.9934;-2.6689,1.821,0.4719;-2.9136,0.6925,1.1267;-2.7776,0.4065,1.7216;-3.5722,0.834,1.1115;-2.7239,0.0857,0.4696;-2.0583,0.1027,-0.0552;-2.1142,-0.6018,-0.5711;-1.6332,-0.9186,-1.2186;-0.9031,-0.4893,-1.4844;-0.9727,0.1003,-2.1031;-1.5642,0.2383,-2.3831;-0.2773,0.5242,-2.3716;-0.3315,0.9837,-2.8531;0.4878,0.3584,-2.0214;1.0254,0.6927,-2.2354;0.5573,-0.2316,-1.4028;1.3588,-0.3932,-1.0482;1.5905,0.0773,-0.3585;1.2002,0.6554,-0.0665;2.3933,-0.1194,0.0095;2.6386,0.2956,0.7262;2.2428,0.7475,1.0192;3.4017,0.1354,1.0788;3.5896,0.457,1.6328;3.9217,-0.4363,0.7167;4.5184,-0.5645,0.9877;3.6768,-0.8489,0.0041;4.2097,-1.3952,-0.3066;2.9068,-0.6967,-0.3594;2.6425,-1.1179,-1.0794;3.1982,-1.7169,-1.457;3.3106,-2.2227,-1.0278;3.7704,-1.4129,-1.6385;2.9318,-1.9829,-2.0144;1.8575,-1.0047,-1.4246;1.6168,-1.4364,-2.0026;-0.138,-0.6553,-1.1342;-0.0582,-1.2887,-0.4699;-0.2862,-1.8851,-0.6843;0.5723,-1.396,-0.2643;-0.4068,-1.1014,0.0747;-1.8741,-1.6494,-1.6034;-1.4248,-1.9619,-2.2208;-2.581,-2.0639,-1.3539;-2.7202,-2.6244,-1.6865;-3.069,-1.7619,-0.7143;-3.8054,-2.1982,-0.4602;-4.2532,-1.9338,0.1012;-4.0043,-2.9212,-0.8738;-3.6777,-3.1773,-1.3373;-4.5184,-3.2354,-0.7104;-2.8218,-1.0304,-0.3345;-3.1799,-0.5981,0.3004;-3.7005,-0.7644,0.5964;-1.4396,0.7778,-0.0395;-0.8137,0.538,-0.0869;-1.5466,1.1855,-0.5657;-1.4992,1.2797,0.7621;-1.2099,0.9291,1.2614;-1.1302,1.8345,0.67),wU:28.28|
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[H:0][O:0][C:0]([C:0]([H:0])([H:0])[H:0])([C:0]([H:0])([H:0])[H:0])[C@:0]1([H:0])[C:0]([H:0])([H:0])[c:0]2[c:0]([c:0]3[c:0](-[c:0]4[c:0]([H:0])[c:0]([H:0])[c:0]([H:0])[c:0](-[n:0]5[c:0](=[O:0])[c:0]6[c:0]([H:0])[c:0]([H:0])[c:0]([H:0])[c:0]([F:0])[c:0]6[n:0]([C:0]([H:0])([H:0])[H:0])[c:0]5=[O:0])[c:0]4[C:0]([H:0])([H:0])[H:0])[c:0]([F:0])[c:0]([H:0])[c:0]([C:0](=[O:0])[N:0]([H:0])[H:0])[c:0]3[n:0]2[H:0])[C:0]([H:0])([H:0])[C:0]1([H:0])[H:0] |(-1.784,2.6885,-15353.5;-1.7706,2.244,-15353.7;-2.0401,2.2783,-15354.4;-1.6036,2.7864,-15354.8;-1.726,2.7756,-15355.4;-1.0502,2.7191,-15354.7;-1.6944,3.3158,-15354.6;-2.7841,2.5509,-15354.3;-3.0456,2.5184,-15354.8;-2.8004,3.0803,-15354.1;-3.0848,2.2449,-15353.9;-2.0126,1.5618,-15354.7;-2.2375,1.5925,-15355.2;-2.4426,1.041,-15354.3;-2.3286,1.1012,-15353.7;-2.9948,1.1437,-15354.3;-2.2836,0.3326,-15354.5;-1.7256,0.1306,-15354.9;-1.7725,-0.5951,-15355;-1.3692,-1.0929,-15355.3;-0.7571,-0.8884,-15355.6;-0.8155,-0.7282,-15356.4;-1.3113,-0.7619,-15356.7;-0.2325,-0.5275,-15356.7;-0.2779,-0.4082,-15357.3;0.4089,-0.514,-15356.4;0.8596,-0.3516,-15356.7;0.4671,-0.6745,-15355.7;1.1391,-0.6579,-15355.4;1.3334,-0.0217,-15355.1;1.0062,0.5319,-15355.1;2.0064,-0.0037,-15354.7;2.2121,0.5921,-15354.4;1.8803,1.0542,-15354.4;2.8519,0.6365,-15354.1;3.0094,1.0843,-15353.8;3.2878,0.0607,-15354.1;3.7881,0.0748,-15353.9;3.0825,-0.5334,-15354.4;3.5292,-1.064,-15354.4;2.437,-0.5836,-15354.8;2.2153,-1.1841,-15355.1;2.6813,-1.7797,-15355.1;2.7755,-1.9594,-15354.6;3.161,-1.6393,-15355.4;2.4579,-2.2139,-15355.4;1.5572,-1.2626,-15355.4;1.3554,-1.8171,-15355.7;-0.1157,-0.875,-15355.3;-0.0488,-1.067,-15354.6;-0.2399,-1.5804,-15354.5;0.4797,-1.0378,-15354.4;-0.341,-0.6899,-15354.3;-1.5711,-1.7842,-15355.3;-1.1945,-2.279,-15355.6;-2.1638,-1.9781,-15354.9;-2.2805,-2.5457,-15354.9;-2.5729,-1.4909,-15354.6;-3.1903,-1.7006,-15354.2;-3.5657,-1.2943,-15353.9;-3.3571,-2.413,-15354.2;-3.0833,-2.7864,-15354.4;-3.7881,-2.5608,-15353.9;-2.3657,-0.7991,-15354.6;-2.6659,-0.2442,-15354.4;-3.1024,-0.231,-15354.1;-1.2069,0.6208,-15355.2;-0.6821,0.4199,-15355.1;-1.2966,0.7025,-15355.7;-1.2568,1.3334,-15354.8;-1.0143,1.2664,-15354.3;-0.9475,1.6827,-15355.1),atomProp:0.molStereoCare.0:0.molAtomMapNumber.0:0.molInversionFlag.0:0.molExactChangeFlag.0:1.molStereoCare.0:1.molAtomMapNumber.0:1.molInversionFlag.0:1.molExactChangeFlag.0:2.molStereoCare.0:2.molAtomMapNumber.0:2.molInversionFlag.0:2.molExactChangeFlag.0:3.molStereoCare.0:3.molAtomMapNumber.0:3.molInversionFlag.0:3.molExactChangeFlag.0:4.molStereoCare.0:4.molAtomMapNumber.0:4.molInversionFlag.0:4.molExactChangeFlag.0:5.molStereoCare.0:5.molAtomMapNumber.0:5.molInversionFlag.0:5.molExactChangeFlag.0:6.molStereoCare.0:6.molAtomMapNumber.0:6.molInversionFlag.0:6.molExactChangeFlag.0:7.molStereoCare.0:7.molAtomMapNumber.0:7.molInversionFlag.0:7.molExactChangeFlag.0:8.molStereoCare.0:8.molAtomMapNumber.0:8.molInversionFlag.0:8.molExactChangeFlag.0:9.molStereoCare.0:9.molAtomMapNumber.0:9.molInversionFlag.0:9.molExactChangeFlag.0:10.molStereoCare.0:10.molAtomMapNumber.0:10.molInversionFlag.0:10.molExactChangeFlag.0:11.molStereoCare.0:11.molAtomMapNumber.0:11.molInversionFlag.0:11.molExactChangeFlag.0:12.molStereoCare.0:12.molAtomMapNumber.0:12.molInversionFlag.0:12.molExactChangeFlag.0:13.molStereoCare.0:13.molAtomMapNumber.0:13.molInversionFlag.0:13.molExactChangeFlag.0:14.molStereoCare.0:14.molAtomMapNumber.0:14.molInversionFlag.0:14.molExactChangeFlag.0:15.molStereoCare.0:15.molAtomMapNumber.0:15.molInversionFlag.0:15.molExactChangeFlag.0:16.molStereoCare.0:16.molAtomMapNumber.0:16.molInversionFlag.0:16.molExactChangeFlag.0:17.molStereoCare.0:17.molAtomMapNumber.0:17.molInversionFlag.0:17.molExactChangeFlag.0:18.molStereoCare.0:18.molAtomMapNumber.0:18.molInversionFlag.0:18.molExactChangeFlag.0:19.molStereoCare.0:19.molAtomMapNumber.0:19.molInversionFlag.0:19.molExactChangeFlag.0:20.molStereoCare.0:20.molAtomMapNumber.0:20.molInversionFlag.0:20.molExactChangeFlag.0:21.molStereoCare.0:21.molAtomMapNumber.0:21.molInversionFlag.0:21.molExactChangeFlag.0:22.molStereoCare.0:22.molAtomMapNumber.0:22.molInversionFlag.0:22.molExactChangeFlag.0:23.molStereoCare.0:23.molAtomMapNumber.0:23.molInversionFlag.0:23.molExactChangeFlag.0:24.molStereoCare.0:24.molAtomMapNumber.0:24.molInversionFlag.0:24.molExactChangeFlag.0:25.molStereoCare.0:25.molAtomMapNumber.0:25.molInversionFlag.0:25.molExactChangeFlag.0:26.molStereoCare.0:26.molAtomMapNumber.0:26.molInversionFlag.0:26.molExactChangeFlag.0:27.molStereoCare.0:27.molAtomMapNumber.0:27.molInversionFlag.0:27.molExactChangeFlag.0:28.molStereoCare.0:28.molAtomMapNumber.0:28.molInversionFlag.0:28.molExactChangeFlag.0:29.molStereoCare.0:29.molAtomMapNumber.0:29.molInversionFlag.0:29.molExactChangeFlag.0:30.molStereoCare.0:30.molAtomMapNumber.0:30.molInversionFlag.0:30.molExactChangeFlag.0:31.molStereoCare.0:31.molAtomMapNumber.0:31.molInversionFlag.0:31.molExactChangeFlag.0:32.molStereoCare.0:32.molAtomMapNumber.0:32.molInversionFlag.0:32.molExactChangeFlag.0:33.molStereoCare.0:33.molAtomMapNumber.0:33.molInversionFlag.0:33.molExactChangeFlag.0:34.molStereoCare.0:34.molAtomMapNumber.0:34.molInversionFlag.0:34.molExactChangeFlag.0:35.molStereoCare.0:35.molAtomMapNumber.0:35.molInversionFlag.0:35.molExactChangeFlag.0:36.molStereoCare.0:36.molAtomMapNumber.0:36.molInversionFlag.0:36.molExactChangeFlag.0:37.molStereoCare.0:37.molAtomMapNumber.0:37.molInversionFlag.0:37.molExactChangeFlag.0:38.molStereoCare.0:38.molAtomMapNumber.0:38.molInversionFlag.0:38.molExactChangeFlag.0:39.molStereoCare.0:39.molAtomMapNumber.0:39.molInversionFlag.0:39.molExactChangeFlag.0:40.molStereoCare.0:40.molAtomMapNumber.0:40.molInversionFlag.0:40.molExactChangeFlag.0:41.molStereoCare.0:41.molAtomMapNumber.0:41.molInversionFlag.0:41.molExactChangeFlag.0:42.molStereoCare.0:42.molAtomMapNumber.0:42.molInversionFlag.0:42.molExactChangeFlag.0:43.molStereoCare.0:43.molAtomMapNumber.0:43.molInversionFlag.0:43.molExactChangeFlag.0:44.molStereoCare.0:44.molAtomMapNumber.0:44.molInversionFlag.0:44.molExactChangeFlag.0:45.molStereoCare.0:45.molAtomMapNumber.0:45.molInversionFlag.0:45.molExactChangeFlag.0:46.molStereoCare.0:46.molAtomMapNumber.0:46.molInversionFlag.0:46.molExactChangeFlag.0:47.molStereoCare.0:47.molAtomMapNumber.0:47.molInversionFlag.0:47.molExactChangeFlag.0:48.molStereoCare.0:48.molAtomMapNumber.0:48.molInversionFlag.0:48.molExactChangeFlag.0:49.molStereoCare.0:49.molAtomMapNumber.0:49.molInversionFlag.0:49.molExactChangeFlag.0:50.molStereoCare.0:50.molAtomMapNumber.0:50.molInversionFlag.0:50.molExactChangeFlag.0:51.molStereoCare.0:51.molAtomMapNumber.0:51.molInversionFlag.0:51.molExactChangeFlag.0:52.molStereoCare.0:52.molAtomMapNumber.0:52.molInversionFlag.0:52.molExactChangeFlag.0:53.molStereoCare.0:53.molAtomMapNumber.0:53.molInversionFlag.0:53.molExactChangeFlag.0:54.molStereoCare.0:54.molAtomMapNumber.0:54.molInversionFlag.0:54.molExactChangeFlag.0:55.molStereoCare.0:55.molAtomMapNumber.0:55.molInversionFlag.0:55.molExactChangeFlag.0:56.molStereoCare.0:56.molAtomMapNumber.0:56.molInversionFlag.0:56.molExactChangeFlag.0:57.molStereoCare.0:57.molAtomMapNumber.0:57.molInversionFlag.0:57.molExactChangeFlag.0:58.molStereoCare.0:58.molAtomMapNumber.0:58.molInversionFlag.0:58.molExactChangeFlag.0:59.molStereoCare.0:59.molAtomMapNumber.0:59.molInversionFlag.0:59.molExactChangeFlag.0:60.molStereoCare.0:60.molAtomMapNumber.0:60.molInversionFlag.0:60.molExactChangeFlag.0:61.molStereoCare.0:61.molAtomMapNumber.0:61.molInversionFlag.0:61.molExactChangeFlag.0:62.molStereoCare.0:62.molAtomMapNumber.0:62.molInversionFlag.0:62.molExactChangeFlag.0:63.molStereoCare.0:63.molAtomMapNumber.0:63.molInversionFlag.0:63.molExactChangeFlag.0:64.molStereoCare.0:64.molAtomMapNumber.0:64.molInversionFlag.0:64.molExactChangeFlag.0:65.molStereoCare.0:65.molAtomMapNumber.0:65.molInversionFlag.0:65.molExactChangeFlag.0:66.molStereoCare.0:66.molAtomMapNumber.0:66.molInversionFlag.0:66.molExactChangeFlag.0:67.molStereoCare.0:67.molAtomMapNumber.0:67.molInversionFlag.0:67.molExactChangeFlag.0:68.molStereoCare.0:68.molAtomMapNumber.0:68.molInversionFlag.0:68.molExactChangeFlag.0:69.molStereoCare.0:69.molAtomMapNumber.0:69.molInversionFlag.0:69.molExactChangeFlag.0:70.molStereoCare.0:70.molAtomMapNumber.0:70.molInversionFlag.0:70.molExactChangeFlag.0:71.molStereoCare.0:71.molAtomMapNumber.0:71.molInversionFlag.0:71.molExactChangeFlag.0,wD:11.11,wU:28.28|
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cc1c(-c2c(F)cc(C(N)=O)c3nc4c(c23)CC[C@H](C(C)(C)O)C4)cccc1-n1c(=O)c2cccc(F)c2n(C)c1=O |(2.0747,-0.3011,;1.3556,-0.7053,;0.6459,-0.2846,;0.6554,0.5402,;1.4029,0.9642,;2.1158,0.5489,;1.403,1.8235,;0.6555,2.2474,;0.6459,3.0723,;1.3556,3.4931,;-0.0731,3.4765,;-0.0819,1.8063,;-0.8665,2.0612,;-1.3515,1.3938,;-0.8665,0.7264,;-0.0819,0.9813,;-1.2039,-0.0639,;-2.0578,-0.1602,;-2.5629,0.5349,;-3.3837,0.4518,;-3.4668,1.2725,;-3.3006,-0.369,;-4.2045,0.3687,;-2.2074,1.3172,;-0.0732,-0.6889,;-0.0827,-1.5137,;0.6268,-1.9345,;1.346,-1.5302,;2.3682,-1.8618,;2.9748,-1.3027,;2.794,-0.4978,;3.7623,-1.5486,;4.3851,-0.9565,;5.2074,-1.2063,;5.3958,-2.0448,;4.7594,-2.6222,;4.9309,-3.4292,;3.9431,-2.3535,;3.3364,-2.9126,;3.5173,-3.7175,;2.549,-2.6667,;1.9423,-3.2258,),wD:18.20,wU:28.45|
6 changes: 5 additions & 1 deletion Code/GraphMol/FindStereo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ StereoInfo getStereoInfo(const Bond *bond) {
UNDER_CONSTRUCTION("unrecognized bond stereo type");
}
} else {
UNDER_CONSTRUCTION("unsupported bond type in getStereoInfo()");
sinfo.type = StereoType::Unspecified;
}

return sinfo;
Expand Down Expand Up @@ -850,6 +850,10 @@ bool updateBonds(ROMol &mol, const std::vector<unsigned int> &aranks,
auto bidx = bond->getIdx();
if (knownBonds[bidx] || possibleBonds[bidx]) {
auto sinfo = detail::getStereoInfo(bond);
if (sinfo.type == Chirality::StereoType::Unspecified) {
continue; // not a double bond nor an atropisomer bond
}

ASSERT_INVARIANT(sinfo.controllingAtoms.size() == 4,
"bad controlling atoms size");

Expand Down

0 comments on commit bebd2eb

Please sign in to comment.