void testExtraAtomQueries() { BOOST_LOG(rdErrorLog) << "---------------------- Test extra atom queries" << std::endl; { // radicals QueryAtom qA; qA.setQuery(makeAtomNumRadicalElectronsQuery(1)); Atom a1(6); TEST_ASSERT(!qA.Match(&a1)); a1.setNumRadicalElectrons(1); TEST_ASSERT(qA.Match(&a1)); a1.setNumRadicalElectrons(2); TEST_ASSERT(!qA.Match(&a1)); qA.getQuery()->setNegation(true); TEST_ASSERT(qA.Match(&a1)); a1.setNumRadicalElectrons(0); TEST_ASSERT(qA.Match(&a1)); a1.setNumRadicalElectrons(1); TEST_ASSERT(!qA.Match(&a1)); } { // chiral tags QueryAtom qA; qA.setQuery(makeAtomHasChiralTagQuery()); Atom a1(6); TEST_ASSERT(!qA.Match(&a1)); a1.setChiralTag(Atom::CHI_TETRAHEDRAL_CW); TEST_ASSERT(qA.Match(&a1)); a1.setChiralTag(Atom::CHI_TETRAHEDRAL_CCW); TEST_ASSERT(qA.Match(&a1)); a1.setChiralTag(Atom::CHI_OTHER); TEST_ASSERT(qA.Match(&a1)); qA.getQuery()->setNegation(true); a1.setChiralTag(Atom::CHI_UNSPECIFIED); TEST_ASSERT(qA.Match(&a1)); a1.setChiralTag(Atom::CHI_TETRAHEDRAL_CW); TEST_ASSERT(!qA.Match(&a1)); a1.setChiralTag(Atom::CHI_TETRAHEDRAL_CCW); TEST_ASSERT(!qA.Match(&a1)); a1.setChiralTag(Atom::CHI_OTHER); TEST_ASSERT(!qA.Match(&a1)); } { // missing chiral tags QueryAtom qA; qA.setQuery(makeAtomMissingChiralTagQuery()); Atom a1(6); TEST_ASSERT(!qA.Match(&a1)); a1.setChiralTag(Atom::CHI_TETRAHEDRAL_CW); TEST_ASSERT(!qA.Match(&a1)); a1.setChiralTag(Atom::CHI_TETRAHEDRAL_CCW); TEST_ASSERT(!qA.Match(&a1)); a1.setChiralTag(Atom::CHI_OTHER); TEST_ASSERT(!qA.Match(&a1)); a1.setChiralTag(Atom::CHI_UNSPECIFIED); a1.setProp(common_properties::_ChiralityPossible, 1); TEST_ASSERT(qA.Match(&a1)); a1.setChiralTag(Atom::CHI_TETRAHEDRAL_CW); TEST_ASSERT(!qA.Match(&a1)); a1.setChiralTag(Atom::CHI_TETRAHEDRAL_CCW); TEST_ASSERT(!qA.Match(&a1)); a1.setChiralTag(Atom::CHI_OTHER); TEST_ASSERT(!qA.Match(&a1)); qA.getQuery()->setNegation(true); a1.clearProp(common_properties::_ChiralityPossible); a1.setChiralTag(Atom::CHI_UNSPECIFIED); TEST_ASSERT(qA.Match(&a1)); a1.setChiralTag(Atom::CHI_TETRAHEDRAL_CW); TEST_ASSERT(qA.Match(&a1)); a1.setChiralTag(Atom::CHI_TETRAHEDRAL_CCW); TEST_ASSERT(qA.Match(&a1)); a1.setChiralTag(Atom::CHI_OTHER); TEST_ASSERT(qA.Match(&a1)); a1.setChiralTag(Atom::CHI_UNSPECIFIED); a1.setProp(common_properties::_ChiralityPossible, 1); TEST_ASSERT(!qA.Match(&a1)); } BOOST_LOG(rdErrorLog) << "Done!" << std::endl; }
QueryAtom *HasPropQueryAtom(const std::string &propname, bool negate) { QueryAtom *res = new QueryAtom(); res->setQuery(makeHasPropQuery<Atom>(propname)); if (negate) res->getQuery()->setNegation(true); return res; }