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 example the part 'A/37/CG
+CD1+CE1+CZ+CE2+CD2' is the selection on chain A, residue 37 and ring
atoms.

> * How do I run the code after I adjust it with my "selection"? I have
> never run a python program from within pymol. What should I do?

I put the code (including Tsjerk's additions!) to a file, see attached.
You have to run it with pymol (File > Run...) and then call the
ring_angle command.

Example to get angle between aromatic residues 37 and 41 in chain A:
ring_angle chain A and resi 37, chain A and resi 41

Cheers,
  Thomas
from pymol import cmd, stored
from chempy import cpv
import numpy, math

def plane_normal(selection):
    stored.x = list()
    cmd.iterate_state(-1, selection, 'stored.x.append([x,y,z])')
    x = numpy.array(stored.x)
    U,s,Vh = numpy.linalg.svd(x - x.mean(0))
    return cpv.normalize(Vh[2])

def ring_angle(selection1, selection2, quiet=1):
    a = plane_normal(selection1 + " and not (e. h or n. c,n,ca,cb,o,oxt)")
    b = plane_normal(selection2 + " and not (e. h or n. c,n,ca,cb,o,oxt)")
    deg = math.degrees(cpv.get_angle(a, b))
    if not int(quiet):
        print 'Angle in degrees: %.2f' % (deg)
    return deg

cmd.extend("ring_angle",ring_angle)
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Reply via email to