I have a slightly different answer using (almost:) only PyMOL commands:

# take 1acb as example
fetch 1acb, async=0
import numpy
# center is [x0,y0,z0]
x0,y0,z0=[1,2,3]
alldist = []
iterate_state 1,  1acb, alldist.append(numpy.sqrt(numpy.sum([(x-x0)**2,(y-y0)**2,(z-z0)**2])))
# assign dist to b-factors!
di = iter(alldist)
alter 1acb, b=di.next()
spectrum b, rainbow, 1acb

The distance computation line is awkward. I thought of using distance() command to replace it. It is also much faster to use distance(). But I failed to dig distance values out of the object generated by distance(). Anybody knows how to do that?

cheers,hongbo

On 28.07.2011 5:06, Thomas Holder wrote:
Hi Robert,

you can set the distance between each atom and the center as b-factor, and then use spectrum (or spectrumany [1]) for coloring.

I wrote a small python script that will do that, see attachment.

Example (in PyMOL command line):

run distancecoloring.py
centerdistance2b (all)
spectrum b, blue_white_red, (all)

Cheers,
Thomas

[1] http://pymolwiki.org/index.php/Spectrumany

On 07/28/2011 04:29 PM, Muench, Robert wrote:
Dear community,

I was searching the internet for several days now to find out how to
perform a distance dependent coloring in pymol.

The idea is to color the surface of a viral (spherical) structure. I
would like to define the xyz-coordinates of the center of the viral
structure an color all residues with a gradient depending on the
distance from these xyz coordinates.

All the best

Robert

*Robert Münch***

---------------------------------------------------------

Dipl. Biologist / PhD-Student

*Paul-Ehrlich-Institut*

Federal Institute for Vaccines and Biomedicines

Division of Medical Biotechnology

Section 6/5 - Viral Gene Transfer Medicinal Products

63225 Langen, Germany

Phone: +49-6103-77-4222

Fax: +49-6103-77-1255

```
------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win \$100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey```
```
_______________________________________________
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```