Ok,  one last question. I try to update my RDKit to the current version 
(rdkit-Release_2016_09_3) which I downloaded from here 
https://github.com/rdkit/rdkit/releases so I can use onlyOnAtoms function.

My current version (2015.03.1.) installed on Win 7 machine works perfectly 
well.  I have downloaded the new one - rdkit-Release_2016_09_3 - I have set up 
environmental variables as described in Win installation guide  (and as I had 
to set them up last time to get the previous 2015.03.1 version working) and at 
the end I have an import error like that:

from rdkit import Chem
  File "C:\rdkit-Release_2016_09_3\rdkit\__init__.py", line 2, in <module>
    from .rdBase import rdkitVersion as __version__
ImportError: No module named rdBase

I presume that this is somehow related to missing DLLs? But I had them 
installed when I got the old version, so they should be there. When I try to 
download them from here 
http://www.microsoft.com/en-us/download/details.aspx?id=5555 anyway, I got a 
notification that newer DLLs are already installed.

Reverting to my previous RDkit version 2015.03.1. allows everything to work 
again.

Does anybody know how to circumvent this problem?

Thank you once again!

Janusz
________________________________
From: Peter Gedeck [peter.ged...@gmail.com]
Sent: Saturday, January 21, 2017 3:44 PM
To: Janusz Petkowski; Maciek Wójcikowski
Cc: rdkit-discuss@lists.sourceforge.net
Subject: Re: [Rdkit-discuss] adding custom number of explicit H to specified 
non-hydrogen atoms

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<mailto: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<mailto:mac...@wojcikowski.pl>]
Sent: Saturday, January 21, 2017 3:11 PM

To: Janusz Petkowski
Cc: 
rdkit-discuss@lists.sourceforge.net<mailto: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<mailto:mac...@wojcikowski.pl>

2017-01-21 15:54 GMT+01:00 Janusz Petkowski 
<jjpet...@mit.edu<mailto: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<mailto:mac...@wojcikowski.pl>]
Sent: Saturday, January 21, 2017 5:35 AM
To: Janusz Petkowski
Cc: 
rdkit-discuss@lists.sourceforge.net<mailto: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<mailto:mac...@wojcikowski.pl>

2017-01-20 23:21 GMT+01:00 Janusz Petkowski 
<jjpet...@mit.edu<mailto: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<mailto: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<mailto: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