Dear Jean-Paul,

On Wed, Mar 14, 2012 at 11:11 AM, JP <[email protected]> wrote:
> Indeed - as shown in RDKit 2012.01 by:
>
> #!/usr/bin/env python
>
> from rdkit import Chem
>
> mol = Chem.MolFromSmiles("C[NH]C")
>
> for atom in mol.GetAtoms():
>     neighbours = [x.GetSymbol() for x in atom.GetNeighbors()]
>     # where is my H dude?
>     print "%s has neighbours %s" % (atom.GetSymbol(), ', '.join(neighbours))
>
> Output:
> C has neighbours N
> N has neighbours C, C  # Here, here!
> C has neighbours N
>

I would not expect that one to work: the molecule has no Hs in the
graph. You have to call AddHs() or, if you read from an SDF or mol2
file, make sure that you don't remove Hs when the molecule is read in
(that's the "removeHs" argument to MolFromMolFile or MolFromMol2File).

This morning I managed to convince myself that there was a bug here,
by screwing up atom indices, now that I've I'm doing the right thing
I've changed my mind:
In [31]: mol = Chem.AddHs(Chem.MolFromSmiles("CNC"))

In [32]: mol.GetNumAtoms()
Out[32]: 10

In [33]: [x.GetSymbol() for x in mol.GetAtomWithIdx(1).GetNeighbors()]
Out[33]: ['C', 'C', 'H']


-greg

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to