mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
* Fixes #2437 getting the canonical atom ranking no longer results in molecules have a RingInfo structure that's been initialized but contains nothing. * update expected results for the MMPA tests
This commit is contained in:
@@ -63,8 +63,8 @@ class TestCase(unittest.TestCase):
|
||||
self.assertNotEqual(frags[1][1], '')
|
||||
self.assertNotEqual(frags[2][1], '')
|
||||
|
||||
self.assertEqual(frags[0][1], 'CO[*:1].c1ccc(cc1)[*:1]')
|
||||
self.assertEqual(frags[1][1], 'C[*:1].c1ccc(cc1)O[*:1]')
|
||||
self.assertEqual(frags[0][1], 'CO[*:1].c1ccc([*:1])cc1')
|
||||
self.assertEqual(frags[1][1], 'C[*:1].c1ccc(O[*:1])cc1')
|
||||
self.assertEqual(frags[2][0], 'O([*:1])[*:2]')
|
||||
self.assertEqual(frags[2][1], 'C[*:1].c1ccc([*:2])cc1')
|
||||
|
||||
@@ -78,7 +78,7 @@ class TestCase(unittest.TestCase):
|
||||
self.assertEqual(frags[0][0], '')
|
||||
self.assertNotEqual(frags[0][1], '')
|
||||
|
||||
self.assertEqual(frags[0][1], 'CO[*:1].c1ccc(cc1)[*:1]')
|
||||
self.assertEqual(frags[0][1], 'CO[*:1].c1ccc([*:1])cc1')
|
||||
|
||||
def test4(self):
|
||||
m = Chem.MolFromSmiles('Cc1ccccc1NC(=O)C(C)[NH+]1CCCC1') # ZINC00000051
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <GraphMol/RDKitBase.h>
|
||||
#include <GraphMol/new_canon.h>
|
||||
#include <GraphMol/RDKitQueries.h>
|
||||
#include <GraphMol/Chirality.h>
|
||||
#include <GraphMol/FileParsers/FileParsers.h>
|
||||
@@ -11,7 +12,7 @@
|
||||
#include <GraphMol/SmilesParse/SmartsWrite.h>
|
||||
|
||||
using namespace RDKit;
|
||||
|
||||
#if 1
|
||||
TEST_CASE("SMILES Parsing works", "[molops]") {
|
||||
std::unique_ptr<RWMol> mol(SmilesToMol("C1CC1"));
|
||||
REQUIRE(mol);
|
||||
@@ -255,6 +256,69 @@ TEST_CASE("github #908: AddHs() using 3D coordinates with 2D conformations",
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
TEST_CASE("github #2437: Canon::rankMolAtoms results in crossed double bonds in rings",
|
||||
"[bug, molops]") {
|
||||
SECTION("underlying problem") {
|
||||
std::string molb=R"CTAB(testmol
|
||||
Mrv1824 05081910082D
|
||||
|
||||
4 4 0 0 0 0 999 V2000
|
||||
6.9312 -8.6277 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
6.9312 -9.4527 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
7.7562 -8.6277 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
7.7562 -9.4527 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 2 1 0 0 0 0
|
||||
1 3 1 0 0 0 0
|
||||
3 4 1 0 0 0 0
|
||||
2 4 2 0 0 0 0
|
||||
M END
|
||||
)CTAB";
|
||||
bool sanitize=false;
|
||||
bool removeHs=false;
|
||||
std::unique_ptr<RWMol> mol(MolBlockToMol(molb,sanitize,removeHs));
|
||||
REQUIRE(mol);
|
||||
mol->updatePropertyCache();
|
||||
CHECK(mol->getBondWithIdx(3)->getBondType()==Bond::BondType::DOUBLE);
|
||||
CHECK(mol->getBondWithIdx(3)->getBondDir()==Bond::BondDir::NONE);
|
||||
std::vector<unsigned int> ranks;
|
||||
CHECK(!mol->getRingInfo()->isInitialized());
|
||||
Canon::rankMolAtoms(*mol,ranks);
|
||||
CHECK(!mol->getRingInfo()->isInitialized());
|
||||
}
|
||||
|
||||
SECTION("as discovered") {
|
||||
std::string molb = R"CTAB(testmol
|
||||
Mrv1824 05081910082D
|
||||
|
||||
4 4 0 0 0 0 999 V2000
|
||||
6.9312 -8.6277 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
6.9312 -9.4527 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
7.7562 -8.6277 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
7.7562 -9.4527 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 2 1 0 0 0 0
|
||||
1 3 1 0 0 0 0
|
||||
3 4 1 0 0 0 0
|
||||
2 4 2 0 0 0 0
|
||||
M END
|
||||
)CTAB";
|
||||
bool sanitize = false;
|
||||
bool removeHs = false;
|
||||
std::unique_ptr<RWMol> mol(MolBlockToMol(molb, sanitize, removeHs));
|
||||
REQUIRE(mol);
|
||||
mol->updatePropertyCache();
|
||||
CHECK(mol->getBondWithIdx(3)->getBondType() == Bond::BondType::DOUBLE);
|
||||
CHECK(mol->getBondWithIdx(3)->getBondDir() == Bond::BondDir::NONE);
|
||||
auto nmb = MolToMolBlock(*mol);
|
||||
CHECK(nmb.find("2 4 2 3") == std::string::npos);
|
||||
CHECK(nmb.find("2 4 2 0") != std::string::npos);
|
||||
std::vector<unsigned int> ranks;
|
||||
Canon::rankMolAtoms(*mol, ranks);
|
||||
nmb = MolToMolBlock(*mol);
|
||||
CHECK(nmb.find("2 4 2 3") == std::string::npos);
|
||||
CHECK(nmb.find("2 4 2 0") != std::string::npos);
|
||||
}
|
||||
}
|
||||
TEST_CASE(
|
||||
"github #2423: Incorrect assignment of explicit Hs to Al+3 read from mol "
|
||||
"block",
|
||||
|
||||
@@ -64,12 +64,9 @@ void compareRingAtomsConcerningNumNeighbors(Canon::canon_atom *atoms,
|
||||
unsigned int nAtoms,
|
||||
const ROMol &mol) {
|
||||
RingInfo *ringInfo = mol.getRingInfo();
|
||||
if (!ringInfo->isInitialized()) {
|
||||
ringInfo->initialize();
|
||||
}
|
||||
for (unsigned idx = 0; idx < nAtoms; ++idx) {
|
||||
const Canon::canon_atom &a = atoms[idx];
|
||||
if (ringInfo->numAtomRings(a.atom->getIdx()) < 1) {
|
||||
if (!ringInfo->isInitialized() || ringInfo->numAtomRings(a.atom->getIdx()) < 1) {
|
||||
continue;
|
||||
}
|
||||
std::deque<int> neighbors;
|
||||
@@ -94,7 +91,7 @@ void compareRingAtomsConcerningNumNeighbors(Canon::canon_atom *atoms,
|
||||
int nidx = neighbors.front();
|
||||
neighbors.pop_front();
|
||||
const Canon::canon_atom &atom = atoms[nidx];
|
||||
if (ringInfo->numAtomRings(atom.atom->getIdx()) < 1) {
|
||||
if (!ringInfo->isInitialized() || ringInfo->numAtomRings(atom.atom->getIdx()) < 1) {
|
||||
continue;
|
||||
}
|
||||
lastLevelNbrs[nidx] = 1;
|
||||
@@ -234,16 +231,13 @@ void rankWithFunctor(T &ftor, bool breakTies, int *order,
|
||||
unsigned ringAtoms = 0;
|
||||
bool branchingRingAtom = false;
|
||||
RingInfo *ringInfo = mol.getRingInfo();
|
||||
if (!ringInfo->isInitialized()) {
|
||||
ringInfo->initialize();
|
||||
}
|
||||
for (unsigned i = 0; i < nAts; ++i) {
|
||||
if (ringInfo->numAtomRings(order[i])) {
|
||||
if (ringInfo->isInitialized() && ringInfo->numAtomRings(order[i])) {
|
||||
if (count[order[i]] > 2) {
|
||||
symRingAtoms += count[order[i]];
|
||||
}
|
||||
ringAtoms++;
|
||||
if (ringInfo->numAtomRings(order[i]) > 1 && count[order[i]] > 1) {
|
||||
if (ringInfo->isInitialized() && ringInfo->numAtomRings(order[i]) > 1 && count[order[i]] > 1) {
|
||||
branchingRingAtom = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user