Re: [Rdkit-discuss] Calculation of atomic descriptors, Code snippet

2008-08-18 Thread Evgueni Kolossov
Thanks Greg,

Will this give the SHORTEST distance?

Regards,
Evgueni

2008/8/18 Greg Landrum greg.land...@gmail.com

 On Mon, Aug 18, 2008 at 12:42 PM, Evgueni Kolossov ekolos...@gmail.com
 wrote:
  Thanks Greg - this is works.
  Another question:
  Can you please provide an example of use MolOps::getDistanceMat with the
  samples how to extract distance data from this matrix

 I'm not clear what you're looking for.

  double *dm = MolOps::getDistanceMat(mol);
  // distance between atom 3 and 7:
  dm[3*mol.getNumAtoms()+7];

 -greg




-- 
Dr. Evgueni Kolossov (PhD)
ekolos...@gmail.com
Tel. +44(0)1628 627168
Mob. +44(0)7812070446


Re: [Rdkit-discuss] Calculation of atomic descriptors, Code snippet

2008-08-18 Thread Greg Landrum
On Mon, Aug 18, 2008 at 8:15 PM, Evgueni Kolossov ekolos...@gmail.com wrote:
 Thanks Greg,

 Will this give the SHORTEST distance?

Yes. As the header file says, it uses the all-pairs shortest paths algorithm.

-greg



Re: [Rdkit-discuss] Calculation of atomic descriptors, Code snippet

2008-08-17 Thread Evgueni Kolossov
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.
 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; iminRingSize; i++)
 {
 RDKit::Atom * pAtom = mol.getAtomWithIdx(ringIt[i]) ;
 ..
 }
 but this is not working.

 Regards,
 Evgueni


 2008/8/15 Greg Landrum greg.land...@gmail.com

 Dear Evgueni,

 this is a general interest answer, so I'm directing it to the mailing
 list.

 On Fri, Aug 15, 2008 at 11:56 AM, Evgueni Kolossov
 ekolos...@btinternet.com wrote:
 
  I need to understand a little bit more about RingInfo.
  For a given atom I got:
  - the number of rings atom involved (pRingInfo-numAtomRings(Atom_Idx))
  - the size of the smallest ring atom involved
  (pRingInfo-minAtomRingSize(Atom_Idx))

 correct.

  Now I need to iterate through the atoms in the smallest ring with my
 atom. I
  can get atoms using pRingInfo-atomRings() but how I know this will give
 me
  the list of atoms in the smallest ring and in the ring where is my atom?

 sample code, not actually tested, should give the idea:

 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
}
  }
  }
 }


  What if my atom is a member of more than one ring?

 The above code should work in that case as well.

 -greg

 -
 This SF.Net email is sponsored by the Moblin Your Move Developer's
 challenge
 Build the coolest Linux based applications with Moblin SDK  win great
 prizes
 Grand prize is a trip for two to an Open Source event anywhere in the
 world
 http://moblin-contest.org/redirect.php?banner_id=100url=/
 ___
 Rdkit-discuss mailing list
 Rdkit-discuss@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/rdkit-discuss




 --
 Dr. Evgueni Kolossov (PhD)
 ekolos...@gmail.com
 Tel. +44(0)1628 627168
 Mob. +44(0)7812070446




-- 
Dr. Evgueni Kolossov (PhD)
ekolos...@gmail.com
Tel. +44(0)1628 627168
Mob. +44(0)7812070446


Re: [Rdkit-discuss] Calculation of atomic descriptors, Code snippet

2008-08-17 Thread Greg Landrum
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; iminRingSize; 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



Re: [Rdkit-discuss] Calculation of atomic descriptors, Code snippet

2008-08-15 Thread Greg Landrum
Dear Evgueni,

this is a general interest answer, so I'm directing it to the mailing list.

On Fri, Aug 15, 2008 at 11:56 AM, Evgueni Kolossov
ekolos...@btinternet.com wrote:

 I need to understand a little bit more about RingInfo.
 For a given atom I got:
 - the number of rings atom involved (pRingInfo-numAtomRings(Atom_Idx))
 - the size of the smallest ring atom involved
 (pRingInfo-minAtomRingSize(Atom_Idx))

correct.

 Now I need to iterate through the atoms in the smallest ring with my atom. I
 can get atoms using pRingInfo-atomRings() but how I know this will give me
 the list of atoms in the smallest ring and in the ring where is my atom?

sample code, not actually tested, should give the idea:

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
}
  }
 }
}


 What if my atom is a member of more than one ring?

The above code should work in that case as well.

-greg