It doesn't answer my question, no doubt because I worded it incorrectly.

So let me try again.

Why is it that for a molecule with H explicitly defined (mol =
Chem.MolFromSmiles("C[NH]C") )  when I do a GetNeighbours on the atom index
of the N I do not get the Hs but only the two carbon atoms?

I find this behaviour counter intuitive.



-
Jean-Paul Ebejer
Early Stage Researcher


On 13 March 2012 19:26, Greg Landrum <[email protected]> wrote:

> Nice subject. :-)
>
> On Tue, Mar 13, 2012 at 6:54 PM, JP <[email protected]> wrote:
> > I need to get the H atom 3D positions on hydrogen bond donors in a
> molecule.
> > Thanks to the great documentation I found out how to get the H bond donor
> > atoms, so I thought I could move from there to get the H 3D co-ordinates.
> >
>
> indeed you can, but you need to be careful that your molecule actually
> includes Hs.
>
> Here's a demonstration of how you can do that that might help:
>
> I start from SMILES, like in your example:
> In [1]: from rdkit import Chem
>
> In [2]: m = Chem.MolFromSmiles('CCCO')
>
> In [3]: mh = Chem.AddHs(m)
>
> In [4]: from rdkit.Chem import AllChem
>
> In [5]: AllChem.EmbedMolecule(mh)
> Out[5]: 0
>
> In [6]: AllChem.UFFOptimizeMolecule(mh)
> Out[6]: 0
>
> In [7]: hMatcher = '[$([#1]-O)]'   # <- you would replace the "O" with
> your expression for a donor
>
> In [8]: hM = Chem.MolFromSmarts(hMatcher)
>
> In [9]: donatableHs = mh.GetSubstructMatches(hM)
>
> In [10]: list(donatableHs)
> Out[10]: [(11,)]
>
> In [13]: hps = [mh.GetConformer().GetAtomPosition(x[0]) for x in
> donatableHs]
>
> In [14]: hps
> Out[14]: [<rdkit.Geometry.rdGeometry.Point3D at 0x1046a8b78>]
>
>
> Here's how to do the same thing from a mol block (from a mol file is
> analogous):
>
> In [15]: mb  = Chem.MolToMolBlock(mh)
>
> In [16]: newm = Chem.MolFromMolBlock(mb,removeHs=False)
>
> In [17]: hps = [newm.GetConformer().GetAtomPosition(x[0]) for x in
> donatableHs]
>
> In [18]: hps
> Out[18]: [<rdkit.Geometry.rdGeometry.Point3D at 0x1046a8af0>]
>
>
> Of course, instead of matching the H directly you can also do the loop
> over neighbors that you originally proposed as long as the neighbors
> are actually still present in the molecular graph and not just
> implicit.
>
> Does that answer the question?
>
> -greg
>
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to