Re: [Rdkit-discuss] generate conformes with a restrained core
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
From: Felipe T. <fel...@gm...> - 2018-03-24 11:36:51
|
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) ... <rdkit.Chem.rdchem.Mol object at 0x2ac7a04d6280> <rdkit.Chem.rdchem.Mol object at 0x2ac7a04d6280> <rdkit.Chem.rdchem.Mol object at 0x2ac7a04d6280> <rdkit.Chem.rdchem.Mol object at 0x2ac7a04d6280> <rdkit.Chem.rdchem.Mol object at 0x2ac7a04d6280> <rdkit.Chem.rdchem.Mol object at 0x2ac7a04d6280> 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 "<stdin>", line 2, in <module> 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 <cge...@gm...>: > 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 <fel...@gm...> > 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 "<stdin>", line 2, in <module> >> 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 < >> lua...@gm...>: >> >>> 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 >>> lua...@gm... >>> >>> On Fri, Mar 23, 2018 at 3:56 PM, Felipe Trajtenberg < >>> fel...@gm...> 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 <pao...@un...>: >>>> >>>>> 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 "<stdin>", line 3, in <module> >>>>> 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('CCCCCCCCCCCCCCC(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('CCCCCCCCCCCCCCCCCCCCCCCCCC(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 lis...@li...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 >>>> Rdk...@li... >>>> 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 >> Rdk...@li... >> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >> >> > |