Hi Greg,
Many thanks for the speedy reply, as always. Once I'd spelt neighbors
correctly, it worked like a dream and was exactly what I wanted. I dare
say this has cropped up before, and I will try and remember for next time.
If you have time at some point to explain what an explicit hydrogen is, I'd
be grateful and it might be helpful for others as well. I'm guessing it's
something like the hydrogen atoms in [CH3-]. If that's the case, no need
to reply.
Cheers,
Dave
On Tue, Jun 21, 2016 at 4:00 PM, Greg Landrum <[email protected]>
wrote:
> Answering this may require a long explanation, or it could be really
> quick.... let's see where we end up. :-)
>
> If you replace "a.GetTotalNumHs()" with
> "a.GetTotalNumHs(includeNeighbors=True)", do the results then make sense to
> you?
>
> -greg
>
>
> On Tue, Jun 21, 2016 at 4:50 PM, David Cosgrove <
> [email protected]> wrote:
>
>> Hi All,
>>
>> I'm a bit confused about counting hydrogen atoms. It's a perennial
>> problem with cheminformatics toolkits in my experience, but this seems
>> particularly perverse. If I run the code:
>>
>> from rdkit import Chem
>> from rdkit.Chem import AllChem
>>
>> mol = Chem.MolFromSmiles( 'CCO' )
>> mol = Chem.AddHs( mol )
>> cids = AllChem.EmbedMultipleConfs(mol , useExpTorsionAnglePrefs=True ,
>> useBasicKnowledge=True , numConfs=1 )
>> AllChem.MMFFOptimizeMoleculeConfs( mol , mmffVariant='MMFF94s' )
>>
>> for a in mol.GetAtoms() :
>> num_heavy = a.GetTotalDegree() - a.GetTotalNumHs()
>> print '%d : %d num_heavy = %d num_H = %d %d %d' % ( a.GetIdx() ,
>> a.GetAtomicNum() , num_heavy , a.GetTotalNumHs() , a.GetNumImplicitHs() ,
>> a.GetNumExplicitHs() )
>> for nb in a.GetNeighbors() :
>> print ' %d : %d' % ( nb.GetIdx() , nb.GetAtomicNum() )
>>
>> I get the output
>>
>> 0 : 6 num_heavy = 4 num_H = 0 0 0
>> 1 : 6
>> 3 : 1
>> 4 : 1
>> 5 : 1
>> 1 : 6 num_heavy = 4 num_H = 0 0 0
>> 0 : 6
>> 2 : 8
>> 6 : 1
>> 7 : 1
>> 2 : 8 num_heavy = 2 num_H = 0 0 0
>> 1 : 6
>> 8 : 1
>> 3 : 1 num_heavy = 1 num_H = 0 0 0
>> 0 : 6
>> 4 : 1 num_heavy = 1 num_H = 0 0 0
>> 0 : 6
>> 5 : 1 num_heavy = 1 num_H = 0 0 0
>> 0 : 6
>> 6 : 1 num_heavy = 1 num_H = 0 0 0
>> 1 : 6
>> 7 : 1 num_heavy = 1 num_H = 0 0 0
>> 1 : 6
>> 8 : 1 num_heavy = 1 num_H = 0 0 0
>> 2 : 8
>>
>>
>> It seems that in a 3D mol, after embedding and minimisation, an H atom is
>> just like any other atom, and is ignored in the various H atom counting
>> functions. Is that expected behaviour? Depending on the answer, either
>> the documentation or the behaviour is incorrect.
>>
>> Cheers,
>> Dave
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
>> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
>> present their vision of the future. This family event has something for
>> everyone, including kids. Get more information and register today.
>> http://sdm.link/attshape
>> _______________________________________________
>> Rdkit-discuss mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>
>>
>
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss