Esempio n. 1
0
void test4() {
  string smi = "C1COCCNCOCNSCC1";
  unsigned int heteros1[] = {2, 7};

  Mol *m = SmilesToMol(smi);
  QueryAtom *q = new QueryAtom();
  q->setQuery(makeAtomNumQuery(8));
  {
    unsigned int nSeen = 0;
    for (Mol::QueryAtomIterator queryIt = m->beginQueryAtoms(q);
         queryIt != m->endQueryAtoms(); queryIt++) {
      CHECK_INVARIANT((*queryIt)->getIdx() == heteros1[nSeen], "bad query");
      nSeen++;
    }
  }
  {
    Mol::QueryAtomIterator queryIt = m->beginQueryAtoms(q);
    queryIt++;
    queryIt--;
    CHECK_INVARIANT((*queryIt)->getIdx() == heteros1[0], "bad query");
    CHECK_INVARIANT((*++queryIt)->getIdx() == heteros1[1], "bad query");
    CHECK_INVARIANT((*queryIt)->getIdx() == heteros1[1], "bad query");
  }
  {
    Mol::QueryAtomIterator queryIt = m->beginQueryAtoms(q);
    queryIt++;
    queryIt--;
    Mol::QueryAtomIterator queryIt2 = queryIt;
    CHECK_INVARIANT((*queryIt2)->getIdx() == heteros1[0], "bad query");
    CHECK_INVARIANT((*++queryIt2)->getIdx() == heteros1[1], "bad query");
    CHECK_INVARIANT((*queryIt2)->getIdx() == heteros1[1], "bad query");
  }
  smi = "CC(C)CC(C)CC(C)CC(C)C";
  unsigned int heteros2[] = {1, 4, 7, 10};
  m = SmilesToMol(smi);
  // m->debugMol(cout);
  q->setQuery(makeAtomImplicitValenceQuery(1));
  {
    unsigned int nSeen = 0;
    for (Mol::QueryAtomIterator queryIt = m->beginQueryAtoms(q);
         queryIt != m->endQueryAtoms(); ++queryIt) {
      CHECK_INVARIANT((*queryIt)->getIdx() == heteros2[nSeen], "bad query");
      nSeen++;
    }
  }
  BOOST_LOG(rdInfoLog) << "test4 done" << endl;
};
Esempio n. 2
0
void test8() {
  {
    string smi = "CC1CC2CC1C2";
    Mol *m = SmilesToMol(smi);
    QueryAtom *q = new QueryAtom();
    q->setQuery(makeAtomExplicitDegreeQuery(3));
    q->expandQuery(makeAtomRingBondCountQuery(2));
    unsigned int nSeen = 0;
    for (Mol::QueryAtomIterator queryIt = m->beginQueryAtoms(q);
         queryIt != m->endQueryAtoms(); ++queryIt) {
      TEST_ASSERT((*queryIt)->getIdx() == 1);
      nSeen++;
    }
    TEST_ASSERT(nSeen == 1);
    delete m;
    delete q;
  }

  BOOST_LOG(rdInfoLog) << "test8 done" << endl;
};