Re: [Rdkit-discuss] Align SDF to user-supplied template coordinates (2D)

2010-08-23 Thread Greg Landrum
On Mon, Aug 16, 2010 at 7:12 AM, James Davidson j.david...@vernalis.com wrote:

 You're doing it correctly; no worries there. The problem is
 that most pieces of chemical drawing software generate 2D
 coordinates for molecules such that a C-C single bond is 1.0A
 long. The RDKit, on the other hand, sets the C-C single bond
 to be 1.5A long. The consequence is a depiction with a core
 that's smaller than it should be.

 I was using ISISDraw for sketching the core motif.  It seems that the
 single-bond length (from the Origdraw settings) is ~ 0.825 A (!)

that's seems peculiar, but I guess there's some rationale behind it.

 So I modified the scalar to 1.818 (1.5/0.825) in your code and it works
 beautifully!

Glad to hear it.

 It should be possible to specify the scale used in the RDKit
 depictions so that these contortions are not necessary. I
 will put a feature request in for this and get it in the next version.

 Thanks for this - I certainly think this would be a worthwhile feature.
 What I may implement in the meantime is running through all the bonds of
 type SINGLE in the core molecule, taking the average, then using
 1.5/(average) as the scalar to protect against differing user settings!

I checked the changes in this weekend. From python you can now provide
a bondLength argument to set the value that's used while generating
depictions. The default value for this is -1, which means don't mess
with the default.

-greg

--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] Align SDF to user-supplied template coordinates (2D)

2010-08-16 Thread James Davidson
Dear All,
 
I am currently struggling with something that I expect is very easy to
solve (I have just got back from holiday, so I think my brain isn't
quite in the zone!)
 
I am trying to read in an SDF and align each molecule to a template
scaffold provided in molfile format.  I want to supply a tool that
allows a user to sketch in a template and view their SDF entries in 2D
all aligned (where there is a match) to the supplied template.
 
I have essentially followed this entry in the Chemistry Toolkit Rosetta
-
http://ctr.wikia.com/wiki/Align_the_depiction_using_a_fixed_substructure
http://ctr.wikia.com/wiki/Align_the_depiction_using_a_fixed_substructur
e , which in essence is pretty-much the same as the info in the RDKit
documentation.
 
However, when I am using pre-supplied 2D coordinates for the template,
rather than generating them from the first substructure match (as in the
CTR example), I find that the alignment proceeds as required, but there
is a mis-match between the scaling of the bond-lengths in the aligned
substructure compared with the rest of the molecule...
 
Is there a way to 'scale' the molecules according to the template mol
(or alternatively scale the template according to the RDKit default)?
Or is it that I am tackling this in the wrong way?
 
Kind regards
 
James

__
PLEASE READ: This email is confidential and may be privileged. It is intended 
for the named addressee(s) only and access to it by anyone else is 
unauthorised. If you are not an addressee, any disclosure or copying of the 
contents of this email or any action taken (or not taken) in reliance on it is 
unauthorised and may be unlawful. If you have received this email in error, 
please notify the sender or postmas...@vernalis.com. Email is not a secure 
method of communication and the Company cannot accept responsibility for the 
accuracy or completeness of this message or any attachment(s). Please check 
this email for virus infection for which the Company accepts no responsibility. 
If verification of this email is sought then please request a hard copy. Unless 
otherwise stated, any views or opinions presented are solely those of the 
author and do not represent those of the Company.

The Vernalis Group of Companies
Oakdene Court
613 Reading Road
Winnersh, Berkshire
RG41 5UA.
Tel: +44 118 977 3133

To access trading company registration and address details, please go to the 
Vernalis website at www.vernalis.com and click on the Company address and 
registration details link at the bottom of the page..
__--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev ___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Align SDF to user-supplied template coordinates (2D)

2010-08-16 Thread Greg Landrum
Hi James,

On Mon, Aug 16, 2010 at 1:09 PM, James Davidson j.david...@vernalis.com wrote:

 I am currently struggling with something that I expect is very easy to solve
 (I have just got back from holiday, so I think my brain isn't quite in the
 zone!)

yes, I know that feeling well.

 I am trying to read in an SDF and align each molecule to a template scaffold
 provided in molfile format.  I want to supply a tool that allows a user to
 sketch in a template and view their SDF entries in 2D all aligned (where
 there is a match) to the supplied template.

 I have essentially followed this entry in the Chemistry Toolkit Rosetta -
 http://ctr.wikia.com/wiki/Align_the_depiction_using_a_fixed_substructure,
 which in essence is pretty-much the same as the info in the RDKit
 documentation.

 However, when I am using pre-supplied 2D coordinates for the template,
 rather than generating them from the first substructure match (as in the CTR
 example), I find that the alignment proceeds as required, but there is a
 mis-match between the scaling of the bond-lengths in the aligned
 substructure compared with the rest of the molecule...

Ah yes, the depictions that you get look rather silly, no?

 Is there a way to 'scale' the molecules according to the template mol (or
 alternatively scale the template according to the RDKit default)?  Or is it
 that I am tackling this in the wrong way?

You're doing it correctly; no worries there. The problem is that most
pieces of chemical drawing software generate 2D coordinates for
molecules such that a C-C single bond is 1.0A long. The RDKit, on the
other hand, sets the C-C single bond to be 1.5A long. The consequence
is a depiction with a core that's smaller than it should be.

It's straightforward to solve the problem:
#---
from rdkit import Chem
from rdkit.Chem import AllChem
core = Chem.MolFromMolFile('core.mol')

# first scale the core so that a single bond is 1.5A:
center = AllChem.ComputeCentroid(core.GetConformer())
import numpy
tf = numpy.identity(4,numpy.float)
tf[0][3] -= center[0]
tf[1][3] -= center[1]
tf[0][0] = tf[1][1] = tf[2][2] = 1.5
AllChem.TransformMol(core,tf)

m = Chem.MolFromSmiles('c12c1nc(CC)cc2C(=O)O')
from rdkit import Geometry
coords = [core.GetConformer().GetAtomPosition(x) for x in
range(core.GetNumAtoms())]
coords2D = [Geometry.Point2D(pt.x,pt.y) for pt in coords]
cd = {}
match = m.GetSubstructMatch(core)
for i,coord in enumerate(coords2D): cd[match[i]] = coord
AllChem.Compute2DCoords(m,coordMap=cd)
#---

It should be possible to specify the scale used in the RDKit
depictions so that these contortions are not necessary. I will put a
feature request in for this and get it in the next version.

-greg

--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Align SDF to user-supplied template coordinates (2D)

2010-08-16 Thread James Davidson
Thanks Greg,

Greg wrote:
 Ah yes, the depictions that you get look rather silly, no?

Yes they do!

 You're doing it correctly; no worries there. The problem is 
 that most pieces of chemical drawing software generate 2D 
 coordinates for molecules such that a C-C single bond is 1.0A 
 long. The RDKit, on the other hand, sets the C-C single bond 
 to be 1.5A long. The consequence is a depiction with a core 
 that's smaller than it should be.

I was using ISISDraw for sketching the core motif.  It seems that the
single-bond length (from the Origdraw settings) is ~ 0.825 A (!)

So I modified the scalar to 1.818 (1.5/0.825) in your code and it works
beautifully!
 
 It should be possible to specify the scale used in the RDKit 
 depictions so that these contortions are not necessary. I 
 will put a feature request in for this and get it in the next version.

Thanks for this - I certainly think this would be a worthwhile feature.
What I may implement in the meantime is running through all the bonds of
type SINGLE in the core molecule, taking the average, then using
1.5/(average) as the scalar to protect against differing user settings!

Kind regards

James

__
PLEASE READ: This email is confidential and may be privileged. It is intended 
for the named addressee(s) only and access to it by anyone else is 
unauthorised. If you are not an addressee, any disclosure or copying of the 
contents of this email or any action taken (or not taken) in reliance on it is 
unauthorised and may be unlawful. If you have received this email in error, 
please notify the sender or postmas...@vernalis.com. Email is not a secure 
method of communication and the Company cannot accept responsibility for the 
accuracy or completeness of this message or any attachment(s). Please check 
this email for virus infection for which the Company accepts no responsibility. 
If verification of this email is sought then please request a hard copy. Unless 
otherwise stated, any views or opinions presented are solely those of the 
author and do not represent those of the Company.

The Vernalis Group of Companies
Oakdene Court
613 Reading Road
Winnersh, Berkshire
RG41 5UA.
Tel: +44 118 977 3133

To access trading company registration and address details, please go to the 
Vernalis website at www.vernalis.com and click on the Company address and 
registration details link at the bottom of the page..
__

--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss