从 pymol 中的笛卡尔坐标绘制彩色球体

发布于 2024-08-17 23:15:08 字数 174 浏览 3 评论 0 原文

我在 wiki 中查找如何将以下有关珠子、笛卡尔坐标 + 能量的信息转换为:

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

到 pymol 中的绘图,其中每个原子包含一个球体半径 R,以其坐标为中心,并带有彩虹渐变的颜色。

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

聚集的泪 2024-08-24 23:15:08

您所渲染的内容实际上与分子结构有关吗(即使用 PyMol 的动机是什么)?

如果您正在绘制一些分子结构,我建议仅输出带有球体坐标的自定义 PDB 文件(您可以使用每个 ATOM 线的 B 因子字段作为控制 PyMol 中每个原子着色的方法)。

如果您不绘制分子结构,那么最好使用 PyMol 的 CGO 界面。

来自 PyMol 文档:

CGO 球体由
SPHERE 命令。

球体,x,y,z,d

其中 x,y,z 是坐标
球心,d 是直径
球体。注意 COLOR 命令如何
用于设置球体的颜色。
与线条一样,您只需要一种颜色
命令当下一个颜色
要绘制的球体发生变化。

一个简单的例子:

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)

Does what you're rendering actually have anything to do with molecular structure (i.e. 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)
山有枢 2024-08-24 23:15:08

我没有得到彩虹渐变位,但关于上面/下面的代码,我必须将其更改为:

import pymol

from pymol.cgo import *

from pymol import (
                    
                    cmd ,
                    )


print('########## PYMOL VERSION ##########################################')
print('         ',  cmd.get_version() )
print('###################################################################')


pymol.finish_launching()

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],
    ]

for i in spherelist:
    
    a = str(spherelist.index(i))

    cmd.load_cgo(i, 'sphere_'+a )

在 Pymol 版本中根据输出:

########## PYMOL VERSION ##########################################
          ('2.3.0',


具有像 spheres_0 和 spheres_1 这样的单对象code> 对象看起来像:

必须研究代码才能找出 wiki 中缺少的 load_cgo 中的第三个参数:加载 CGO PyMOLWiki ,但也许 zoom 可以在很多命令中传递,我猜:

cmd.load_cgo(obj , cgo_name , Zoom=0)

I am not getting the rainbow gradient bit, but concerning the code above/below I had to change it as :

import pymol

from pymol.cgo import *

from pymol import (
                    
                    cmd ,
                    )


print('########## PYMOL VERSION ##########################################')
print('         ',  cmd.get_version() )
print('###################################################################')


pymol.finish_launching()

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],
    ]

for i in spherelist:
    
    a = str(spherelist.index(i))

    cmd.load_cgo(i, 'sphere_'+a )

in Pymol version as per output:

########## PYMOL VERSION ##########################################
          ('2.3.0',


to have singles objects like spheres_0 and spheres_1 objects looking like :

enter image description here .

Had to look into code to figure out the third argument in load_cgo missing from the wiki : Load CGO PyMOLWiki , but maybe the zoom can be passed along in a lot of commands I guess:

cmd.load_cgo(obj , cgo_name , zoom=0)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文