简体   繁体   中英

Draw a colored sphere from cartesian coordinates in pymol

I was looking in the wiki how to convert the following information about beads, cartesian coordinates + energy :

23.4 54.6 12.3 -123.5 54.5 23.1 9.45 -56.7 .......

to a draw in pymol that contains for each atom a sphere of radius R, centered on its coordinates, and with color, in a rainbow gradient.

Thanks

Does what you're rendering actually have anything to do with molecular structure (ie what is the motivation for using PyMol)?

If you are drawing some molecular structure, I would recommend just outputting a custom PDB file with the sphere coordinates (you can use the B-factor field per ATOM line as a way of controlling per-atom coloring in PyMol).

If you are not drawing a molecular structure, you would be best off using the CGO interface of PyMol.

From the PyMol documentation:

CGO spheres are generated by the SPHERE command.

SPHERE, x,y,z,d

where x,y,z are the coordinates of the sphere centre and d is the diameter of the sphere. Note how a COLOR command is used to set the colour of a sphere. As with LINES you only need a COLOR command when the colour of the next sphere to be drawn changes.

A simple example:

from pymol.cgo import *
from pymol import cmd

spherelist = [
   COLOR,    0.100,    1.000,    0.000,
   SPHERE,   30.304,   30.407,   30.531,0.30,
   COLOR,    1.000,    0.000,    0.000,
   SPHERE,   30.250,   30.250,   30.250,0.20,
    ]

cmd.load_cgo(spherelist, 'segment',   1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM