Hi David, Attached is a script I wrote for doing a similar thing in pymol. It sets the B value of an atom to be the distance of that atom from a specified point (optionally normalising the final values from 0-100). You can then either draw the molecule coloured by B in pymol, or export the coords for use in your favourite graphics package.
Usage is as follows (from inside pymol, assuming the script is in directory /path/to): run /path/to/distance_to_B.py distance_to_B( "all", [0,0,0] ) It would be fairly trivial to extend the code to measure the distance from a plane instead of from a point. Cheers, Stephen On 10/9/07, David Briggs <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I know that this has been discussed on the bb before now, but 20 pages of > google search in, I have still come up with zip. > > I want to vary b-factors smoothly from either point or a plane. This is for > pretty-picture purposes. > I can then colour molecule by b-factor and get nice, pretty effects. > > Thank you in advance for your assistance, > > David > > -- > ============================ > David C. Briggs PhD > Father & Crystallographer > http://personalpages.manchester.ac.uk/staff/David.C.Briggs/ > < BROKEN! > AIM ID: dbassophile > ============================ -- Dr Stephen Graham Nuffield Medical Fellow Division of Structural Biology Wellcome Trust Centre for Human Genetics Roosevelt Drive Oxford OX3 7BN United Kingdom Phone: +44 1865 287 549
from pymol import cmd from pymol import stored from math import * def distance_to_B( selection, origin, state=1, normalise=1 ): stored.xyz = [] cmd.iterate_state( state, selection, "stored.xyz.append([x,y,z])" ) x0, y0, z0 = origin[0], origin[1], origin[2] distances = [] for i in stored.xyz: x = i[0] y = i[1] z = i[2] distances.append( sqrt((x-x0)**2+(y-y0)**2+(z-z0)**2) ) sorted_dists = distances[:] sorted_dists.sort() min_dist = sorted_dists.pop(0) max_dist = sorted_dists.pop() range = max_dist - min_dist stored.b = [] for i in distances: if normalise == 1: stored.b.append( ((i - min_dist)/range)*100 ) else: stored.b.append( i ) cmd.alter( selection, "b=stored.b.pop(0)" ) cmd.extend( "distance_to_B", distance_to_B )
