Re: [PyMOL] How to measure the angle between two aromatic rings?

2010-09-27 Thread Ramiro Téllez Sanz
First of all, I would like to express my gratitude to both Tsjerk and Thomas. If only the rest of the world were like you!! The script works very well indeed. Thanks! I would like to make my own humble contribution, though, so that other people can benefit from the impressive work by Thomas and T

Re: [PyMOL] How to measure the angle between two aromatic rings?

2010-09-23 Thread Thomas Holder
On Thu, 2010-09-23 at 09:54 -0400, Jason Vertrees wrote: > Hi Ramiro, > > Another option is to fit (in a least-squares sense) a plane to each of > your rings and then calculate the angle between the fitted planes' > normals. that's what the recently posted ring_angle.py script does. Cheers, Th

Re: [PyMOL] How to measure the angle between two aromatic rings?

2010-09-23 Thread Jason Vertrees
Hi Ramiro, Another option is to fit (in a least-squares sense) a plane to each of your rings and then calculate the angle between the fitted planes' normals. This would help if your rings are not perfectly planar: it would spread the deviation among all atoms in the ring not just the ones you sel

Re: [PyMOL] How to measure the angle between two aromatic rings?

2010-09-23 Thread Thomas Holder
Hi Ramiro, > * How do I adjust the code with my selected rings? Do I need to include > both residues in the same selection in pymol, then rename the selection, > and then include the chosen selection name in the code where you write > "selection"? you need two selections of two residues, in my ex

Re: [PyMOL] How to measure the angle between two aromatic rings?

2010-09-23 Thread Tsjerk Wassenaar
Hi Thomas, You're right, and using an svd on the whole ring is also more correct. But the vector stuff is simple and handy to have lying around, and it serves also to give some insight in what's going on :) numpy.linalg.svd is magic if you don't know how a cross product or normalization works... S

Re: [PyMOL] How to measure the angle between two aromatic rings?

2010-09-23 Thread Ramiro Téllez Sanz
Thanks very much Thomas for your help. > no need to implement common linear algebra functions, there is the > chempy.cpv module shipped with pymol (and there is numpy as well). > > Ramiro, I recently did something similar, just adjust the residue > selection in the code below (requires numpy): >

Re: [PyMOL] How to measure the angle between two aromatic rings?

2010-09-23 Thread Thomas Holder
no need to implement common linear algebra functions, there is the chempy.cpv module shipped with pymol (and there is numpy as well). Ramiro, I recently did something similar, just adjust the residue selection in the code below (requires numpy): python from chempy import cpv import numpy, math de

Re: [PyMOL] How to measure the angle between two aromatic rings?

2010-09-23 Thread Tsjerk Wassenaar
Hi Ramiro, A bit of linear algebra wouldn't hurt... :p In python: def vsub(a,b): return a[0]-b[0], a[1]-b[1], a[2]-b[2] def dot(a,b): return a[0]*b[0]+a[1]*b[1]+a[2]*b[2] def svmul(s,a): return s*a[0], s*a[1], s*a[2] def normalize(a): return svmul(1/math.sqrt(dot(a,a)),a) def cross(a,b): retu

Re: [PyMOL] How to measure the angle between two aromatic rings?

2010-09-23 Thread Ramiro Téllez Sanz
Thanks for your kind help, Tsjerk. > Hi Ramiro, > > Assuming your rings are nicely planar, and representing the ring as: > > 1-2-3 > | | > 6-5-4 > > you can get the plane normal vector as the vector cross product from > (3)-(1) and (5)-(1). OK. But I just started to use pymol. Which are the

Re: [PyMOL] How to measure the angle between two aromatic rings?

2010-09-23 Thread Tsjerk Wassenaar
Hi Ramiro, Assuming your rings are nicely planar, and representing the ring as: 1-2-3 | | 6-5-4 you can get the plane normal vector as the vector cross product from (3)-(1) and (5)-(1). Doing so for both rings gives you the two normal vectors. The angle then follows from the dot product of t

[PyMOL] How to measure the angle between two aromatic rings?

2010-09-23 Thread Ramiro Téllez Sanz
Hi everyone and thanks for reading this! I am interested in measuring the angle between aromatic ring planes. Is there any easy way/script to do it? One way that came to my mind is creating a pseudoatom representing the centroid for each ring (I already know how to do that), then drawing two lin

[PyMOL] How to measure the angle between two aromatic rings?

2010-09-23 Thread Ramiro Téllez Sanz
Hi everyone and thanks for reading this! I am interested in measuring the angle between aromatic ring planes. Is there any easy way/script to do it? One way that came to my mind is creating a pseudoatom representing the centroid for each ring (I already know how to do that), then drawing two li