Re: [Rdkit-discuss] Getting Started: labeling sidechain by number of core atom it was attached to

2017-02-22 Thread Greg Landrum
Hi Markus,


On Thu, Feb 23, 2017 at 1:41 AM, Markus Metz  wrote:

>
> According to the example it is possible to use the option
> labelByIndex=True in ReplaceCore.
> Converting the sidechains from mol to smiles with isomericSmiles=True
> labels the sidechains with 1 and 5.
> Where do these numbers come from?
>

They are the indices of the atoms in the core.


> I included the atom indices in the mol drawing but the core atoms are 1
> and 8. (please see attached jupyter file). What am I missing?
>

The code where you assign the atom map numbers so that you can see the
indices:


matches = m1.GetSubstructMatch(core)
print(matches)

for i, atom_idx in enumerate(matches, 1):
m1.GetAtomWithIdx(atom_idx).SetProp('molAtomMapNumber', str(atom_idx))


is using the indices in m1. You want the indices in the core:


for i, atom_idx in enumerate(matches, 1):
m1.GetAtomWithIdx(atom_idx).SetProp('molAtomMapNumber', str(i))


(Note: you can also do SetIntProp() and skip the conversion of i to a
string).

Best,
-greg
--
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] Getting Started: labeling sidechain by number of core atom it was attached to

2017-02-22 Thread Markus Metz
Dear all:

According to the example it is possible to use the option labelByIndex=True
in ReplaceCore.
Converting the sidechains from mol to smiles with isomericSmiles=True
labels the sidechains with 1 and 5.
Where do these numbers come from?
I included the atom indices in the mol drawing but the core atoms are 1 and
8. (please see attached jupyter file). What am I missing?

Thanks in advance for your help.

Best,

Markus


Testcase.ipynb
Description: Binary data
--
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] aligning maximum common substructure of 2 molecules

2017-02-22 Thread Thomas Evangelidis
OK, I am almost there!

First, I tried the AllChem.ConstrainedEmbed(qmol, core) function to
generate conformers, where core was a mol object created from the MCS with
3D coordinates copied from template's MCS. But is seems that this functions
works only when core is an intact molecule, because I get this error:

[15:48:22] Explicit valence for atom # 8 C, 5, is greater than permitted
> Traceback (most recent call last):
>   File "/usr/local/bin/align_lig.py", line 392, in 
> embed_conformers2(qmolname, refmolname, writer)
>   File "/usr/local/bin/align_lig.py", line 295, in embed_conformers2
> Chem.AllChem.EmbedMultipleConfs(patt)
> ValueError: Sanitization error: Explicit valence for atom # 8 C, 5, is
> greater than permitted
>


So I ended up working with distance restraints during optimization. At the
end of the email is the relevant part of the code. The problem is that most
of the geometries are wrong, namely distorted rings, out-of-plane
hydrogens, etc. At first, my code selected as the most representative
conformer of each query compound that one with the lowest RMSD and highest
shape similarity value to the template. But in most of the cases the
selected conformer had wrong geometry. How can I rule out such conformers?
One thought was to measure the energy and select the lowest energy
conformer, but this does not necessarily mean that it will be the one
resembling the template ligand the most.

Lastly and most importantly (!!!), RDKit fails to generate conformers for
many ligands. The error I get is:

[16:29:30] Could not triangle bounds smooth molecule.
> WARNING: No conformations generated for molecule erk36
>

What does this mean? Am I using an old version of RDKit (2015.03.1, the one
in Ubuntu repositories) ?


Thanks in advance,
Thomas


### THE RELEVANT CODE 


def embed_conformers1(qmolname, refmolname, writer):
>
> global qmolname2qmol_dict, refmolname2refmol_dict,
> qmolname_refmolname_fullscaffMCS_multidict, rmsthreshold, shapethreshold,
> nconf
> global forcetol, RMSD_cutoff
>
> qmol = qmolname2qmol_dict[qmolname]
> refmolname = qmolname_bestRefmolname_dict[qmolname] # the best
> reference ligand
> qmol.SetProp('refmolname', refmolname)  # save in its properties the
> name of the template ligand
> refmol = refmolname2refmol_dict[refmolname]
> refconf = refmol.GetConformer() # the original reference conformer
> qconf = qmol.GetConformer() # the original query conformer
>
> # nsuccess = 0# number of query compound conformations that passed
> the RMSD and SHAPE SIM threshold criteria
>
> #
> # : matchValences=True,completeRingsOnly=True,bondCompare="bondtypes"
> mcs = qmolname_refmolname_fullscaffMCS_multidict[qmolname][refmolname]
> patt  = Chem.MolFromSmarts(mcs.smartsString)
> refatoms = refmol.GetSubstructMatch(patt)  # reference ligand atoms of
> the MCS
> qatoms  = qmol.GetSubstructMatch(patt)# query compound atoms of
> the MCS
>
> aliatoms = []   # the atomMap for the restrained conformer generation
> (include hydrogens)
> coordmap = {}   # the coordinates of the restrained atoms in conformer
> generation
>
> # AVENUE4.1: copy the coordinates of the MCS of the reference to the
> query 1st conformer, generate N conformers using distance restraints and
> optimize
> # their geometry using distance restraints again.
> for k in range(0, len(refatoms) ):
> pt3 = refconf.GetAtomPosition(refatoms[k])
> qconf.SetAtomPosition(qatoms[k],pt3)
> coordmap[qatoms[k]] = pt3
> aliatoms.append( [qatoms[k], refatoms[k]] )
>
> qmol.AddConformer(qconf, assignId=0)# replace the original query
> conformer with the one which has a MCS with the reference ligand coordinates
> # Now generate N query conformer and save their conformer IDs
> newconfIDs = AllChem.EmbedMultipleConfs(qmol, coordMap=coordmap,
> forceTol=forcetol, numConfs=args.N, pruneRmsThresh=RMSD_cutoff)
>
> if(len(newconfIDs) == 0):
> print "WARNING: No conformations generated for molecule %s"
> %(qmolname)
> else:
> bestshape_sim = -1
> bestrms = 1e10
> bestconfID= -1
>
> confID_isvalid_dict = []# confID -> 1 if the conformer is not
> too similar to the other conformers, or 0 otherwise
> # loop over all generated conformations
> confIDEnergy_list = []
> for qconfID in range(0, len(newconfIDs)):
> # print "DEBUG: optimizing confomrer", qconfID
>
> confID_isvalid_dict.append(1)
> # Optimize current conformation
> # from ConstrainedEmbed() , minimization using constraints
> defined by MCS-matching atoms
> ff = AllChem.UFFGetMoleculeForceField(qmol, confId=qconfID)
> # Add distance constraints for minimization
> for k in range(0, len(refatoms) ):
> pt3 = refconf.GetAtomPosition(refatoms[k])
>   

Re: [Rdkit-discuss] problems with installation on conda with python 3.5 32-bit

2017-02-22 Thread Michal Krompiec
Hi Greg,
Thanks a lot, your help is much appreciated!
Thanks and kind regards,
Michal

On 22 February 2017 at 07:04, Greg Landrum  wrote:

> Michal,
>
> This morning I did a win32 build of the RDKit with python 3.5 and pushed
> it to anaconda. You should (hopefully) be able to do "conda install -c
> rdkit rdkit" now and have things work. I will try python 2.7 tomorrow.
>
> It turns out that this isn't much extra effort, so assuming this build
> works I should be able to keep doing these.
>
> -greg
>
>
> On Mon, Feb 20, 2017 at 9:33 PM, Michal Krompiec <
> michal.kromp...@gmail.com> wrote:
>
>> Hi Greg,
>> Thanks for your reply. Actually, >50% of my (prospective) users are stuck
>> on 32-bit. It would be really nice to have a python3 build (even once a
>> year) but I understand that the demand is low and waning. I guess the
>> solution is to use python2.7 for the time being...
>> Thanks and kind regards,
>> Michal
>>
>> On Monday, 20 February 2017, Greg Landrum  wrote:
>>
>>> Hi Michal,
>>>
>>> We've only ever done python2.7 builds for win32 and we stopped doing
>>> those with the 2016.03 release.
>>> I will have to check, but I think I probably can start doing these
>>> again, but I'm reluctant due to the amount of effort required.
>>> How many users do you need to support who are stuck on 32bit machines?
>>>
>>> -greg
>>>
>>>
>>> On Mon, Feb 20, 2017 at 2:18 PM, Michal Krompiec <
>>> michal.kromp...@gmail.com> wrote:
>>>
 Hello,
 I can't install rdkit on anaconda with 32-bit python3 on Windows 7.

 When I try "the usual", conda tries to install python2.7 into the
 environment:

 >conda create -c rdkit -n my-rdkit-env rdkit
 Fetching package metadata .
 Solving package specifications: .
 Package plan for installation in environment
 C:\Anaconda3_32\envs\my-rdkit-env:
 The following NEW packages will be INSTALLED:
 boost:  1.56.0-py27_3 rdkit
 bzip2:  1.0.6-vc9_3 [vc9]
 mkl:2017.0.1-0
 numpy:  1.11.3-py27_0
 pip:9.0.1-py27_1
 python: 2.7.13-0
 rdkit:  2016.03.1-np111py27_1 rdkit
 setuptools: 27.2.0-py27_1
 vs2008_runtime: 9.00.30729.5054-0
 wheel:  0.29.0-py27_0
 zlib:   1.2.8-vc9_3 [vc9]

 If I create an empty environment, load python 3.5 into it and try
 installing rdkit, I get an error:

 >conda create -n my-rdkit-env python=3.5
 Fetching package metadata ...
 Solving package specifications: .
 Package plan for installation in environment
 C:\Anaconda3_32\envs\my-rdkit-env:
 The following NEW packages will be INSTALLED:
 pip:9.0.1-py35_1
 python: 3.5.2-0
 setuptools: 27.2.0-py35_1
 vs2015_runtime: 14.0.25123-0
 wheel:  0.29.0-py35_0
 Proceed ([y]/n)?
 #
 # To activate this environment, use:
 # > activate my-rdkit-env
 #
 # To deactivate this environment, use:
 # > deactivate my-rdkit-env
 #
 # * for power-users using bash, you must source
 #

 >conda install --name my-rdkit-env -f --channel
 https://conda.anaconda.org/rdkit rdkit
 Fetching package metadata .
 Solving package specifications: .

 UnsatisfiableError: The following specifications were found to be in
 conflict:
   - python 3.5*
   - rdkit -> python 2.7*
 Use "conda info " to see the dependencies for each package.


 I managed to install rdkit without any problems on the same machine in
 64-bit anaconda with python3.5, but I need a separate 32-bit build to
 support users with 32-bit machines. Any help will be appreciated.

 Thanks and best regards,

 Michal


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