Dear Evgueni, > 2008/8/17 Evgueni Kolossov <ekolos...@gmail.com> >> >> Thanks Greg, >> >> But this is not enough: >> >> unsigned int minRingSize=ringInfo-> >>> >>> minAtomRingSize(atomIdx); >>> for(VECT_INT_VECT_CI ringIt=ringInfo->atomRings().begin(); >>> ringIt!=ringInfo->atomRings().end();++ringIt){ >>> if(ringIt->size()==minRingSize){ >>> if(std::find(ringIt->begin(),ringIt->end(),atomIdx)!=ringIt->end()){ >>> // our atom is in this ring; do something >>> } >>> } >>> } >>> } >> >> In this case we got an iterator (ringIt) which is itself a vector (if I am >> right) of Ring atoms.
It's a vector of ring atom indices. You can use these to get the corresponding atoms from the molecule. >> So to do something with atoms inside this ring we need somehow iterate >> through the atoms... >> Can you show how to do this? >> I have tried to do it this way: >> for (unsighed int i=0; i<minRingSize; i++) >> { >> RDKit::Atom * pAtom = mol.getAtomWithIdx(ringIt[i]) ; >> .......... >> } >> but this is not working. Here's a sample that is actually tested. It's now part of the getting started in C++ sample code. We loop over all atom rings, then grab each atom in the 5-rings and test to see if it's aromatic. I think this, combined with the earlier stuff I posted, should get you started: --------------- mol=SmilesToMol("C1CC2=C(C1)C1=C(NC3=C1C=CC=C3)C=C2"); ringInfo = mol->getRingInfo(); atomRings=ringInfo->atomRings(); unsigned int nMatchingAtoms=0; for(VECT_INT_VECT_CI ringIt=atomRings.begin(); ringIt!=atomRings.end();++ringIt){ if(ringIt->size()!=5){ continue; } bool isAromatic=true; for(INT_VECT_CI atomIt=ringIt->begin(); atomIt!=ringIt->end();++atomIt){ if(!mol->getAtomWithIdx(*atomIt)->getIsAromatic()){ isAromatic=false; break; } } if(isAromatic){ nMatchingAtoms+=5; } } TEST_ASSERT(nMatchingAtoms==5); --------------- Best Regards, -greg