On Mon, Mar 18, 2013 at 2:36 PM, Syeda Sabrina <[email protected]> wrote:
> Hi Greg,
>
> If this is working as it is supposed to be then I don't understand why even
> if  I add only explicit Hydrogens to a molecule and check the number the of
> explicit Hydrogens attached to it later why it returns zero and in case of
> implicit hydrogen it is returning the other one?
>

Ok, let's start with what you have:
In [12]: m = Chem.MolFromSmiles('C')
In [13]: mnew = Chem.AddHs(m,explicitOnly=True)
In [14]: m.GetNumAtoms()
Out[14]: 1
In [15]: mnew.GetNumAtoms()
Out[15]: 1
In [16]: m = Chem.MolFromSmiles('C')
In [17]: m.GetNumAtoms()
Out[17]: 1
In [18]: mnew = Chem.AddHs(m,explicitOnly=True)
In [19]: mnew.GetNumAtoms()
Out[19]: 1
In [20]: mnew = Chem.AddHs(m)
In [21]: mnew.GetNumAtoms()
Out[21]: 5

The behavior around lines 20 and 21, which is the default, is I think
what you want.

In order to have the "explicitOnly" flag do anything, you have to have
some explicit Hs in your molecule:

In [22]: m2 = Chem.MolFromSmiles('[CH4]')
In [23]: m2.GetNumAtoms()
Out[23]: 1
In [24]: mnew2 = Chem.AddHs(m2,explicitOnly=True)
In [25]: mnew2.GetNumAtoms()
Out[25]: 5

As I said in the earlier post I linked to, this behavior is correct
(in the sense the code is doing what it was designed to do), but it
doesn't really make sense. The distinction the RDKit currently makes
between explicit and implicit Hs is somewhat silly and should be
changed. I'm doing this, but it will take a while.

In the meantime, there's probably no reason for you to be providing
the "explicitOnly" argument to addHs. What were you trying to
accomplish?


-greg

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to