Re: [Rdkit-discuss] generate conformes with a restrained core

2018-03-24 Thread Felipe Trajtenberg
Hi Chris

yesterday I realize about this and using the following command appears to
do the job:

for cid in cids: AllChem.ConstrainedEmbed(newMol3D,coreMol,useTethers=True)

...














but then I cannot save the conformers because something is different:

for cid in cids:

w.write(newMol3D, cid)

Traceback (most recent call last):

  File "", line 2, in 

ValueError: Bad Conformer Id

before constrainedEmbed:

conf.GetId() for conf in newMol3D.GetConformers()]

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]

after:

[conf.GetId() for conf in newMol3D.GetConformers()]

[0]


why I am getting only one conformer? the idea is to constrain only the core
of the molecule. The other part should be sampled to build a rotamer library


thanks again for all your help!


felipe

2018-03-24 6:11 GMT-03:00 Chris Earnshaw :

> Hi Felipe
>
> You're doing something similar to the problem Paolo addressed.
>
> ConstrainedEmbed (see http://www.rdkit.org/Python_Docs/rdkit.Chem.AllChem-
> module.html#ConstrainedEmbed) requires a mol object as the first
> parameter, but you are passing it an integer cid value, not a molecule.
> Your code must retrieve the molecule associated with the cid number and
> pass that to ConstrainedEmbed instead of the cid number.
>
> Regards,
> Chris
>
> On 23 March 2018 at 21:58, Felipe Trajtenberg 
> wrote:
>
>> Hi Luan!
>> thanks!
>>
>> I was trying to use it but I am still struggling with very basic
>> problems. What you are saying is that I can delete the UFFOptimizeMolecule
>> and add a loop with ConstrainedEmbed to minimize with constraints?
>>
>> in my script, using:
>>
>> for cid in cids:
>> AllChem.ConstrainedEmbed(cid,coreMol,useTethers=True)
>>
>> I get the error:
>>
>> Traceback (most recent call last):
>>   File "", line 2, in 
>>   File "/export/home/felipet/.conda/envs/my-rdkit-env/lib/python2.7
>> /site-packages/rdkit/Chem/AllChem.py", line 274, in ConstrainedEmbed
>> match = mol.GetSubstructMatch(core)
>> AttributeError: 'int' object has no attribute 'GetSubstructMatch'
>>
>> what I am missing?
>>
>> thanks!
>>
>> 2018-03-23 16:19 GMT-03:00 Luan Carvalho Martins <
>> luancarvalhomart...@gmail.com>:
>>
>>> When you used AllChem.UFFOptimizeMolecule(newMol3D,confId=cid) the
>>> minimization proceeded without constraints, therefore, the core embedding
>>> was lost. Read the source of ConstrainedEmbed [
>>> http://www.rdkit.org/Python_Docs/rdkit.Chem.AllChem-pysrc.h
>>> tml#ConstrainedEmbed]. This function does a restricted minimization
>>> using AddDistanceConstraint.
>>>
>>> Sincerely,
>>> Luan Carvalho.
>>>
>>> Atenciosamente, Luan Carvalho Martins
>>> luancarvalhomart...@gmail.com
>>>
>>> On Fri, Mar 23, 2018 at 3:56 PM, Felipe Trajtenberg <
>>> felipet...@gmail.com> wrote:
>>>
 Hi Paolo

 great! it was a very simple thing. Now the sdf file with the conformers
 is generated but the conformers were not constraints at the core of the
 ligand...as I was trying? can you tell me why?

 thanks a lot!

 felipet

 2018-03-23 15:37 GMT-03:00 Paolo Tosco :

> Dear Felipe,
>
> cids is a list of conformer ids, i.e. integer numbers. Therefore
>
> prbMol = cids[prbNum]
>
> sets prbMol to the integer value of the prbNum element of the cids
> list.
>
> The reason of the error message you are getting:
> Boost.Python.ArgumentError: Python argument types in
> SDWriter.write(SDWriter, int)
> did not match C++ signature:
> write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol,
> int confId=-1)
>
> is that you are passing only an int to SDWriter.write(), rather than a
> mol and an int as the function expects.
> What you need is:
>
> nMol = len(cids)
> w = Chem.SDWriter('conf_output.sdf')
>
> for prbNum in range(0, nMol):
> prbMol = cids[prbNum]
> w.write(newMol3D, prbMol)
> w.close()
>
> or, more simply:
>
> w = Chem.SDWriter('conf_output.sdf')
>
> for cid in cids:
> w.write(newMol3D, cid)
> w.close()
>
> Cheers,
> p.
>
> On 03/23/18 18:04, Felipe Trajtenberg wrote:
>
> Dear all,
>
> sorry but I am really new at using RDkit. By looking at the scripts
> and tutorial available I wrote the following script. The idea is to
> generate a number of conformers for a big and flexible ligand, but with
> constraints. This script generate a set of conformers but I can't write a
> SDF file with all of them. The error I get is:
>
> Traceback (most recent call last):
>   File "", line 3, in 
> Boost.Python.ArgumentError: Python argument types in
> SDWriter.write(SDWriter, int)
> did not match C++ signature:
> write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol,
> int confId=-1)
>
> Thanks in 

Re: [Rdkit-discuss] generate conformes with a restrained core

2018-03-24 Thread Chris Earnshaw
Hi Felipe

You're doing something similar to the problem Paolo addressed.

ConstrainedEmbed (see
http://www.rdkit.org/Python_Docs/rdkit.Chem.AllChem-module.html#ConstrainedEmbed)
requires a mol object as the first parameter, but you are passing it an
integer cid value, not a molecule. Your code must retrieve the molecule
associated with the cid number and pass that to ConstrainedEmbed instead of
the cid number.

Regards,
Chris

On 23 March 2018 at 21:58, Felipe Trajtenberg  wrote:

> Hi Luan!
> thanks!
>
> I was trying to use it but I am still struggling with very basic problems.
> What you are saying is that I can delete the UFFOptimizeMolecule and add a
> loop with ConstrainedEmbed to minimize with constraints?
>
> in my script, using:
>
> for cid in cids:
> AllChem.ConstrainedEmbed(cid,coreMol,useTethers=True)
>
> I get the error:
>
> Traceback (most recent call last):
>   File "", line 2, in 
>   File "/export/home/felipet/.conda/envs/my-rdkit-env/lib/python2.
> 7/site-packages/rdkit/Chem/AllChem.py", line 274, in ConstrainedEmbed
> match = mol.GetSubstructMatch(core)
> AttributeError: 'int' object has no attribute 'GetSubstructMatch'
>
> what I am missing?
>
> thanks!
>
> 2018-03-23 16:19 GMT-03:00 Luan Carvalho Martins <
> luancarvalhomart...@gmail.com>:
>
>> When you used AllChem.UFFOptimizeMolecule(newMol3D,confId=cid) the
>> minimization proceeded without constraints, therefore, the core embedding
>> was lost. Read the source of ConstrainedEmbed [
>> http://www.rdkit.org/Python_Docs/rdkit.Chem.AllChem-pysrc.h
>> tml#ConstrainedEmbed]. This function does a restricted minimization
>> using AddDistanceConstraint.
>>
>> Sincerely,
>> Luan Carvalho.
>>
>> Atenciosamente, Luan Carvalho Martins
>> luancarvalhomart...@gmail.com
>>
>> On Fri, Mar 23, 2018 at 3:56 PM, Felipe Trajtenberg > > wrote:
>>
>>> Hi Paolo
>>>
>>> great! it was a very simple thing. Now the sdf file with the conformers
>>> is generated but the conformers were not constraints at the core of the
>>> ligand...as I was trying? can you tell me why?
>>>
>>> thanks a lot!
>>>
>>> felipet
>>>
>>> 2018-03-23 15:37 GMT-03:00 Paolo Tosco :
>>>
 Dear Felipe,

 cids is a list of conformer ids, i.e. integer numbers. Therefore

 prbMol = cids[prbNum]

 sets prbMol to the integer value of the prbNum element of the cids list.

 The reason of the error message you are getting:
 Boost.Python.ArgumentError: Python argument types in
 SDWriter.write(SDWriter, int)
 did not match C++ signature:
 write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, int
 confId=-1)

 is that you are passing only an int to SDWriter.write(), rather than a
 mol and an int as the function expects.
 What you need is:

 nMol = len(cids)
 w = Chem.SDWriter('conf_output.sdf')

 for prbNum in range(0, nMol):
 prbMol = cids[prbNum]
 w.write(newMol3D, prbMol)
 w.close()

 or, more simply:

 w = Chem.SDWriter('conf_output.sdf')

 for cid in cids:
 w.write(newMol3D, cid)
 w.close()

 Cheers,
 p.

 On 03/23/18 18:04, Felipe Trajtenberg wrote:

 Dear all,

 sorry but I am really new at using RDkit. By looking at the scripts and
 tutorial available I wrote the following script. The idea is to generate a
 number of conformers for a big and flexible ligand, but with constraints.
 This script generate a set of conformers but I can't write a SDF file with
 all of them. The error I get is:

 Traceback (most recent call last):
   File "", line 3, in 
 Boost.Python.ArgumentError: Python argument types in
 SDWriter.write(SDWriter, int)
 did not match C++ signature:
 write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, int
 confId=-1)

 Thanks in advance for any help

 felipet

 The script is:

 from rdkit import Chem
 from rdkit.Chem import AllChem
 import os

 mols = [x for x in Chem.SDMolSupplier('out.CRC.sdf',removeHs=False) if
 x is not None]
 core = Chem.MolFromSmarts('CCC(O)=O')


 em = Chem.EditableMol(mols[0])
 match = mols[0].GetSubstructMatch(core)
 for idx in range(mols[0].GetNumAtoms()-1,-1,-1):
 if idx not in match:
 em.RemoveAtom(idx)

 coreMol = em.GetMol()
 Chem.SanitizeMol(coreMol)

 newMol = Chem.MolFromSmiles('CC(O)=O')

 newMol=Chem.AddHs(newMol)
 newMol3D=AllChem.ConstrainedEmbed(newMol,coreMol)

 cids=AllChem.EmbedMultipleConfs(newMol3D,numConfs=100,pruneR
 msThresh=1.0,enforceChirality=True)
 for cid in cids: AllChem.UFFOptimizeMolecule(newMol3D,confId=cid)

 nMol = len(cids)
 w = Chem.SDWriter('conf_output.sdf')

 for prbNum in range(0, 

Re: [Rdkit-discuss] generate conformes with a restrained core

2018-03-23 Thread Felipe Trajtenberg
I understand, but I want the constrained core to be fixed

How would you optimize each conformers with the initial constraints?

If i don’t include de UFFOptimizeMolecule I still have important
differences at the level of the core...so they are not really
constrained...?

Thanks

Felipe

On Fri, Mar 23, 2018 at 9:20 PM Luan Carvalho Martins <
luancarvalhomart...@gmail.com> wrote:

> No, what I am suggesting is you to use a scheme similar to that applied in
> ConstrainedEmbed, namely, to add restraints between atoms you know the
> position. If you call ConstrainedEmbed several times, you will obtain the
> same confirmation again and again.
>
> Sincerely,
> Luan Carvalho
>
>
> Atenciosamente, Luan Carvalho Martins
> luancarvalhomart...@gmail.com
>
> On Fri, Mar 23, 2018 at 6:58 PM, Felipe Trajtenberg 
> wrote:
>
>> Hi Luan!
>> thanks!
>>
>> I was trying to use it but I am still struggling with very basic
>> problems. What you are saying is that I can delete the UFFOptimizeMolecule
>> and add a loop with ConstrainedEmbed to minimize with constraints?
>>
>> in my script, using:
>>
>> for cid in cids:
>> AllChem.ConstrainedEmbed(cid,coreMol,useTethers=True)
>>
>> I get the error:
>>
>> Traceback (most recent call last):
>>   File "", line 2, in 
>>   File
>> "/export/home/felipet/.conda/envs/my-rdkit-env/lib/python2.7/site-packages/rdkit/Chem/AllChem.py",
>> line 274, in ConstrainedEmbed
>> match = mol.GetSubstructMatch(core)
>> AttributeError: 'int' object has no attribute 'GetSubstructMatch'
>>
>> what I am missing?
>>
>> thanks!
>>
>> 2018-03-23 16:19 GMT-03:00 Luan Carvalho Martins <
>> luancarvalhomart...@gmail.com>:
>>
>>> When you used AllChem.UFFOptimizeMolecule(newMol3D,confId=cid) the
>>> minimization proceeded without constraints, therefore, the core embedding
>>> was lost. Read the source of ConstrainedEmbed [
>>> http://www.rdkit.org/Python_Docs/rdkit.Chem.AllChem-pysrc.html#ConstrainedEmbed].
>>> This function does a restricted minimization using AddDistanceConstraint.
>>>
>>> Sincerely,
>>> Luan Carvalho.
>>>
>>> Atenciosamente, Luan Carvalho Martins
>>> luancarvalhomart...@gmail.com
>>>
>>> On Fri, Mar 23, 2018 at 3:56 PM, Felipe Trajtenberg <
>>> felipet...@gmail.com> wrote:
>>>
 Hi Paolo

 great! it was a very simple thing. Now the sdf file with the conformers
 is generated but the conformers were not constraints at the core of the
 ligand...as I was trying? can you tell me why?

 thanks a lot!

 felipet

 2018-03-23 15:37 GMT-03:00 Paolo Tosco :

> Dear Felipe,
>
> cids is a list of conformer ids, i.e. integer numbers. Therefore
>
> prbMol = cids[prbNum]
>
> sets prbMol to the integer value of the prbNum element of the cids
> list.
>
> The reason of the error message you are getting:
> Boost.Python.ArgumentError: Python argument types in
> SDWriter.write(SDWriter, int)
> did not match C++ signature:
> write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol,
> int confId=-1)
>
> is that you are passing only an int to SDWriter.write(), rather than a
> mol and an int as the function expects.
> What you need is:
>
> nMol = len(cids)
> w = Chem.SDWriter('conf_output.sdf')
>
> for prbNum in range(0, nMol):
> prbMol = cids[prbNum]
> w.write(newMol3D, prbMol)
> w.close()
>
> or, more simply:
>
> w = Chem.SDWriter('conf_output.sdf')
>
> for cid in cids:
> w.write(newMol3D, cid)
> w.close()
>
> Cheers,
> p.
>
> On 03/23/18 18:04, Felipe Trajtenberg wrote:
>
> Dear all,
>
> sorry but I am really new at using RDkit. By looking at the scripts
> and tutorial available I wrote the following script. The idea is to
> generate a number of conformers for a big and flexible ligand, but with
> constraints. This script generate a set of conformers but I can't write a
> SDF file with all of them. The error I get is:
>
> Traceback (most recent call last):
>   File "", line 3, in 
> Boost.Python.ArgumentError: Python argument types in
> SDWriter.write(SDWriter, int)
> did not match C++ signature:
> write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol,
> int confId=-1)
>
> Thanks in advance for any help
>
> felipet
>
> The script is:
>
> from rdkit import Chem
> from rdkit.Chem import AllChem
> import os
>
> mols = [x for x in Chem.SDMolSupplier('out.CRC.sdf',removeHs=False)
> if x is not None]
> core = Chem.MolFromSmarts('CCC(O)=O')
>
>
> em = Chem.EditableMol(mols[0])
> match = mols[0].GetSubstructMatch(core)
> for idx in range(mols[0].GetNumAtoms()-1,-1,-1):
> if idx not in match:
> em.RemoveAtom(idx)
>
> coreMol = em.GetMol()
> 

Re: [Rdkit-discuss] generate conformes with a restrained core

2018-03-23 Thread Luan Carvalho Martins
For the record, it would be nice to see an *EmbedMultipleConstrainedConfs*
function in rdkit.

Atenciosamente, Luan Carvalho Martins
luancarvalhomart...@gmail.com

On Fri, Mar 23, 2018 at 9:20 PM, Luan Carvalho Martins <
luancarvalhomart...@gmail.com> wrote:

> No, what I am suggesting is you to use a scheme similar to that applied in
> ConstrainedEmbed, namely, to add restraints between atoms you know the
> position. If you call ConstrainedEmbed several times, you will obtain the
> same confirmation again and again.
>
> Sincerely,
> Luan Carvalho
>
>
> Atenciosamente, Luan Carvalho Martins
> luancarvalhomart...@gmail.com
>
> On Fri, Mar 23, 2018 at 6:58 PM, Felipe Trajtenberg 
> wrote:
>
>> Hi Luan!
>> thanks!
>>
>> I was trying to use it but I am still struggling with very basic
>> problems. What you are saying is that I can delete the UFFOptimizeMolecule
>> and add a loop with ConstrainedEmbed to minimize with constraints?
>>
>> in my script, using:
>>
>> for cid in cids:
>> AllChem.ConstrainedEmbed(cid,coreMol,useTethers=True)
>>
>> I get the error:
>>
>> Traceback (most recent call last):
>>   File "", line 2, in 
>>   File "/export/home/felipet/.conda/envs/my-rdkit-env/lib/python2.7
>> /site-packages/rdkit/Chem/AllChem.py", line 274, in ConstrainedEmbed
>> match = mol.GetSubstructMatch(core)
>> AttributeError: 'int' object has no attribute 'GetSubstructMatch'
>>
>> what I am missing?
>>
>> thanks!
>>
>> 2018-03-23 16:19 GMT-03:00 Luan Carvalho Martins <
>> luancarvalhomart...@gmail.com>:
>>
>>> When you used AllChem.UFFOptimizeMolecule(newMol3D,confId=cid) the
>>> minimization proceeded without constraints, therefore, the core embedding
>>> was lost. Read the source of ConstrainedEmbed [
>>> http://www.rdkit.org/Python_Docs/rdkit.Chem.AllChem-pysrc.h
>>> tml#ConstrainedEmbed]. This function does a restricted minimization
>>> using AddDistanceConstraint.
>>>
>>> Sincerely,
>>> Luan Carvalho.
>>>
>>> Atenciosamente, Luan Carvalho Martins
>>> luancarvalhomart...@gmail.com
>>>
>>> On Fri, Mar 23, 2018 at 3:56 PM, Felipe Trajtenberg <
>>> felipet...@gmail.com> wrote:
>>>
 Hi Paolo

 great! it was a very simple thing. Now the sdf file with the conformers
 is generated but the conformers were not constraints at the core of the
 ligand...as I was trying? can you tell me why?

 thanks a lot!

 felipet

 2018-03-23 15:37 GMT-03:00 Paolo Tosco :

> Dear Felipe,
>
> cids is a list of conformer ids, i.e. integer numbers. Therefore
>
> prbMol = cids[prbNum]
>
> sets prbMol to the integer value of the prbNum element of the cids
> list.
>
> The reason of the error message you are getting:
> Boost.Python.ArgumentError: Python argument types in
> SDWriter.write(SDWriter, int)
> did not match C++ signature:
> write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol,
> int confId=-1)
>
> is that you are passing only an int to SDWriter.write(), rather than a
> mol and an int as the function expects.
> What you need is:
>
> nMol = len(cids)
> w = Chem.SDWriter('conf_output.sdf')
>
> for prbNum in range(0, nMol):
> prbMol = cids[prbNum]
> w.write(newMol3D, prbMol)
> w.close()
>
> or, more simply:
>
> w = Chem.SDWriter('conf_output.sdf')
>
> for cid in cids:
> w.write(newMol3D, cid)
> w.close()
>
> Cheers,
> p.
>
> On 03/23/18 18:04, Felipe Trajtenberg wrote:
>
> Dear all,
>
> sorry but I am really new at using RDkit. By looking at the scripts
> and tutorial available I wrote the following script. The idea is to
> generate a number of conformers for a big and flexible ligand, but with
> constraints. This script generate a set of conformers but I can't write a
> SDF file with all of them. The error I get is:
>
> Traceback (most recent call last):
>   File "", line 3, in 
> Boost.Python.ArgumentError: Python argument types in
> SDWriter.write(SDWriter, int)
> did not match C++ signature:
> write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol,
> int confId=-1)
>
> Thanks in advance for any help
>
> felipet
>
> The script is:
>
> from rdkit import Chem
> from rdkit.Chem import AllChem
> import os
>
> mols = [x for x in Chem.SDMolSupplier('out.CRC.sdf',removeHs=False)
> if x is not None]
> core = Chem.MolFromSmarts('CCC(O)=O')
>
>
> em = Chem.EditableMol(mols[0])
> match = mols[0].GetSubstructMatch(core)
> for idx in range(mols[0].GetNumAtoms()-1,-1,-1):
> if idx not in match:
> em.RemoveAtom(idx)
>
> coreMol = em.GetMol()
> Chem.SanitizeMol(coreMol)
>
> newMol = Chem.MolFromSmiles('CC(O)=O')
>
> 

Re: [Rdkit-discuss] generate conformes with a restrained core

2018-03-23 Thread Luan Carvalho Martins
No, what I am suggesting is you to use a scheme similar to that applied in
ConstrainedEmbed, namely, to add restraints between atoms you know the
position. If you call ConstrainedEmbed several times, you will obtain the
same confirmation again and again.

Sincerely,
Luan Carvalho


Atenciosamente, Luan Carvalho Martins
luancarvalhomart...@gmail.com

On Fri, Mar 23, 2018 at 6:58 PM, Felipe Trajtenberg 
wrote:

> Hi Luan!
> thanks!
>
> I was trying to use it but I am still struggling with very basic problems.
> What you are saying is that I can delete the UFFOptimizeMolecule and add a
> loop with ConstrainedEmbed to minimize with constraints?
>
> in my script, using:
>
> for cid in cids:
> AllChem.ConstrainedEmbed(cid,coreMol,useTethers=True)
>
> I get the error:
>
> Traceback (most recent call last):
>   File "", line 2, in 
>   File "/export/home/felipet/.conda/envs/my-rdkit-env/lib/python2.
> 7/site-packages/rdkit/Chem/AllChem.py", line 274, in ConstrainedEmbed
> match = mol.GetSubstructMatch(core)
> AttributeError: 'int' object has no attribute 'GetSubstructMatch'
>
> what I am missing?
>
> thanks!
>
> 2018-03-23 16:19 GMT-03:00 Luan Carvalho Martins <
> luancarvalhomart...@gmail.com>:
>
>> When you used AllChem.UFFOptimizeMolecule(newMol3D,confId=cid) the
>> minimization proceeded without constraints, therefore, the core embedding
>> was lost. Read the source of ConstrainedEmbed [
>> http://www.rdkit.org/Python_Docs/rdkit.Chem.AllChem-pysrc.h
>> tml#ConstrainedEmbed]. This function does a restricted minimization
>> using AddDistanceConstraint.
>>
>> Sincerely,
>> Luan Carvalho.
>>
>> Atenciosamente, Luan Carvalho Martins
>> luancarvalhomart...@gmail.com
>>
>> On Fri, Mar 23, 2018 at 3:56 PM, Felipe Trajtenberg > > wrote:
>>
>>> Hi Paolo
>>>
>>> great! it was a very simple thing. Now the sdf file with the conformers
>>> is generated but the conformers were not constraints at the core of the
>>> ligand...as I was trying? can you tell me why?
>>>
>>> thanks a lot!
>>>
>>> felipet
>>>
>>> 2018-03-23 15:37 GMT-03:00 Paolo Tosco :
>>>
 Dear Felipe,

 cids is a list of conformer ids, i.e. integer numbers. Therefore

 prbMol = cids[prbNum]

 sets prbMol to the integer value of the prbNum element of the cids list.

 The reason of the error message you are getting:
 Boost.Python.ArgumentError: Python argument types in
 SDWriter.write(SDWriter, int)
 did not match C++ signature:
 write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, int
 confId=-1)

 is that you are passing only an int to SDWriter.write(), rather than a
 mol and an int as the function expects.
 What you need is:

 nMol = len(cids)
 w = Chem.SDWriter('conf_output.sdf')

 for prbNum in range(0, nMol):
 prbMol = cids[prbNum]
 w.write(newMol3D, prbMol)
 w.close()

 or, more simply:

 w = Chem.SDWriter('conf_output.sdf')

 for cid in cids:
 w.write(newMol3D, cid)
 w.close()

 Cheers,
 p.

 On 03/23/18 18:04, Felipe Trajtenberg wrote:

 Dear all,

 sorry but I am really new at using RDkit. By looking at the scripts and
 tutorial available I wrote the following script. The idea is to generate a
 number of conformers for a big and flexible ligand, but with constraints.
 This script generate a set of conformers but I can't write a SDF file with
 all of them. The error I get is:

 Traceback (most recent call last):
   File "", line 3, in 
 Boost.Python.ArgumentError: Python argument types in
 SDWriter.write(SDWriter, int)
 did not match C++ signature:
 write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, int
 confId=-1)

 Thanks in advance for any help

 felipet

 The script is:

 from rdkit import Chem
 from rdkit.Chem import AllChem
 import os

 mols = [x for x in Chem.SDMolSupplier('out.CRC.sdf',removeHs=False) if
 x is not None]
 core = Chem.MolFromSmarts('CCC(O)=O')


 em = Chem.EditableMol(mols[0])
 match = mols[0].GetSubstructMatch(core)
 for idx in range(mols[0].GetNumAtoms()-1,-1,-1):
 if idx not in match:
 em.RemoveAtom(idx)

 coreMol = em.GetMol()
 Chem.SanitizeMol(coreMol)

 newMol = Chem.MolFromSmiles('CC(O)=O')

 newMol=Chem.AddHs(newMol)
 newMol3D=AllChem.ConstrainedEmbed(newMol,coreMol)

 cids=AllChem.EmbedMultipleConfs(newMol3D,numConfs=100,pruneR
 msThresh=1.0,enforceChirality=True)
 for cid in cids: AllChem.UFFOptimizeMolecule(newMol3D,confId=cid)

 nMol = len(cids)
 w = Chem.SDWriter('conf_output.sdf')

 for prbNum in range(0, nMol):
 prbMol = cids[prbNum]
 w.write(prbMol)
 w.close()

Re: [Rdkit-discuss] generate conformes with a restrained core

2018-03-23 Thread Felipe Trajtenberg
Hi Luan!
thanks!

I was trying to use it but I am still struggling with very basic problems.
What you are saying is that I can delete the UFFOptimizeMolecule and add a
loop with ConstrainedEmbed to minimize with constraints?

in my script, using:

for cid in cids:
AllChem.ConstrainedEmbed(cid,coreMol,useTethers=True)

I get the error:

Traceback (most recent call last):
  File "", line 2, in 
  File
"/export/home/felipet/.conda/envs/my-rdkit-env/lib/python2.7/site-packages/rdkit/Chem/AllChem.py",
line 274, in ConstrainedEmbed
match = mol.GetSubstructMatch(core)
AttributeError: 'int' object has no attribute 'GetSubstructMatch'

what I am missing?

thanks!

2018-03-23 16:19 GMT-03:00 Luan Carvalho Martins <
luancarvalhomart...@gmail.com>:

> When you used AllChem.UFFOptimizeMolecule(newMol3D,confId=cid) the
> minimization proceeded without constraints, therefore, the core embedding
> was lost. Read the source of ConstrainedEmbed [
> http://www.rdkit.org/Python_Docs/rdkit.Chem.AllChem-pysrc.
> html#ConstrainedEmbed]. This function does a restricted minimization
> using AddDistanceConstraint.
>
> Sincerely,
> Luan Carvalho.
>
> Atenciosamente, Luan Carvalho Martins
> luancarvalhomart...@gmail.com
>
> On Fri, Mar 23, 2018 at 3:56 PM, Felipe Trajtenberg 
> wrote:
>
>> Hi Paolo
>>
>> great! it was a very simple thing. Now the sdf file with the conformers
>> is generated but the conformers were not constraints at the core of the
>> ligand...as I was trying? can you tell me why?
>>
>> thanks a lot!
>>
>> felipet
>>
>> 2018-03-23 15:37 GMT-03:00 Paolo Tosco :
>>
>>> Dear Felipe,
>>>
>>> cids is a list of conformer ids, i.e. integer numbers. Therefore
>>>
>>> prbMol = cids[prbNum]
>>>
>>> sets prbMol to the integer value of the prbNum element of the cids list.
>>>
>>> The reason of the error message you are getting:
>>> Boost.Python.ArgumentError: Python argument types in
>>> SDWriter.write(SDWriter, int)
>>> did not match C++ signature:
>>> write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, int
>>> confId=-1)
>>>
>>> is that you are passing only an int to SDWriter.write(), rather than a
>>> mol and an int as the function expects.
>>> What you need is:
>>>
>>> nMol = len(cids)
>>> w = Chem.SDWriter('conf_output.sdf')
>>>
>>> for prbNum in range(0, nMol):
>>> prbMol = cids[prbNum]
>>> w.write(newMol3D, prbMol)
>>> w.close()
>>>
>>> or, more simply:
>>>
>>> w = Chem.SDWriter('conf_output.sdf')
>>>
>>> for cid in cids:
>>> w.write(newMol3D, cid)
>>> w.close()
>>>
>>> Cheers,
>>> p.
>>>
>>> On 03/23/18 18:04, Felipe Trajtenberg wrote:
>>>
>>> Dear all,
>>>
>>> sorry but I am really new at using RDkit. By looking at the scripts and
>>> tutorial available I wrote the following script. The idea is to generate a
>>> number of conformers for a big and flexible ligand, but with constraints.
>>> This script generate a set of conformers but I can't write a SDF file with
>>> all of them. The error I get is:
>>>
>>> Traceback (most recent call last):
>>>   File "", line 3, in 
>>> Boost.Python.ArgumentError: Python argument types in
>>> SDWriter.write(SDWriter, int)
>>> did not match C++ signature:
>>> write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, int
>>> confId=-1)
>>>
>>> Thanks in advance for any help
>>>
>>> felipet
>>>
>>> The script is:
>>>
>>> from rdkit import Chem
>>> from rdkit.Chem import AllChem
>>> import os
>>>
>>> mols = [x for x in Chem.SDMolSupplier('out.CRC.sdf',removeHs=False) if
>>> x is not None]
>>> core = Chem.MolFromSmarts('CCC(O)=O')
>>>
>>>
>>> em = Chem.EditableMol(mols[0])
>>> match = mols[0].GetSubstructMatch(core)
>>> for idx in range(mols[0].GetNumAtoms()-1,-1,-1):
>>> if idx not in match:
>>> em.RemoveAtom(idx)
>>>
>>> coreMol = em.GetMol()
>>> Chem.SanitizeMol(coreMol)
>>>
>>> newMol = Chem.MolFromSmiles('CC(O)=O')
>>>
>>> newMol=Chem.AddHs(newMol)
>>> newMol3D=AllChem.ConstrainedEmbed(newMol,coreMol)
>>>
>>> cids=AllChem.EmbedMultipleConfs(newMol3D,numConfs=100,pruneR
>>> msThresh=1.0,enforceChirality=True)
>>> for cid in cids: AllChem.UFFOptimizeMolecule(newMol3D,confId=cid)
>>>
>>> nMol = len(cids)
>>> w = Chem.SDWriter('conf_output.sdf')
>>>
>>> for prbNum in range(0, nMol):
>>> prbMol = cids[prbNum]
>>> w.write(prbMol)
>>> w.close()
>>>
>>>
>>>
>>> --
>>> 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 
>>> listRdkit-discuss@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>>
>>>
>>>
>>
>> 
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech 

Re: [Rdkit-discuss] generate conformes with a restrained core

2018-03-23 Thread Luan Carvalho Martins
When you used AllChem.UFFOptimizeMolecule(newMol3D,confId=cid) the
minimization proceeded without constraints, therefore, the core embedding
was lost. Read the source of ConstrainedEmbed [
http://www.rdkit.org/Python_Docs/rdkit.Chem.AllChem-pysrc.html#ConstrainedEmbed].
This function does a restricted minimization using AddDistanceConstraint.

Sincerely,
Luan Carvalho.

Atenciosamente, Luan Carvalho Martins
luancarvalhomart...@gmail.com

On Fri, Mar 23, 2018 at 3:56 PM, Felipe Trajtenberg 
wrote:

> Hi Paolo
>
> great! it was a very simple thing. Now the sdf file with the conformers is
> generated but the conformers were not constraints at the core of the
> ligand...as I was trying? can you tell me why?
>
> thanks a lot!
>
> felipet
>
> 2018-03-23 15:37 GMT-03:00 Paolo Tosco :
>
>> Dear Felipe,
>>
>> cids is a list of conformer ids, i.e. integer numbers. Therefore
>>
>> prbMol = cids[prbNum]
>>
>> sets prbMol to the integer value of the prbNum element of the cids list.
>>
>> The reason of the error message you are getting:
>> Boost.Python.ArgumentError: Python argument types in
>> SDWriter.write(SDWriter, int)
>> did not match C++ signature:
>> write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, int
>> confId=-1)
>>
>> is that you are passing only an int to SDWriter.write(), rather than a
>> mol and an int as the function expects.
>> What you need is:
>>
>> nMol = len(cids)
>> w = Chem.SDWriter('conf_output.sdf')
>>
>> for prbNum in range(0, nMol):
>> prbMol = cids[prbNum]
>> w.write(newMol3D, prbMol)
>> w.close()
>>
>> or, more simply:
>>
>> w = Chem.SDWriter('conf_output.sdf')
>>
>> for cid in cids:
>> w.write(newMol3D, cid)
>> w.close()
>>
>> Cheers,
>> p.
>>
>> On 03/23/18 18:04, Felipe Trajtenberg wrote:
>>
>> Dear all,
>>
>> sorry but I am really new at using RDkit. By looking at the scripts and
>> tutorial available I wrote the following script. The idea is to generate a
>> number of conformers for a big and flexible ligand, but with constraints.
>> This script generate a set of conformers but I can't write a SDF file with
>> all of them. The error I get is:
>>
>> Traceback (most recent call last):
>>   File "", line 3, in 
>> Boost.Python.ArgumentError: Python argument types in
>> SDWriter.write(SDWriter, int)
>> did not match C++ signature:
>> write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, int
>> confId=-1)
>>
>> Thanks in advance for any help
>>
>> felipet
>>
>> The script is:
>>
>> from rdkit import Chem
>> from rdkit.Chem import AllChem
>> import os
>>
>> mols = [x for x in Chem.SDMolSupplier('out.CRC.sdf',removeHs=False) if x
>> is not None]
>> core = Chem.MolFromSmarts('CCC(O)=O')
>>
>>
>> em = Chem.EditableMol(mols[0])
>> match = mols[0].GetSubstructMatch(core)
>> for idx in range(mols[0].GetNumAtoms()-1,-1,-1):
>> if idx not in match:
>> em.RemoveAtom(idx)
>>
>> coreMol = em.GetMol()
>> Chem.SanitizeMol(coreMol)
>>
>> newMol = Chem.MolFromSmiles('CC(O)=O')
>>
>> newMol=Chem.AddHs(newMol)
>> newMol3D=AllChem.ConstrainedEmbed(newMol,coreMol)
>>
>> cids=AllChem.EmbedMultipleConfs(newMol3D,numConfs=100,pruneRmsThresh=1.0,
>> enforceChirality=True)
>> for cid in cids: AllChem.UFFOptimizeMolecule(newMol3D,confId=cid)
>>
>> nMol = len(cids)
>> w = Chem.SDWriter('conf_output.sdf')
>>
>> for prbNum in range(0, nMol):
>> prbMol = cids[prbNum]
>> w.write(prbMol)
>> w.close()
>>
>>
>>
>> --
>> 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 
>> listRdkit-discuss@lists.sourceforge.nethttps://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


Re: [Rdkit-discuss] generate conformes with a restrained core

2018-03-23 Thread Felipe Trajtenberg
Hi Paolo

great! it was a very simple thing. Now the sdf file with the conformers is
generated but the conformers were not constraints at the core of the
ligand...as I was trying? can you tell me why?

thanks a lot!

felipet

2018-03-23 15:37 GMT-03:00 Paolo Tosco :

> Dear Felipe,
>
> cids is a list of conformer ids, i.e. integer numbers. Therefore
>
> prbMol = cids[prbNum]
>
> sets prbMol to the integer value of the prbNum element of the cids list.
>
> The reason of the error message you are getting:
> Boost.Python.ArgumentError: Python argument types in
> SDWriter.write(SDWriter, int)
> did not match C++ signature:
> write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, int
> confId=-1)
>
> is that you are passing only an int to SDWriter.write(), rather than a mol
> and an int as the function expects.
> What you need is:
>
> nMol = len(cids)
> w = Chem.SDWriter('conf_output.sdf')
>
> for prbNum in range(0, nMol):
> prbMol = cids[prbNum]
> w.write(newMol3D, prbMol)
> w.close()
>
> or, more simply:
>
> w = Chem.SDWriter('conf_output.sdf')
>
> for cid in cids:
> w.write(newMol3D, cid)
> w.close()
>
> Cheers,
> p.
>
> On 03/23/18 18:04, Felipe Trajtenberg wrote:
>
> Dear all,
>
> sorry but I am really new at using RDkit. By looking at the scripts and
> tutorial available I wrote the following script. The idea is to generate a
> number of conformers for a big and flexible ligand, but with constraints.
> This script generate a set of conformers but I can't write a SDF file with
> all of them. The error I get is:
>
> Traceback (most recent call last):
>   File "", line 3, in 
> Boost.Python.ArgumentError: Python argument types in
> SDWriter.write(SDWriter, int)
> did not match C++ signature:
> write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, int
> confId=-1)
>
> Thanks in advance for any help
>
> felipet
>
> The script is:
>
> from rdkit import Chem
> from rdkit.Chem import AllChem
> import os
>
> mols = [x for x in Chem.SDMolSupplier('out.CRC.sdf',removeHs=False) if x
> is not None]
> core = Chem.MolFromSmarts('CCC(O)=O')
>
>
> em = Chem.EditableMol(mols[0])
> match = mols[0].GetSubstructMatch(core)
> for idx in range(mols[0].GetNumAtoms()-1,-1,-1):
> if idx not in match:
> em.RemoveAtom(idx)
>
> coreMol = em.GetMol()
> Chem.SanitizeMol(coreMol)
>
> newMol = Chem.MolFromSmiles('CC(O)=O')
>
> newMol=Chem.AddHs(newMol)
> newMol3D=AllChem.ConstrainedEmbed(newMol,coreMol)
>
> cids=AllChem.EmbedMultipleConfs(newMol3D,numConfs=100,pruneRmsThresh=1.
> 0,enforceChirality=True)
> for cid in cids: AllChem.UFFOptimizeMolecule(newMol3D,confId=cid)
>
> nMol = len(cids)
> w = Chem.SDWriter('conf_output.sdf')
>
> for prbNum in range(0, nMol):
> prbMol = cids[prbNum]
> w.write(prbMol)
> w.close()
>
>
>
> --
> 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 
> listRdkit-discuss@lists.sourceforge.nethttps://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


Re: [Rdkit-discuss] generate conformes with a restrained core

2018-03-23 Thread Paolo Tosco

Dear Felipe,

cids is a list of conformer ids, i.e. integer numbers. Therefore

prbMol = cids[prbNum]

sets prbMol to the integer value of the prbNum element of the cids list.

The reason of the error message you are getting:

Boost.Python.ArgumentError: Python argument types in
    SDWriter.write(SDWriter, int)
did not match C++ signature:
    write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, int 
confId=-1)


is that you are passing only an int to SDWriter.write(), rather than a 
mol and an int as the function expects.

What you need is:

nMol = len(cids)
w = Chem.SDWriter('conf_output.sdf')

for prbNum in range(0, nMol):
    prbMol = cids[prbNum]
    w.write(newMol3D, prbMol)
w.close()

or, more simply:

w = Chem.SDWriter('conf_output.sdf')

for cid in cids:
    w.write(newMol3D, cid)
w.close()

Cheers,
p.

On 03/23/18 18:04, Felipe Trajtenberg wrote:

Dear all,

sorry but I am really new at using RDkit. By looking at the scripts 
and tutorial available I wrote the following script. The idea is to 
generate a number of conformers for a big and flexible ligand, but 
with constraints. This script generate a set of conformers but I can't 
write a SDF file with all of them. The error I get is:


Traceback (most recent call last):
  File "", line 3, in 
Boost.Python.ArgumentError: Python argument types in
    SDWriter.write(SDWriter, int)
did not match C++ signature:
    write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, 
int confId=-1)


Thanks in advance for any help

felipet

The script is:

from rdkit import Chem
from rdkit.Chem import AllChem
import os

mols = [x for x in Chem.SDMolSupplier('out.CRC.sdf',removeHs=False) if 
x is not None]

core = Chem.MolFromSmarts('CCC(O)=O')


em = Chem.EditableMol(mols[0])
match = mols[0].GetSubstructMatch(core)
for idx in range(mols[0].GetNumAtoms()-1,-1,-1):
    if idx not in match:
em.RemoveAtom(idx)

coreMol = em.GetMol()
Chem.SanitizeMol(coreMol)

newMol = Chem.MolFromSmiles('CC(O)=O')

newMol=Chem.AddHs(newMol)
newMol3D=AllChem.ConstrainedEmbed(newMol,coreMol)

cids=AllChem.EmbedMultipleConfs(newMol3D,numConfs=100,pruneRmsThresh=1.0,enforceChirality=True)
for cid in cids: AllChem.UFFOptimizeMolecule(newMol3D,confId=cid)

nMol = len(cids)
w = Chem.SDWriter('conf_output.sdf')

for prbNum in range(0, nMol):
    prbMol = cids[prbNum]
    w.write(prbMol)
w.close()



--
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


[Rdkit-discuss] generate conformes with a restrained core

2018-03-23 Thread Felipe Trajtenberg
Dear all,

sorry but I am really new at using RDkit. By looking at the scripts and
tutorial available I wrote the following script. The idea is to generate a
number of conformers for a big and flexible ligand, but with constraints.
This script generate a set of conformers but I can't write a SDF file with
all of them. The error I get is:

Traceback (most recent call last):
  File "", line 3, in 
Boost.Python.ArgumentError: Python argument types in
SDWriter.write(SDWriter, int)
did not match C++ signature:
write(RDKit::SDWriter {lvalue} self, RDKit::ROMol {lvalue} mol, int
confId=-1)

Thanks in advance for any help

felipet

The script is:

from rdkit import Chem
from rdkit.Chem import AllChem
import os

mols = [x for x in Chem.SDMolSupplier('out.CRC.sdf',removeHs=False) if x is
not None]
core = Chem.MolFromSmarts('CCC(O)=O')


em = Chem.EditableMol(mols[0])
match = mols[0].GetSubstructMatch(core)
for idx in range(mols[0].GetNumAtoms()-1,-1,-1):
if idx not in match:
em.RemoveAtom(idx)

coreMol = em.GetMol()
Chem.SanitizeMol(coreMol)

newMol = Chem.MolFromSmiles('CC(O)=O')

newMol=Chem.AddHs(newMol)
newMol3D=AllChem.ConstrainedEmbed(newMol,coreMol)

cids=AllChem.EmbedMultipleConfs(newMol3D,numConfs=100,pruneRmsThresh=1.0,enforceChirality=True)
for cid in cids: AllChem.UFFOptimizeMolecule(newMol3D,confId=cid)

nMol = len(cids)
w = Chem.SDWriter('conf_output.sdf')

for prbNum in range(0, nMol):
prbMol = cids[prbNum]
w.write(prbMol)
w.close()
--
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