remove no-op macros and dead code (pt 1) (#8012)

This commit is contained in:
Hussein Faara
2024-11-18 19:31:56 -08:00
committed by greg landrum
parent e9e13f6523
commit 17c75bf219
10 changed files with 1 additions and 570 deletions

View File

@@ -40,7 +40,6 @@ void MolToCairo(const ROMol &mol, cairo_t *cr, int width, int height) {
#endif
void DrawDemo() {
#if 1
{
RWMol *mol = SmilesToMol("c1c(C#N)cccc1C~C2CC2");
std::string svg = MolToSVG(*mol);
@@ -87,7 +86,6 @@ void DrawDemo() {
delete mol;
}
#endif
#ifdef USE_CAIRO
{
RWMol *mol =

View File

@@ -680,10 +680,6 @@ void dfsBuildStack(ROMol &mol, int atomIdx, int inBondIdx,
std::vector<INT_LIST> &atomTraversalBondOrder,
const boost::dynamic_bitset<> *bondsInPlay,
const std::vector<std::string> *bondSymbols, bool doRandom) {
#if 0
std::cerr<<"traverse from atom: "<<atomIdx<<" via bond "<<inBondIdx<<" num cycles available: "
<<std::count(cyclesAvailable.begin(),cyclesAvailable.end(),1)<<std::endl;
#endif
Atom *atom = mol.getAtomWithIdx(atomIdx);
INT_LIST directTravList, cycleEndList;
@@ -892,21 +888,11 @@ void clearBondDirs(ROMol &mol, Bond *refBond, const Atom *fromAtom,
PRECONDITION(fromAtom, "bad atom");
PRECONDITION(&fromAtom->getOwningMol() == &mol, "bad bond");
#if 0
std::copy(bondDirCounts.begin(),bondDirCounts.end(),std::ostream_iterator<int>(std::cerr,", "));
std::cerr<<"\n";
std::copy(atomDirCounts.begin(),atomDirCounts.end(),std::ostream_iterator<int>(std::cerr,", "));
std::cerr<<"\n";
std::cerr<<"cBD: bond: "<<refBond->getIdx()<<" atom: "<<fromAtom->getIdx()<<": ";
#endif
ROMol::OEDGE_ITER beg, end;
boost::tie(beg, end) = mol.getAtomBonds(fromAtom);
bool nbrPossible = false, adjusted = false;
while (beg != end) {
Bond *oBond = mol[*beg];
// std::cerr<<" >>"<<oBond->getIdx()<<" "<<canHaveDirection(*oBond)<<"
// "<<bondDirCounts[oBond->getIdx()]<<"-"<<bondDirCounts[refBond->getIdx()]<<"
// "<<atomDirCounts[oBond->getBeginAtomIdx()]<<"-"<<atomDirCounts[oBond->getEndAtomIdx()]<<std::endl;
if (oBond != refBond && canHaveDirection(*oBond)) {
nbrPossible = true;
if ((bondDirCounts[oBond->getIdx()] >=
@@ -948,12 +934,6 @@ void removeRedundantBondDirSpecs(ROMol &mol, MolStack &molStack,
UINT_VECT &atomDirCounts,
const UINT_VECT &bondVisitOrders) {
PRECONDITION(bondDirCounts.size() >= mol.getNumBonds(), "bad dirCount size");
#if 0
std::cerr<<"rRBDS: ";
mol.debugMol(std::cerr);
std::copy(bondDirCounts.begin(),bondDirCounts.end(),std::ostream_iterator<int>(std::cerr,", "));
std::cerr<<"\n";
#endif
// find bonds that have directions indicated that are redundant:
for (auto &msI : molStack) {
if (msI.type == MOL_STACK_BOND) {
@@ -1156,24 +1136,9 @@ void canonicalizeFragment(ROMol &mol, int atomIdx,
}
}
#if 0
std::cerr<<"<11111111"<<std::endl;
std::cerr<<"----------------------------------------->"<<std::endl;
mol.debugMol(std::cerr);
#endif
// std::cerr<<"----->\ntraversal stack:"<<std::endl;
// traverse the stack and canonicalize double bonds and atoms with (ring)
// stereochemistry
for (auto &msI : molStack) {
#if 0
if(msI->type == MOL_STACK_ATOM) std::cerr<<" atom: "<<msI->obj.atom->getIdx()<<std::endl;
else if(msI->type == MOL_STACK_BOND) std::cerr<<" bond: "<<msI->obj.bond->getIdx()<<" "<<msI->number<<" "<<msI->obj.bond->getBeginAtomIdx()<<"-"<<msI->obj.bond->getEndAtomIdx()<<" order: "<<msI->obj.bond->getBondType()<<std::endl;
else if(msI->type == MOL_STACK_RING) std::cerr<<" ring: "<<msI->number<<std::endl;
else if(msI->type == MOL_STACK_BRANCH_OPEN) std::cerr<<" branch open"<<std::endl;
else if(msI->type == MOL_STACK_BRANCH_CLOSE) std::cerr<<" branch close"<<std::endl;
#endif
if (msI.type == MOL_STACK_BOND &&
msI.obj.bond->getBondType() == Bond::DOUBLE &&
msI.obj.bond->getStereo() > Bond::STEREOANY) {
@@ -1265,19 +1230,8 @@ void canonicalizeFragment(ROMol &mol, int atomIdx,
}
}
}
#if 0
std::cerr<<"<-----"<<std::endl;
std::cerr<<"----------------------------------------->"<<std::endl;
mol.debugMol(std::cerr);
#endif
Canon::removeRedundantBondDirSpecs(mol, molStack, bondDirCounts,
atomDirCounts, bondVisitOrders);
#if 0
std::cerr<<"----------------------------------------->"<<std::endl;
mol.debugMol(std::cerr);
std::cerr<<"----------------------------------------->"<<std::endl;
#endif
}
void canonicalizeEnhancedStereo(ROMol &mol,
@@ -1350,22 +1304,6 @@ void canonicalizeEnhancedStereo(ROMol &mol,
// referenceAtom is already CCW then we don't need to do anything more
// with this stereogroup
auto refState = Atom::ChiralType::CHI_TETRAHEDRAL_CCW;
#if 0
INT_LIST nbrs;
auto [beg, end] = mol.getAtomBonds(*refAtom);
while (beg != end) {
nbrs.push_back(mol[*beg++]->getIdx());
}
std::cerr << "!!!! " << (*refAtom)->getDegree() << " " << nbrs.size()
<< std::endl;
// sort the neighbor indices by atom ranks
nbrs.sort([&atomRanks](auto i, auto j) {
return atomRanks->at(i) < atomRanks->at(j);
});
if ((*refAtom)->getPerturbationOrder(nbrs) % 1) {
refState = Atom::ChiralType::CHI_TETRAHEDRAL_CW;
}
#endif
if (foundRefState != refState) {
// we need to flip everyone... so loop over the other atoms and bonds
// and flip them all:

View File

@@ -179,43 +179,6 @@ void test190() {
BOOST_LOG(rdInfoLog) << "\tdone" << std::endl;
}
void test45() {
BOOST_LOG(rdInfoLog) << "-------------------------------------" << std::endl;
BOOST_LOG(rdInfoLog) << "Testing FMCS test45" << std::endl;
std::cout << "\n test45()\n";
std::vector<ROMOL_SPTR> mols;
const char *smi[] = {
// SLOW
// test 45 # Using CHEMBL551656 CHEMBL563796 CHEMBL561978 CHEMBL559467
// CHEMBL550503 CHEMBL562866 CHEMBL552190 CHEMBL181547 CHEMBL359567
// CHEMBL373316
// 45 . 1 30 32 27.01
// n12-C-c:c(-c:2:c:c2-C(-O)(-C-C)-C(-O-C-c:2:c:1=O)=O):n:c(:c:c:c-O):c(:c):c-C-C-C
"CCC1(O)c2cc3n(c(=O)c2COC1=O)Cc1c-3nc2ccc(OC)cc2c1C1CCCCC1 CHEMBL551656",
"CCC1(O)c2cc3n(c(=O)c2COC1=O)Cc1c-3nc2ccc(OC)cc2c1C1CCCC1 CHEMBL563796", // Q
"CCC1(O)C(=O)OCc2c1cc1n(c2=O)Cc2c-1nc1ccc(OC)cc1c2C1CCCCCC1 CHEMBL561978",
"CCC1(O)C(=O)OCc2c1cc1n(c2=O)Cc2c-1nc1ccc(OC)cc1c2C1CCC1 CHEMBL559467",
"CCC1(O)C(=O)OCc2c1cc1n(c2=O)Cc2c-1nc1ccc(O)cc1c2C1CCCC1 CHEMBL550503",
"CCC1(O)c2cc3n(c(=O)c2COC1=O)Cc1c-3nc2ccc(O)cc2c1C1CCCCCC1 CHEMBL562866",
"CCC1(O)C(=O)OCc2c1cc1n(c2=O)Cc2c-1nc1ccc(O)cc1c2C1CCCCC1 CHEMBL552190",
"CCC1(O)c2c(c(=O)n3c(c2)-c2nc4cc5c(cc4c(C4CCCC4)c2C3)OCO5)COC1=O "
"CHEMBL181547",
"CCC1(O)c2c(c(=O)n3c(c2)-c2nc4c(c(C5CCCCC5)c2C3)cc2c(c4)OCO2)COC1=O "
"CHEMBL359567",
"CCCc1c(OC)ccc2nc3c(c(CC)c21)Cn1c-3cc2c(c1=O)COC(=O)C2(O)CC CHEMBL373316",
};
for (auto &i : smi) {
mols.emplace_back(SmilesToMol(getSmilesOnly(i)));
}
t0 = nanoClock();
MCSResult res = findMCS(mols);
std::cout << "MCS: " << res.SmartsString << " " << res.NumAtoms << " atoms, "
<< res.NumBonds << " bonds\n";
printTime();
TEST_ASSERT(res.NumAtoms == 31 && res.NumBonds == 33);
BOOST_LOG(rdInfoLog) << "\tdone" << std::endl;
}
void test3() {
BOOST_LOG(rdInfoLog) << "-------------------------------------" << std::endl;
BOOST_LOG(rdInfoLog) << "Testing FMCS test3" << std::endl;
@@ -411,55 +374,6 @@ void testThreshold() {
BOOST_LOG(rdInfoLog) << "\tdone" << std::endl;
}
void test330() {
BOOST_LOG(rdInfoLog) << "-------------------------------------" << std::endl;
BOOST_LOG(rdInfoLog) << "Testing FMCS test330" << std::endl;
std::cout << "\ntest330()\n";
std::vector<ROMOL_SPTR> mols;
const char *smi[] = {
// TEST 330 40 sec
"CCC(C)C(NC(=O)C(NC(C(CCC(O)=O)NC(=O)C(NC(=O)C(NC(C(CC(O)=O)NC(C(CC(C)C)"
"NC(C(Cc1ccccc1)NC(CN)=O)=O)=O)=O)C(C)CC)C(C)CC)=O)CCCCN)C(NC(C)C(NC("
"CCCCN)C(NC(CO)C(NC(Cc1c[nH]c2c1cccc2)C(O)=O)=O)=O)=O)=O CHEMBL1240742",
"CCC(C)C(NC(=O)C(NC(C(CCCCN)NC(=O)C(NC(=O)C(NC(C(CC(O)=O)NC(C(Cc1ccccc1)"
"NC(C(CC(C)C)NC(CN)=O)=O)=O)=O)C(C)CC)C(C)CC)=O)CCCCN)C(NC(C)C(NC(CCC(O)="
"O)C(NC(CO)C(NC(Cc1c[nH]c2c1cccc2)C(O)=O)=O)=O)=O)=O CHEMBL1240736",
"CCC(C)C(NC(CN)=O)C(NC(C(NC(CC(O)=O)C(NC(C(NC(C)C(NC(CCCCN)C(NC(C(NC(CC("
"C)C)C(NC(Cc1ccccc1)C(NC(CCC(O)=O)C(NC(CO)C(NC(Cc1c[nH]c2c1cccc2)C(O)=O)="
"O)=O)=O)=O)=O)CCCCN)=O)=O)=O)C(C)CC)=O)=O)C(C)CC)=O CHEMBL1240738",
"CCC(C)C(NC(CN)=O)C(NC(Cc1ccccc1)C(NC(CC(O)=O)C(NC(CCCCN)C(NC(CC(C)C)C("
"NC(C)C(NC(CCCCN)C(NC(CCC(O)=O)C(NC(C(NC(CO)C(NC(C(NC(Cc1c[nH]c2c1cccc2)"
"C(O)=O)=O)C(C)CC)=O)=O)C(C)CC)=O)=O)=O)=O)=O)=O)=O)=O CHEMBL1240740",
"CCC(C)C(NC(CN)=O)C(NC(Cc1c[nH]c2c1cccc2)C(NC(CO)C(NC(CC(O)=O)C(NC(CC(C)"
"C)C(NC(C)C(NC(CCC(O)=O)C(NC(C(NC(C(NC(CCCCN)C(NC(CCCCN)C(NC(Cc1ccccc1)C("
"O)=O)=O)=O)=O)C(C)CC)=O)C(C)CC)=O)=O)=O)=O)=O)=O)=O CHEMBL1240741",
"CCC(C)C(NC(=O)C(NC(=O)C(CCCCN)NC(C(CC(C)C)NC(C(Cc1c[nH]c2c1cccc2)NC(CN)="
"O)=O)=O)CCCCN)C(NC(CCC(O)=O)C(NC(CO)C(=O)NC(C(NC(C(NC(CC(O)=O)C(NC(C)C("
"NC(Cc1ccccc1)C(O)=O)=O)=O)=O)C(C)CC)=O)C(C)CC)=O)=O CHEMBL1240743",
"CCC(C)C(NC(C(CCC(O)=O)NC(C(CC(O)=O)NC(C(CC(C)C)NC(C(Cc1ccccc1)NC(C)=O)="
"O)=O)=O)=O)C(NC(Cc1c[nH]c2ccccc12)C(O)=O)=O CHEMBL431874",
"CCC(C)C(NC(C(CC(O)=O)NC(C(CC(C)C)NC(C(Cc1ccccc1)NC(C)=O)=O)=O)=O)C(NC("
"CCC(O)=O)C(NC(Cc1c[nH]c2ccccc12)C(O)=O)=O)=O CHEMBL262166",
"CCC(C)C(NC(C(CC(O)=O)NC(C(CC(C)C)NC(C(Cc1ccccc1)NC(C)=O)=O)=O)=O)C(NC("
"CCCCN)C(NC(Cc1c[nH]c2c1cccc2)C(O)=O)=O)=O CHEMBL313122",
"CCC(C)C(NC(C(CCCCN)NC(C(CC(O)=O)NC(C(CC(C)C)NC(C(Cc1ccccc1)NC(C)=O)=O)="
"O)=O)=O)C(NC(Cc1c[nH]c2c1cccc2)C(O)=O)=O CHEMBL314239",
// # 330 F 42 41 30.93 sec MCS:
//[#6]-[#6](-[#7]-[#6](-[#6](-[#6])-[#7]-[#6](-[#6](-[#6])-[#7]-[#6](-[#6](-[#6]-[#6]-[#6])-[#7]-[#6](-[#6](-[#6])-[#7]-[#6](-[#6])=[#8])=[#8])=[#8])=[#8])=[#8])-[#6](-[#7]-[#6](-[#6]-[#6](:[#6]):[#6]:[#6]:[#6]:[#6])-[#6](-[#8])=[#8])=[#8]
};
for (auto &i : smi) {
mols.emplace_back(SmilesToMol(getSmilesOnly(i)));
}
MCSParameters p;
t0 = nanoClock();
MCSResult res = findMCS(mols, &p);
std::cout << "MCS: " << res.SmartsString << " " << res.NumAtoms << " atoms, "
<< res.NumBonds << " bonds\n";
printTime();
TEST_ASSERT(res.NumAtoms == 42 && res.NumBonds == 41);
BOOST_LOG(rdInfoLog) << "\tdone" << std::endl;
}
void testTarget_no_10188_30149() {
BOOST_LOG(rdInfoLog) << "-------------------------------------" << std::endl;
BOOST_LOG(rdInfoLog) << "Testing FMCS testTarget_no_10188_30149" << std::endl;
@@ -1484,7 +1398,6 @@ void testGithub945() {
BOOST_LOG(rdInfoLog) << "Testing Github #945: MCS returning partial rings "
"with completeRingsOnly=True"
<< std::endl;
#if 1
{
std::vector<ROMOL_SPTR> mols;
const char *smi[] = {"c1cc2ccccc2s1", "c1cc2ccccc2o1"};
@@ -1533,7 +1446,6 @@ void testGithub945() {
TEST_ASSERT(res.NumBonds == 6);
}
}
#endif
{
std::vector<ROMOL_SPTR> mols;
const char *smi[] = {"c1cc2ccc(C)cc2s1", "c1cc2c(cccc2s1)C"};
@@ -3132,7 +3044,6 @@ void testAtomRingQueries() {
int main(int argc, const char *argv[]) {
(void)argc;
(void)argv;
// p.Verbose = true;
RDLog::InitLogs();
BOOST_LOG(rdInfoLog)
<< "*******************************************************\n";
@@ -3150,7 +3061,6 @@ int main(int argc, const char *argv[]) {
T0 = nanoClock();
t0 = nanoClock();
#if 1
testJSONParameters();
test1Basics();
@@ -3175,9 +3085,6 @@ int main(int argc, const char *argv[]) {
test18();
test504();
// very SLOW optional tests:
// test330(); // SLOW test
// test45(); // SLOW test
testInitialSeed();
testInitialSeed2();
@@ -3222,7 +3129,6 @@ int main(int argc, const char *argv[]) {
testGitHub6773();
testBondCompareCompleteRingsOnly();
testAtomRingQueries();
#endif
unsigned long long t1 = nanoClock();
double sec = double(t1 - T0) / 1000000.;

View File

@@ -503,14 +503,9 @@ void testSDMemoryCorruption() {
auto *writer = new SDWriter(os, false);
STR_VECT names;
#if 1
ROMol *m1 = sdsup.next();
MolOps::sanitizeMol(*(RWMol *)m1);
delete m1;
#else
ROMol *m1 = SmilesToMol("C1CC1");
TEST_ASSERT(m1);
#endif
sdsup.reset();
int nDone = 0;
while (!sdsup.atEnd()) {
@@ -536,7 +531,6 @@ void testSDMemoryCorruption() {
delete writer;
delete os;
#if 1
// now read in the file we just finished writing
SDMolSupplier reader(ofile);
int i = 0;
@@ -549,7 +543,6 @@ void testSDMemoryCorruption() {
delete mol;
i++;
}
#endif
}
void testIssue3525000() {
@@ -1594,7 +1587,7 @@ M END)CTAB"_ctab;
}
{
auto m = R"CTAB(
MJ201100
MJ201100
3 2 0 0 0 0 0 0 0 0999 V2000
-1.5623 1.6625 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
@@ -1614,7 +1607,6 @@ M END)CTAB"_ctab;
int main() {
RDLog::InitLogs();
#if 1
BOOST_LOG(rdInfoLog) << "-----------------------------------------\n";
BOOST_LOG(rdInfoLog) << "Running testSmilesWriter()\n";
testSmilesWriter();
@@ -1741,8 +1733,6 @@ int main() {
testNeedsUpdatePropertyCacheSDWriter();
BOOST_LOG(rdInfoLog) << "-----------------------------------------\n\n";
#endif
BOOST_LOG(rdInfoLog) << "-----------------------------------------\n";
BOOST_LOG(rdInfoLog) << "Running testIssue3525000()\n";
testIssue3525000();

View File

@@ -74,27 +74,6 @@ const char *pqs[] = {
//"[*]!@[R]~[R]~[R]!@[*]", Github #151: can't have !@ in an SSS pattern
"[*]~[R](@[R])@[R](@[R])~[*]", "[*]~[R](@[R])@[R]@[R](@[R])~[*]",
"[*]", // single atom fragment
#if 0
"[*]~[*](~[*])(~[*])~[*]",
"[*]~[*]~[*]~[*]~[*]~[*]",
"[*]~[*]~[*]~[*](~[*])~[*]",
"[*]~[*]~[*](~[*])~[*]~[*]",
"[*]~[*]~[*](~[*])(~[*])~[*]",
"[*]~[*](~[*])~[*](~[*])~[*]",
"[*]~[R]~1[R]~[R]~1(~[*])~[*]",
"[*]~[R]~1[R](~[*])~[R]~1[*]",
"[*]~[R]~1[R]~[R](~[*])~[R]~1",
"[*]~[R]~1[R]~[R]~[R]~1[*]",
"[*]~[R]~1[R]~[R]~[R]~[R]~1",
"[*]~[R]~1(~[*])~[R]~[R]~[R]~1",
"[*]~[*]~[*]~[*]~[*]~[*]~[*]",
"[*]~[*]~[*]~[*]~[*](~[*])~[*]",
"[*]~[*]~[*]~[*](~[*])~[*]~[*]",
"[*]~[*]~[*]~[*](~[*])(~[*])~[*]",
"[*]~[*]~[*](~[*])~[*](~[*])~[*]",
"[*]~[*](~[*])~[*]~[*](~[*])~[*]",
"[*]~[*](~[*])~[*](~[*])(~[*])~[*]",
#endif
""};
typedef boost::flyweight<boost::flyweights::key_value<std::string, ss_matcher>,
boost::flyweights::no_tracking>

View File

@@ -31,7 +31,6 @@ void testPass() {
BOOST_LOG(rdInfoLog) << "-------------------------------------" << std::endl;
BOOST_LOG(rdInfoLog) << "Testing patterns which should parse." << std::endl;
string smis[] = {
#if 1
"C", "CC", "C-C", "C=C", "[CH2+]C[CH+2]", "C1CC=1", "C=1CC1", "Ccc",
"C=C-O", "C1CC1", "C1NC1", "C1=CC1", "C1CCC1", "CC(C)CC", "CC(=O)O",
"C1C(=O)C1", "C1C(N)C1", "CC(O)C", "OC=CCC", "CC([O-])O", "C1CC2C1CC2",
@@ -61,7 +60,6 @@ void testPass() {
"[D{-3}]", "[D{1-}]", "[z{1-3}]", "[Z{1-3}]",
"[2H,13C]", // github #1719
"[+{0-3}]",
#endif
"[-{0-3}]", "[-{0-3},C]",
"[-{0-3},D{1-3}]", // github #2709
"C%(1000)CCC%(1000)", // github #2909
@@ -433,7 +431,6 @@ void testProblems() {
BOOST_LOG(rdInfoLog) << "-------------------------------------" << std::endl;
BOOST_LOG(rdInfoLog) << "Testing former problems" << std::endl;
#if 1
_checkMatches("[$(C(=O)O)]", "CC(=O)OC", 1, 1);
_checkMatches("[$(C(=O)[O,N])]", "CC(=O)OC", 1, 1);
@@ -478,7 +475,6 @@ void testProblems() {
_checkNoMatches("[O]-[!$(*=O)]", "CC(=O)O");
// BOOST_LOG(rdInfoLog) << "-*-*-*-*-*-*-*-*-" << std::endl;
#endif
_checkNoMatches("[$([O]-[!$(*=O)])]", "CC(=O)O");
// ISSUE 78
@@ -838,53 +834,6 @@ void testIssue254() {
BOOST_LOG(rdInfoLog) << "\tdone" << std::endl;
}
void testIssue255() {
ROMol *matcher1;
std::string sma;
BOOST_LOG(rdInfoLog) << "-------------------------------------" << std::endl;
BOOST_LOG(rdInfoLog) << "Testing Issue 255: Core leaks in smarts parsing. "
"Watch memory consumption."
<< std::endl;
for (int i = 0; i < 10000; i++) {
#if 1
sma = "CC";
matcher1 = SmartsToMol(sma);
TEST_ASSERT(matcher1);
delete matcher1;
sma = "C-C";
matcher1 = SmartsToMol(sma);
TEST_ASSERT(matcher1);
delete matcher1;
sma = "C=C";
matcher1 = SmartsToMol(sma);
TEST_ASSERT(matcher1);
delete matcher1;
sma = "C=,#C";
matcher1 = SmartsToMol(sma);
TEST_ASSERT(matcher1);
delete matcher1;
#endif
sma = "C-1CC-1";
// matcher1 = SmartsToMol(sma);
matcher1 = SmilesToMol(sma);
TEST_ASSERT(matcher1);
delete matcher1;
#if 1
sma = "C-1CC1";
matcher1 = SmartsToMol(sma);
TEST_ASSERT(matcher1);
delete matcher1;
#endif
}
BOOST_LOG(rdInfoLog) << "\tdone" << std::endl;
}
void testIssue330() {
ROMol *matcher1;
std::string sma, wsma;
@@ -987,7 +936,6 @@ void testAtomMap() {
BOOST_LOG(rdInfoLog) << "\tdone" << std::endl;
}
#if 1
void testIssue1804420() {
ROMol *matcher1;
std::string sma;
@@ -1025,7 +973,6 @@ void testIssue1804420() {
BOOST_LOG(rdInfoLog) << "\tdone" << std::endl;
}
#endif
void testSmartsSmiles() {
RWMol *mol;
@@ -2796,7 +2743,6 @@ int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
RDLog::InitLogs();
#if 1
testPass();
testFail();
testMatches();
@@ -2810,8 +2756,6 @@ int main(int argc, char *argv[]) {
testProblems();
testIssue196();
testIssue254();
// testIssue255(); // this is a slow one and doesn't really actually test much
// without someone watching memory consumption
testIssue330();
testIssue351();
testAtomMap();
@@ -2847,7 +2791,6 @@ int main(int argc, char *argv[]) {
testGithub2565();
testSmartsStereoBonds();
testGithub6730();
#endif
testRingBondCrash();
return 0;
}

View File

@@ -729,7 +729,6 @@ void github3881() {
int main() {
RDLog::InitLogs();
#if 1
test1();
test2();
test3();
@@ -747,6 +746,5 @@ int main() {
testTautomerQueries();
#endif
github3881();
#endif
return 0;
}

View File

@@ -534,97 +534,6 @@ void test5() {
delete m;
}
/*
void test6(){
string smi;
Mol *m;
VECT_INT_VECT sssr;
int c1,c2;
smi = "C1(Cl)C(Cl)C1Cl";
m = SmilesToMol(smi);
INT_SET ringAtoms,ringBonds;
//boost::tie(c1,c2) = MolOps::findRingAtomsAndBonds(*m,ringAtoms,ringBonds);
CHECK_INVARIANT(c1==3,"bad nRingAtoms");
CHECK_INVARIANT(ringAtoms.count(0)==1,"bad RingAtoms");
CHECK_INVARIANT(ringAtoms.count(1)==0,"bad RingAtoms");
CHECK_INVARIANT(ringAtoms.count(2)==1,"bad RingAtoms");
CHECK_INVARIANT(ringAtoms.count(3)==0,"bad RingAtoms");
CHECK_INVARIANT(ringAtoms.count(4)==1,"bad RingAtoms");
CHECK_INVARIANT(ringAtoms.count(5)==0,"bad RingAtoms");
CHECK_INVARIANT(c2==3,"bad nRingBonds");
CHECK_INVARIANT(ringBonds.count(0)==0,"");
CHECK_INVARIANT(ringBonds.count(1)==1,"");
CHECK_INVARIANT(ringBonds.count(2)==0,"");
CHECK_INVARIANT(ringBonds.count(3)==1,"");
CHECK_INVARIANT(ringBonds.count(4)==0,"");
CHECK_INVARIANT(ringBonds.count(5)==1,"");
}
*/
void test7() {
#if 0
string smi;
Mol *m;
INT_VECT tree;
#if 1
smi = "C(CO)OCC";
m = SmilesToMol(smi);
MolOps::findSpanningTree(*m,tree);
CHECK_INVARIANT(tree.size()==5,"bad mst");
delete m;
smi = "C1CC1";
m = SmilesToMol(smi);
MolOps::findSpanningTree(*m,tree);
CHECK_INVARIANT(tree.size()==2,"bad mst");
delete m;
smi = "C1C=C1";
m = SmilesToMol(smi);
MolOps::findSpanningTree(*m,tree);
CHECK_INVARIANT(tree.size()==2,"bad mst");
CHECK_INVARIANT(std::find(tree.begin(),tree.end(),1)==tree.end(),"bogus idx in mst");
delete m;
#endif
smi = "C1C=CC=CC=1";
m = SmilesToMol(smi);
MolOps::findSpanningTree(*m,tree);
CHECK_INVARIANT(tree.size()==5,"bad mst");
delete m;
smi = "C1C(=CC1)";
m = SmilesToMol(smi);
MolOps::findSpanningTree(*m,tree);
CHECK_INVARIANT(tree.size()==3,"bad mst");
delete m;
smi = "C1C(C=C1)";
m = SmilesToMol(smi);
MolOps::findSpanningTree(*m,tree);
CHECK_INVARIANT(tree.size()==3,"bad mst");
delete m;
smi = "C1C(C2)CCC2C1";
m = SmilesToMol(smi);
MolOps::findSpanningTree(*m,tree);
CHECK_INVARIANT(tree.size()==6,"bad mst");
delete m;
smi = "C1C2CC3CCCCC3CC2CCC1";
m = SmilesToMol(smi);
MolOps::findSpanningTree(*m,tree);
CHECK_INVARIANT(tree.size()==13,"bad mst");
delete m;
#endif
}
void test8() {
BOOST_LOG(rdInfoLog) << "-----------------------\n Testing Hydrogen Ops"
@@ -4199,7 +4108,6 @@ void testBasicCanon() {
BOOST_LOG(rdInfoLog) << "Testing canonicalization basics" << std::endl;
// these are all cases that were problematic at one time or another during
// the canonicalization rewrite.
#if 1
{
std::string smi = "FC1C(=C/Cl)\\C1";
RWMol *m = SmilesToMol(smi);
@@ -4427,7 +4335,6 @@ void testBasicCanon() {
delete m;
delete m2;
}
#endif
{
std::string pathName = getenv("RDBASE");
@@ -5776,7 +5683,6 @@ void testAdjustQueryProperties() {
BOOST_LOG(rdInfoLog)
<< "-----------------------\n Testing adjustQueryProperties()"
<< std::endl;
#if 1
{ // basics from SMILES
std::string smiles = "C1CCC1C";
ROMol *qm = SmilesToMol(smiles);
@@ -6101,7 +6007,6 @@ void testAdjustQueryProperties() {
delete m;
delete t;
}
#endif
{ // make atoms generic
std::string smiles = "C1CC1CC";
ROMol *qm = SmilesToMol(smiles);
@@ -7664,7 +7569,6 @@ void testGithub1614() {
"1614: AssignStereochemistry incorrectly removing "
"CIS/TRANS bond stereo"
<< std::endl;
#if 1
{
RWMol m;
m.addAtom(new Atom(9), true, true);
@@ -7788,8 +7692,6 @@ void testGithub1614() {
TEST_ASSERT(smi == "C/C(F)=C(/C)Cl");
}
}
#endif
#if 1
{
RWMol *m = SmilesToMol("F/C=C(\\C/C=C/C)C/C=C\\F", false, false);
TEST_ASSERT(m);
@@ -7808,7 +7710,6 @@ void testGithub1614() {
}
delete m;
}
#endif
{
RWMol *m = SmilesToMol("FC=C(C/C=C/C)C/C=C\\F", false, false);
@@ -7832,7 +7733,6 @@ void testGithub1614() {
delete m;
}
#if 1
{
RWMol *m = SmilesToMol("F/C=C(\\C/C=C/C)C/C=C\\C", false, false);
TEST_ASSERT(m);
@@ -7849,7 +7749,6 @@ void testGithub1614() {
}
delete m;
}
#endif
{
RWMol *m = SmilesToMol("FC=C(C/C=C/C)C/C=C\\C", false, false);
TEST_ASSERT(m);
@@ -7896,7 +7795,6 @@ void testGithub1810() {
TEST_ASSERT(mol->getNumAtoms() == 4);
TEST_ASSERT(mol->getBondBetweenAtoms(1, 2)->getStereo() == Bond::STEREOZ);
}
#if 1
{
std::unique_ptr<RWMol> mol(SmilesToMol("FC=C(F)[H]", false, false));
TEST_ASSERT(mol);
@@ -7909,7 +7807,6 @@ void testGithub1810() {
TEST_ASSERT(mol->getBondBetweenAtoms(1, 2)->getStereoAtoms()[0] == 0);
TEST_ASSERT(mol->getBondBetweenAtoms(1, 2)->getStereoAtoms()[1] == 3);
}
#endif
BOOST_LOG(rdInfoLog) << "Finished" << std::endl;
}
@@ -8643,8 +8540,6 @@ int main() {
test3();
test4();
test5();
// test6();
test7();
test8();
test9();
test10();

View File

@@ -155,7 +155,6 @@ void testRoundTrip() {
TEST_ASSERT(m->getAtomWithIdx(0)->hasProp(common_properties::_CIPCode));
m->getAtomWithIdx(0)->getProp(common_properties::_CIPCode, cip);
TEST_ASSERT(cip == "R");
#if 1
smi = MolToSmiles(*m, true);
BOOST_LOG(rdInfoLog) << "smiout: " << smi << std::endl;
TEST_ASSERT(smi == "N[C@H](O)I");
@@ -169,7 +168,6 @@ void testRoundTrip() {
TEST_ASSERT(cip == "R");
smi2 = MolToSmiles(*m, true);
TEST_ASSERT(smi == smi2);
#endif
BOOST_LOG(rdInfoLog) << " >>>>>>>>>>>>> mol file <<<<<<<<<<<<<< "
<< std::endl;
@@ -183,7 +181,6 @@ void testRoundTrip() {
TEST_ASSERT(m->getAtomWithIdx(1)->hasProp(common_properties::_CIPCode));
m->getAtomWithIdx(1)->getProp(common_properties::_CIPCode, cip);
TEST_ASSERT(cip == "R");
#if 1
smi = MolToSmiles(*m, true);
delete m;
m = SmilesToMol(smi);
@@ -195,7 +192,6 @@ void testRoundTrip() {
TEST_ASSERT(cip == "R");
smi2 = MolToSmiles(*m, true);
TEST_ASSERT(smi == smi2);
#endif
delete m;
fName =
@@ -207,7 +203,6 @@ void testRoundTrip() {
TEST_ASSERT(m->getAtomWithIdx(1)->hasProp(common_properties::_CIPCode));
m->getAtomWithIdx(1)->getProp(common_properties::_CIPCode, cip);
TEST_ASSERT(cip == "R");
#if 1
smi = MolToSmiles(*m, true);
delete m;
m = SmilesToMol(smi);
@@ -219,7 +214,6 @@ void testRoundTrip() {
TEST_ASSERT(cip == "R");
smi2 = MolToSmiles(*m, true);
TEST_ASSERT(smi == smi2);
#endif
delete m;
fName =
@@ -231,7 +225,6 @@ void testRoundTrip() {
TEST_ASSERT(m->getAtomWithIdx(1)->hasProp(common_properties::_CIPCode));
m->getAtomWithIdx(1)->getProp(common_properties::_CIPCode, cip);
TEST_ASSERT(cip == "R");
#if 1
smi = MolToSmiles(*m, true);
delete m;
m = SmilesToMol(smi);
@@ -243,7 +236,6 @@ void testRoundTrip() {
TEST_ASSERT(cip == "R");
smi2 = MolToSmiles(*m, true);
TEST_ASSERT(smi == smi2);
#endif
delete m;
fName =
@@ -255,7 +247,6 @@ void testRoundTrip() {
TEST_ASSERT(m->getAtomWithIdx(1)->hasProp(common_properties::_CIPCode));
m->getAtomWithIdx(1)->getProp(common_properties::_CIPCode, cip);
TEST_ASSERT(cip == "R");
#if 1
smi = MolToSmiles(*m, true);
delete m;
m = SmilesToMol(smi);
@@ -267,7 +258,6 @@ void testRoundTrip() {
TEST_ASSERT(cip == "R");
smi2 = MolToSmiles(*m, true);
TEST_ASSERT(smi == smi2);
#endif
delete m;
BOOST_LOG(rdInfoLog) << "done" << std::endl;
@@ -893,14 +883,6 @@ void testRingStereochemistry() {
TEST_ASSERT(smi1 == "B[C@H]1CC[C@H](C)CC1");
delete m;
#if 0
smi="B[C@@H]1CC[C@@H](C)CC1";
m = SmilesToMol(smi);
std::string smi2=MolToSmiles(*m,true);
BOOST_LOG(rdInfoLog)<<" : "<<smi2<<" "<<smi1<<std::endl;
TEST_ASSERT(smi2==smi);
delete m;
#endif
}
{
@@ -911,14 +893,6 @@ void testRingStereochemistry() {
BOOST_LOG(rdInfoLog) << " : " << smi << " " << smi1 << std::endl;
TEST_ASSERT(smi1 == smi);
delete m;
#if 0
smi="C1[C@H](B)CC[C@@H](C)C1";
m = SmilesToMol(smi);
std::string smi2=MolToSmiles(*m,true);
BOOST_LOG(rdInfoLog)<<" : "<<smi2<<" "<<smi1<<std::endl;
TEST_ASSERT(smi2==smi1);
delete m;
#endif
}
{
@@ -928,14 +902,6 @@ void testRingStereochemistry() {
BOOST_LOG(rdInfoLog) << " : " << smi << " " << smi1 << std::endl;
TEST_ASSERT(smi1 == "C[C@H]1CC[C@H](F)CC1");
delete m;
#if 0
smi="C[C@@H]1CC[C@@H](F)CC1";
m = SmilesToMol(smi);
std::string smi2=MolToSmiles(*m,true);
BOOST_LOG(rdInfoLog)<<" : "<<smi2<<" "<<smi1<<std::endl;
TEST_ASSERT(smi2==smi1);
delete m;
#endif
}
{
@@ -943,14 +909,6 @@ void testRingStereochemistry() {
RWMol *m = SmilesToMol(smi);
std::string smi1 = MolToSmiles(*m, true);
delete m;
#if 0
smi="F[C@@H]1CC[C@@H](C)CC1";
m = SmilesToMol(smi);
std::string smi2=MolToSmiles(*m,true);
BOOST_LOG(rdInfoLog)<<" : "<<smi2<<" "<<smi1<<std::endl;
TEST_ASSERT(smi2==smi1);
delete m;
#endif
}
{
@@ -1006,30 +964,6 @@ void testRingStereochemistry() {
delete m;
}
#if 0
// FIX : these tests do not pass
{
std::string smi = "C[C@H]1CC[C@H](C)CC1";
RWMol *m = SmilesToMol(smi);
std::string smi1=MolToSmiles(*m,true);
BOOST_LOG(rdInfoLog)<<" : "<<smi<<" "<<smi1<<std::endl;
TEST_ASSERT(smi1==smi);
delete m;
}
{
std::string smi = "C1[C@@H](C)CC[C@H](C)C1";
RWMol *m = SmilesToMol(smi);
m->debugMol(std::cerr);
std::string smi1=MolToSmiles(*m,true);
smi = "C[C@H]1CC[C@H](C)CC1";
BOOST_LOG(rdInfoLog)<<" : "<<smi<<" "<<smi1<<std::endl;
m->debugMol(std::cerr);
TEST_ASSERT(smi1==smi);
delete m;
}
#endif
BOOST_LOG(rdInfoLog) << "done" << std::endl;
}
@@ -1124,7 +1058,6 @@ void testIterativeChirality() {
// unless otherwise noted, the R/S and Z/E assignments here
// match Marvin and ChemDraw.
#if 1
{ // atom-chirality -> atom-chirality
std::string cip;
@@ -1205,7 +1138,6 @@ void testIterativeChirality() {
TEST_ASSERT(!m->getAtomWithIdx(0)->hasProp(common_properties::_CIPCode));
#if 1 // this fails due to sf.net bug 1896935
std::string smi1 = MolToSmiles(*m, true);
delete m;
m = SmilesToMol(smi1);
@@ -1213,7 +1145,6 @@ void testIterativeChirality() {
std::string smi2 = MolToSmiles(*m, true);
BOOST_LOG(rdInfoLog) << " : " << smi1 << " " << smi2 << std::endl;
TEST_ASSERT(smi1 == smi2);
#endif
delete m;
}
@@ -1236,7 +1167,6 @@ void testIterativeChirality() {
TEST_ASSERT(!m->getAtomWithIdx(0)->hasProp(common_properties::_CIPCode));
#if 1 // this fails due to sf.net bug 1896935
std::string smi1 = MolToSmiles(*m, true);
delete m;
m = SmilesToMol(smi1);
@@ -1244,7 +1174,6 @@ void testIterativeChirality() {
std::string smi2 = MolToSmiles(*m, true);
BOOST_LOG(rdInfoLog) << " : " << smi1 << " " << smi2 << std::endl;
TEST_ASSERT(smi1 == smi2);
#endif
delete m;
}
@@ -1260,27 +1189,6 @@ void testIterativeChirality() {
TEST_ASSERT(!m->getAtomWithIdx(2)->hasProp(common_properties::_CIPCode));
TEST_ASSERT(!m->getAtomWithIdx(4)->hasProp(common_properties::_CIPCode));
#if 0 // this fails due to sf.net bug 1896935
std::cerr<<"m pre -----"<<std::endl;
m->debugMol(std::cerr);
std::cerr<<"-----"<<std::endl;
std::string smi1=MolToSmiles(*m,true);
std::cerr<<"m post -----"<<std::endl;
m->debugMol(std::cerr);
std::cerr<<"-----"<<std::endl;
delete m;
m = SmilesToMol(smi1);
TEST_ASSERT(m);
std::cerr<<"m2 pre -----"<<std::endl;
m->debugMol(std::cerr);
std::cerr<<"-----"<<std::endl;
std::string smi2=MolToSmiles(*m,true);
std::cerr<<"m post -----"<<std::endl;
m->debugMol(std::cerr);
std::cerr<<"-----"<<std::endl;
BOOST_LOG(rdInfoLog)<<" : "<<smi1<<" "<<smi2<<std::endl;
TEST_ASSERT(smi1==smi2);
#endif
delete m;
}
@@ -1512,7 +1420,6 @@ void testIterativeChirality() {
delete m;
}
#endif
{ // bond stereochemistry -> bond stereochemistry
std::string cip;
@@ -1794,14 +1701,6 @@ void testIssue2705543() {
MolOps::assignChiralTypesFrom3D(*m);
MolOps::assignStereochemistry(*m, true);
#if 0
for(unsigned int i=0;i<m->getNumAtoms();++i){
if(m->getAtomWithIdx(i)->hasProp(common_properties::_CIPCode)){
m->getAtomWithIdx(i)->getProp(common_properties::_CIPCode,cip);
std::cerr<<" >> "<<i<<" "<<cip<<std::endl;
}
}
#endif
TEST_ASSERT(m->getAtomWithIdx(0)->hasProp(common_properties::_CIPCode));
TEST_ASSERT(m->getAtomWithIdx(0)->getChiralTag() ==
Atom::CHI_TETRAHEDRAL_CCW);
@@ -3208,9 +3107,7 @@ void testGithub7115() {
int main() {
RDLog::InitLogs();
// boost::logging::enable_logs("rdApp.debug");
#if 1
testSmiles1();
testMol1();
testMol2();
@@ -3236,7 +3133,6 @@ int main() {
testDoubleBondStereoInRings();
testIssue1735();
testStereoGroupUpdating();
#endif
testClearDirsOnDoubleBondsWithoutStereo();
testAssignChiralTypesFromMolParity();
testIncorrectBondDirsOnWedging();

View File

@@ -76,67 +76,6 @@ void test1(bool doLong = 0) {
BOOST_LOG(rdErrorLog) << "\tdone" << std::endl;
}
void _createPickleFile() {
std::string smiName = getenv("RDBASE");
smiName += "/Code/GraphMol/test_data/canonSmiles.smi";
std::string pklName = getenv("RDBASE");
#ifdef OLD_PICKLE
pklName += "/Code/GraphMol/test_data/canonSmiles.v1.pkl";
#else
pklName += "/Code/GraphMol/test_data/canonSmiles.v2.pkl";
#endif
BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl;
BOOST_LOG(rdErrorLog) << "creating pickle file." << std::endl;
SmilesMolSupplier suppl(smiName, "\t", 0, 1, false);
std::ofstream outStream(pklName.c_str(), std::ios_base::binary);
while (!suppl.atEnd()) {
ROMol *m = suppl.next();
TEST_ASSERT(m);
std::string pickle;
MolPickler::pickleMol(*m, outStream);
delete m;
}
BOOST_LOG(rdErrorLog) << "\tdone" << std::endl;
}
void test2(bool doLong = 0) {
std::string smiName = getenv("RDBASE");
smiName += "/Code/GraphMol/test_data/canonSmiles.smi";
std::string pklName = getenv("RDBASE");
pklName += "/Code/GraphMol/test_data/canonSmiles.v1.pkl";
BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl;
BOOST_LOG(rdErrorLog) << "Testing reading existing pickle file (v1)."
<< std::endl;
SmilesMolSupplier suppl(smiName, "\t", 0, 1, false);
std::ifstream inStream(pklName.c_str(), std::ios_base::binary);
int count = 0;
while (!suppl.atEnd()) {
ROMol *m1 = suppl.next();
TEST_ASSERT(m1);
ROMol m2;
MolPickler::molFromPickle(inStream, m2);
std::string smi1 = MolToSmiles(*m1);
std::string smi2 = MolToSmiles(m2);
if (smi1 != smi2) {
BOOST_LOG(rdInfoLog) << "Line: " << count << "\n " << smi1
<< "\n != \n " << smi2 << std::endl;
}
TEST_ASSERT(smi1 == smi2);
delete m1;
count++;
if (!doLong && count >= 100) {
break;
}
}
BOOST_LOG(rdErrorLog) << "\tdone" << std::endl;
}
void test3(bool doLong = 0) {
std::string smiName = getenv("RDBASE");
smiName += "/Code/GraphMol/test_data/canonSmiles.smi";
@@ -173,52 +112,6 @@ void test3(bool doLong = 0) {
BOOST_LOG(rdErrorLog) << "\tdone" << std::endl;
}
void timeTest(bool doLong = 0) {
time_t t1, t2;
std::string smiName = getenv("RDBASE");
smiName += "/Code/GraphMol/test_data/canonSmiles.smi";
std::string pklName = getenv("RDBASE");
pklName += "/Code/GraphMol/test_data/canonSmiles.v2.pkl";
BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl;
BOOST_LOG(rdErrorLog) << "Timing reads." << std::endl;
t1 = std::time(nullptr);
SmilesMolSupplier suppl(smiName, "\t", 0, 1, false);
int count = 0;
while (!suppl.atEnd()) {
ROMol *m1 = suppl.next();
TEST_ASSERT(m1);
count++;
if (!doLong && count >= 100) {
break;
}
delete m1;
}
t2 = std::time(nullptr);
BOOST_LOG(rdInfoLog) << " Smiles time: " << std::difftime(t2, t1)
<< std::endl;
;
std::ifstream inStream(pklName.c_str(), std::ios_base::binary);
t1 = std::time(nullptr);
while (count > 0) {
ROMol m2;
MolPickler::molFromPickle(inStream, m2);
count--;
if (!doLong && count >= 100) {
break;
}
}
t2 = std::time(nullptr);
BOOST_LOG(rdInfoLog) << " Pickle time: " << std::difftime(t2, t1)
<< std::endl;
;
BOOST_LOG(rdErrorLog) << "\tdone" << std::endl;
}
void test4() {
BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl;
BOOST_LOG(rdErrorLog) << "Testing combining molecules using pickles."
@@ -1851,16 +1744,12 @@ int main(int argc, char *argv[]) {
}
}
//_createPickleFile();
#if 1
test1(doLong);
// test2(doLong);
test3(doLong);
test4();
testIssue164();
testIssue219();
testIssue220();
// timeTest(doLong);
testQueries();
testRadicals();
testPickleProps();
@@ -1880,7 +1769,6 @@ int main(int argc, char *argv[]) {
testCustomPickler();
testGithub2441();
testGithubIssue2510();
#endif
testNegativeMaps();
testHistoricalConfs();
testConformerOptions();