Re: [Rdkit-discuss] constrained embed: aromatic atom in core

2020-09-16 Thread Luan Carvalho Martins
You probably want to try tunning query parameters:
https://github.com/greglandrum/rdkit_blog/blob/master/notebooks/Tuning%20substructure%20queries.ipynb

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


On Wed, Sep 16, 2020 at 12:59 PM Rafael da Fonseca Lameiro <
rafael.lame...@alumni.usp.br> wrote:

> Hi all, I was applying the code from the ConstrainedEmbed tutorial
> <http://rdkit.blogspot.com/2013/12/using-allchemconstrainedembed.html>
> and found a problem when trying to embed a molecule with an aromatic atom
> that is not in the core. As an example, 1-aminopropan-2-one
> and 2-acetylpyridine:
> [image: image.png]
>
>
> from rdkit import Chem
> from rdkit.Chem import AllChem, rdFMCS
>
> m1 = Chem.MolFromSmiles("CC(CN)=O")
> m2 = Chem.MolFromSmiles("CC(C1=CC=CC=N1)=O")
> AllChem.EmbedMolecule(m1, useRandomCoords=True)
>
> mols = [m1, m2]
> res = rdFMCS.FindMCS(mols, threshold=0.8, completeRingsOnly=False)
> p = Chem.MolFromSmarts(res.smartsString)
>
> print(m1.HasSubstructMatch(p))  # True
> print(m2.HasSubstructMatch(p))  # True
>
> core1 =
> AllChem.DeleteSubstructs(AllChem.ReplaceSidechains(Chem.RemoveHs(m1), p),
> Chem.MolFromSmiles('*'))
> core1.UpdatePropertyCache()
>
> print(m1.HasSubstructMatch(core1))  # True
> print(m2.HasSubstructMatch(core1))  # False
>
> Of course, when I try:
>
> m3 = Chem.AddHs(m2, addCoords=True)
> Chem.AllChem.ConstrainedEmbed(m3, core1, ignoreSmoothingFailures=True,
> useTethers=True)
>
> I get ValueError("molecule doesn't match the core")
>
> For some reason, after p is converted to core1, it stops matching the
> aromatic N. If the N in m2 is not aromatic, the program works.
> In some cases, I was able to match m2 to the core, but the core is missing
> the N atom.
> Any thoughts on how to solve this? I am actually reading the scaffold m1
> from a .mol file, so I need that aromatic N there. Maybe there is a way to
> add information on m1 that states that its N should be aromatic.
>
> Thank you in advance
> --
> Rafael da Fonseca Lameiro
> MSc Organic and Biological Chemistry
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] FindMCS and chiral molecules

2020-01-10 Thread Luan Carvalho Martins
Dear all,

I'm facing issues applying FindMCS to chiral molecules. What I'm trying to
obtain is a 3D-like MCS (i.e.: an MCS containing the chiral carbons, but
not the substituents which differ). This is not what matchChiralFlag
does (*include
atom chirality in the match*). Is there a way of obtaining such MCS from
FindMCS?

A simple example:

m1 = rdkit.Chem.AddHs(rdkit.Chem.MolFromSmiles('CC(C)[C@H](C)O'))
m2 = rdkit.Chem.AddHs(rdkit.Chem.MolFromSmiles('CC(C)[C@@H](C)O'))
rdkit.Chem.rdFMCS.FindMCS([m1, m2], **magicalOptions).smartsString
Out: [H]C([H])([H])C([H])(CO)C([H])([H])[H]

If there is no simple option set to do that, is there another way to
achieve such? I'm thinking about using a flexible molecular alignment
(maybe first using an MCS core constraint to get more good conformers),
then compare atoms close to each other given a small tolerance. Then maybe
checking for ring membership and completeRingsOnly somehow.

Thank you very much

Sincerely,
Luan Carvalho Martins
luancarvalhomart...@gmail.com
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Setting atom type

2019-10-16 Thread Luan Carvalho Martins
Thank you for your answer, Paolo. I figure out what to do. For further
reference, I was trying to optimize a molecule containing dummy atoms.
Although rdkit.Chem.rdForceFieldHelpers.UFFGetMoleculeForceField complains
about the dummy atoms with "UFFTYPER: Unrecognized atom type: *_" messages,
but I still can call UFFAddDistanceConstraint, UFFAddAngleConstraint, etc,
using these atoms indices. This way I could optimize the molecule the way I
needed.

Thank you very much

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


On Wed, Oct 16, 2019 at 1:08 PM Paolo Tosco 
wrote:

> Hi Luan,
>
> as mentioned in the e-mail thread that you have found, it is not currently
> possible to change atom type definitions from Python.
>
> Could you give me a few more details regarding your use case? What are you
> trying to achieve? Feel free to reply to me off-list.
>
> Thanks, cheers
> p.
>
> On 10/16/19 20:18, Luan Carvalho Martins wrote:
>
> Dear all,
>
> Some years ago, in this list, there was a discussion regarding the
> possibility of explicitly setting the atom type of an atom in MMFF or UFF
> (thread: https://sourceforge.net/p/rdkit/mailman/message/31600590/). It
> is not clear if this functionality made to the code. Does anyone know if it
> did? Is there and alternative way to enforce an atom type to UFF/MMFF? Eg:
> by setting with atom names/atomic numbers?
>
> Thank you very much.
>
> Sincerely,
> Luan Carvalho Martins
> luancarvalhomart...@gmail.com
>
>
>
>
> ___
> Rdkit-discuss mailing 
> listRdkit-discuss@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
>
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] Setting atom type

2019-10-16 Thread Luan Carvalho Martins
Dear all,

Some years ago, in this list, there was a discussion regarding the
possibility of explicitly setting the atom type of an atom in MMFF or UFF
(thread: https://sourceforge.net/p/rdkit/mailman/message/31600590/). It is
not clear if this functionality made to the code. Does anyone know if it
did? Is there and alternative way to enforce an atom type to UFF/MMFF? Eg:
by setting with atom names/atomic numbers?

Thank you very much.

Sincerely,
Luan Carvalho Martins
luancarvalhomart...@gmail.com
___
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 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 <felipet...@gmail.com>
> 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 <paolo.to...@unito.it>:
>>>>
>>>>> 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
&

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 <felipet...@gmail.com>
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 <paolo.to...@unito.it>:
>>>
>>>> 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
>>&

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 <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 <paolo.to...@unito.it>:
>
>> 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