Looks like you have a very old version of RDkit. The additional option was
included in RDkit 2016.03.1. Check

import rdkit
print(rdkit.__version__)

Best,

Peter



On Sat, Jan 21, 2017 at 3:39 PM Janusz Petkowski <jjpet...@mit.edu> wrote:

> Czesc again,
>
> Many thanks for the code snippet. I thought that I use it wrongly, I
> previously tried to use it exactly like you wrote, but I always got an
> error back. I think that maybe I am missing a module? I copied your snippet
> and tried to use it and got the same error
>
> m1 = Chem.MolFromSmiles('c1ccccc1')
>
> m1 = Chem.AddHs(m1, onlyOnAtoms=(2,3,4))
> print Chem.MolToSmiles(m1)
>
>
>
> The error is below:
>
>     m1 = Chem.AddHs(m1, onlyOnAtoms=(2,3,4))
> Boost.Python.ArgumentError: Python argument types in
>     rdkit.Chem.rdmolops.AddHs(Mol)
> did not match C++ signature:
>     AddHs(class RDKit::ROMol mol, bool explicitOnly=False, bool
> addCoords=False)
>
> It looks like RDkit does not recognize the onlyOnAtoms function?
>
> Thanks again for all your help!
>
> Janusz
>
> ------------------------------
> *From:* Maciek Wójcikowski [mac...@wojcikowski.pl]
> *Sent:* Saturday, January 21, 2017 3:11 PM
>
> *To:* Janusz Petkowski
> *Cc:* rdkit-discuss@lists.sourceforge.net
> *Subject:* Re: [Rdkit-discuss] adding custom number of explicit H to
> specified non-hydrogen atoms
> Cześć,
>
> Following code will add Hs to atoms 2,3,4. These are the usual RDKit
> indices which you get from "Atom.GetIdx()".
>
> In [5]: m1 = Chem.MolFromSmiles('c1ccccc1')
>    ...: m1 = Chem.AddHs(m1, onlyOnAtoms=(2,3,4))
>    ...: Chem.MolToSmiles(m1)
>    ...:
>    ...:
> Out[5]: '[H]c1cccc([H])c1[H]'
>
>
>
> ----
> Pozdrawiam,  |  Best regards,
> Maciek Wójcikowski
> mac...@wojcikowski.pl
>
> 2017-01-21 15:54 GMT+01:00 Janusz Petkowski <jjpet...@mit.edu>:
>
> Czesc Maciek,
>
> Thanks a lot for suggesting "onlyOnAtoms" option out. It looks like it is
> exactly what I would need. If it is not too big of a problem would it be
> possible for you to give me a simple example how to toggle that option on?
> I am sorry if this question seems obvious but I am not a programmer and my
> python skills are not yet advanced.
>
> Best regards,
>
> Janusz Petkowski
> ------------------------------
> *From:* Maciek Wójcikowski [mac...@wojcikowski.pl]
> *Sent:* Saturday, January 21, 2017 5:35 AM
> *To:* Janusz Petkowski
> *Cc:* rdkit-discuss@lists.sourceforge.net
> *Subject:* Re: [Rdkit-discuss] adding custom number of explicit H to
> specified non-hydrogen atoms
>
> Hi Janusz,
>
> AddHs has a parameter "onlyOnAtoms" which takes a list of indices of atoms
> to include. [
> http://www.rdkit.org/Python_Docs/rdkit.Chem.rdmolops-module.html#AddHs]
>
> ----
> Pozdrawiam,  |  Best regards,
> Maciek Wójcikowski
> mac...@wojcikowski.pl
>
> 2017-01-20 23:21 GMT+01:00 Janusz Petkowski <jjpet...@mit.edu>:
>
> Dear RDKit Community,
>
> By default H atoms are not explicit in the molecular graph and because of
> that the substructure matching is ignoring them when searching for
> substructures. It is possible to use Chem.AddHs(mol) to add explicit
> hydrogens to all atoms in the molecule and then perform substructure
> matching but is it possible, in RDkit, to add explicit hydrogens
> specifically to atoms of choice instead to all of them?
>
> So let's say if I do:
>
> m1 = Chem.MolFromSmiles('C=C')
> m1_H = Chem.AddHs(m1)
> print m1_H.GetNumAtoms()
> print Chem.MolToSmiles(m1_H)
>
> The result is:
>
> >>> 6
> >>> [H]C([H])=C([H])[H]
>
> What if I would like to add only one (1)  explicit hydrogen atom to a
> specific non-hydrogen atom (let's say m1.GetAtomWithIdx(0). In that case I
> would want to have:
>
> print m1_H.GetNumAtoms()
> print Chem.MolToSmiles(m1_H)
>
> >>> 3
> >>> [H]C=C
>
> I tried to use the following method:
> m1.GetAtomWithIdx(0).SetNumExplicitHs(1) which correctly adds an explicit H
> to C=C molecule but somehow I cannot convert it to smiles with this one
> additional explicit H added or subsequently use  for substructure matching.
>
> At the end I would like to do a substructure matching where the following
> query structures:
>
>
> [H]C=C or [H]C=CC match the following molecule:
> [H]C(=C([H])C([H])([H])[H])C([H])([H])[H]
>
> but at the same time those query structures: [H]C=C([H])[H] or
> [H]C([H])=CC do not match [H]C(=C([H])C([H])([H])[H])C([H])([H])[H]
>
> PS. Of course, the structure [H]C([H])=C([H])[H] converted from C=C using
> Chem.AddHs(mol) will not be matched onto
> [H]C(=C([H])C([H])([H])[H])C([H])([H])[H] which is correct.
>
> Thank you very much for your help,
>
> Best regards,
>
> Janusz Petkowski
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to