ATOM_EQUALS_QUERY *makeAtomIsotopeQuery(int what) { ATOM_EQUALS_QUERY *res = makeAtomSimpleQuery<ATOM_EQUALS_QUERY>(what, queryAtomIsotope); res->setDescription("AtomIsotope"); return res; }
ATOM_EQUALS_QUERY *makeAtomFormalChargeQuery(int what) { ATOM_EQUALS_QUERY *res = makeAtomSimpleQuery<ATOM_EQUALS_QUERY>(what, queryAtomFormalCharge); res->setDescription("AtomFormalCharge"); return res; }
ATOM_EQUALS_QUERY *makeAtomUnsaturatedQuery() { ATOM_EQUALS_QUERY *res = makeAtomSimpleQuery<ATOM_EQUALS_QUERY>(true, queryAtomUnsaturated); res->setDescription("AtomUnsaturated"); return res; }
ATOM_EQUALS_QUERY *makeAtomMassQuery(int what) { ATOM_EQUALS_QUERY *res = makeAtomSimpleQuery<ATOM_EQUALS_QUERY>( massIntegerConversionFactor * what, queryAtomMass); res->setDescription("AtomMass"); return res; }
ATOM_EQUALS_QUERY *makeAtomInRingOfSizeQuery(int tgt) { RANGE_CHECK(3, tgt, 20); ATOM_EQUALS_QUERY *res = new ATOM_EQUALS_QUERY; res->setVal(tgt); switch (tgt) { case 3: res->setDataFunc(queryAtomIsInRingOfSize<3>); break; case 4: res->setDataFunc(queryAtomIsInRingOfSize<4>); break; case 5: res->setDataFunc(queryAtomIsInRingOfSize<5>); break; case 6: res->setDataFunc(queryAtomIsInRingOfSize<6>); break; case 7: res->setDataFunc(queryAtomIsInRingOfSize<7>); break; case 8: res->setDataFunc(queryAtomIsInRingOfSize<8>); break; case 9: res->setDataFunc(queryAtomIsInRingOfSize<9>); break; case 10: res->setDataFunc(queryAtomIsInRingOfSize<10>); break; case 11: res->setDataFunc(queryAtomIsInRingOfSize<11>); break; case 12: res->setDataFunc(queryAtomIsInRingOfSize<12>); break; case 13: res->setDataFunc(queryAtomIsInRingOfSize<13>); break; case 14: res->setDataFunc(queryAtomIsInRingOfSize<14>); break; case 15: res->setDataFunc(queryAtomIsInRingOfSize<15>); break; case 16: res->setDataFunc(queryAtomIsInRingOfSize<16>); break; case 17: res->setDataFunc(queryAtomIsInRingOfSize<17>); break; case 18: res->setDataFunc(queryAtomIsInRingOfSize<18>); break; case 19: res->setDataFunc(queryAtomIsInRingOfSize<19>); break; case 20: res->setDataFunc(queryAtomIsInRingOfSize<20>); break; } res->setDescription("AtomRingSize"); return res; }
ATOM_EQUALS_QUERY *makeAtomAliphaticQuery() { ATOM_EQUALS_QUERY *res = makeAtomSimpleQuery<ATOM_EQUALS_QUERY>(true, queryAtomAliphatic); res->setDescription("AtomIsAliphatic"); return res; }
ATOM_EQUALS_QUERY *makeAtomImplicitHCountQuery(int what) { ATOM_EQUALS_QUERY *res = makeAtomSimpleQuery<ATOM_EQUALS_QUERY>(what, queryAtomImplicitHCount); res->setDescription("AtomImplicitHCount"); return res; }
ATOM_EQUALS_QUERY *makeAtomHasImplicitHQuery() { ATOM_EQUALS_QUERY *res = makeAtomSimpleQuery<ATOM_EQUALS_QUERY>(true, queryAtomHasImplicitH); res->setDescription("AtomHasImplicitH"); return res; }
ATOM_EQUALS_QUERY *makeAtomExplicitDegreeQuery(int what) { ATOM_EQUALS_QUERY *res = makeAtomSimpleQuery<ATOM_EQUALS_QUERY>(what, queryAtomExplicitDegree); res->setDescription("AtomExplicitDegree"); return res; }
ATOM_EQUALS_QUERY *makeAtomTotalValenceQuery(int what) { ATOM_EQUALS_QUERY *res = makeAtomSimpleQuery<ATOM_EQUALS_QUERY>(what, queryAtomTotalValence); res->setDescription("AtomTotalValence"); return res; }
//! returns a Query for matching atoms with a particular number of ring bonds ATOM_EQUALS_QUERY *makeAtomRingBondCountQuery(int what) { ATOM_EQUALS_QUERY *res = new AtomRingQuery(what); res->setDescription("AtomRingBondCount"); res->setDataFunc(queryAtomRingBondCount); return res; };
void test3() { BOOST_LOG(rdErrorLog) << "---------------------- Test3" << std::endl; Mol m; Atom *a = new Atom(6); // we copy in addAtom, so this is safe m.addAtom(a); m.addAtom(a); m.addAtom(a); m.addAtom(a); m.addAtom(a); m.addAtom(a); m.addAtom(a); delete a; m.addBond(0, 1, Bond::SINGLE); m.addBond(1, 2, Bond::DOUBLE); m.addBond(2, 3, Bond::SINGLE); m.addBond(3, 4, Bond::DOUBLE); m.addBond(4, 5, Bond::SINGLE); m.addBond(5, 0, Bond::DOUBLE); m.addBond(5, 6, Bond::SINGLE); MolOps::sanitizeMol(m); ATOM_EQUALS_QUERY *aeq = makeAtomExplicitDegreeQuery(3); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), ""); delete aeq; aeq = makeAtomExplicitDegreeQuery(2); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), ""); delete aeq; aeq = makeAtomHCountQuery(1); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), ""); delete aeq; aeq = makeAtomInNRingsQuery(1); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), ""); delete aeq; aeq = makeAtomInNRingsQuery(0); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(6)), ""); delete aeq; aeq = makeAtomAromaticQuery(); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), ""); delete aeq; aeq = makeAtomAliphaticQuery(); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(6)), ""); delete aeq; aeq = makeAtomInRingQuery(); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), ""); aeq->setNegation(true); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(6)), ""); delete aeq; aeq = makeAtomInRingOfSizeQuery(6); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), ""); aeq->setNegation(true); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(6)), ""); delete aeq; aeq = makeAtomInRingOfSizeQuery(5); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), ""); aeq->setNegation(true); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), ""); CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(6)), ""); delete aeq; BOND_EQUALS_QUERY *beq = makeBondIsInRingQuery(); CHECK_INVARIANT(beq->Match(m.getBondWithIdx(0)), ""); CHECK_INVARIANT(!beq->Match(m.getBondWithIdx(6)), ""); CHECK_INVARIANT(beq->Match(m.getBondBetweenAtoms(0, 1)), ""); CHECK_INVARIANT(beq->Match(m.getBondBetweenAtoms(1, 0)), ""); CHECK_INVARIANT(!beq->Match(m.getBondBetweenAtoms(5, 6)), ""); CHECK_INVARIANT(!beq->Match(m.getBondBetweenAtoms(6, 5)), ""); BOOST_LOG(rdErrorLog) << "Done!" << std::endl; }
ATOM_EQUALS_QUERY *makeAtomInNRingsQuery(int what){ ATOM_EQUALS_QUERY *res; res = makeAtomSimpleQuery(what,queryIsAtomInNRings); res->setDescription("AtomInNRings"); return res; }