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

2008-08-18 Thread Evgueni Kolossov
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

Regards,
Evgueni

2008/8/17 Greg Landrum 

> Dear Evgueni,
>
> > 2008/8/17 Evgueni Kolossov 
> >>
> >> 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 >> {
> >> 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
>



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


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

2008-08-18 Thread Evgueni Kolossov
-- Forwarded message --
From: Evgueni Kolossov 
Date: 2008/8/18
Subject: Re: [Rdkit-discuss] Calculation of atomic descriptors, Code snippet
To: Greg Landrum 


Greg,
Another question: getAllRotatableBonds(RDKit::ROMol &mol) - will this take
in account hydrogens or not?


> Regards,
> Evgueni
>
> 2008/8/17 Greg Landrum 
>
> Dear Evgueni,
>>
>> > 2008/8/17 Evgueni Kolossov 
>> >>
>> >> 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> >> {
>> >> 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
>>
>
>
>
> --
> 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



-- 
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 12:42 PM, Evgueni Kolossov  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



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

2008-08-18 Thread Greg Landrum
On Mon, Aug 18, 2008 at 2:55 PM, Evgueni Kolossov  wrote:
>
> Another question: getAllRotatableBonds(RDKit::ROMol &mol) - will this take
> in account hydrogens or not?

I think you're talking about the function that's in :
   .../Code/GraphMol/Depictor/DepictUtils.h
That looks for bonds that are rotatable as far as the depictor is
concerned, which probably isn't interesting to you.

I would otherwise define rotatable bonds using a SMARTS pattern. This
is the one used in the python descriptor calculator:

[!$(*#*)&!D1]-&!...@[!$(*#*)&!D1]

(heh, taken out of context SMARTS really can look like line noise!)

There's already sample code connected with this in the Getting Started cpp.

-greg



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

2008-08-18 Thread Evgueni Kolossov
Ok,
I understood - there is no function to get the number of non-terminal
rotatable bonds...
Another question - is there function to calculate the longest chain of
non-hydrogen atoms?

Regards,
Evgueni

2008/8/18 Greg Landrum 

> On Mon, Aug 18, 2008 at 2:55 PM, Evgueni Kolossov 
> wrote:
> >
> > Another question: getAllRotatableBonds(RDKit::ROMol &mol) - will this
> take
> > in account hydrogens or not?
>
> I think you're talking about the function that's in :
>   .../Code/GraphMol/Depictor/DepictUtils.h
> That looks for bonds that are rotatable as far as the depictor is
> concerned, which probably isn't interesting to you.
>
> I would otherwise define rotatable bonds using a SMARTS pattern. This
> is the one used in the python descriptor calculator:
>
> [!$(*#*)&!D1]-&!...@[!$(*#*)&!D1]
>
> (heh, taken out of context SMARTS really can look like line noise!)
>
> There's already sample code connected with this in the Getting Started cpp.
>
> -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 Evgueni Kolossov
Thanks Greg,

Will this give the SHORTEST distance?

Regards,
Evgueni

2008/8/18 Greg Landrum 

> On Mon, Aug 18, 2008 at 12:42 PM, Evgueni Kolossov 
> 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  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] Fwd: Calculation of atomic descriptors, Code snippet

2008-08-18 Thread Greg Landrum
On Mon, Aug 18, 2008 at 8:12 PM, Evgueni Kolossov  wrote:
> Ok,
> I understood - there is no function to get the number of non-terminal
> rotatable bonds...

Correct, you have to do that with SMARTS.

> Another question - is there function to calculate the longest chain of
> non-hydrogen atoms?

Nope. that would have to be done by hand. Or by assuming that it's
going to be less than a particular value (say 10) and using SMARTS
queries for that as well.

-greg