gpt4 book ai didi

python - 如何显示 Pymol 中残基之间的距离

转载 作者:太空宇宙 更新时间:2023-11-03 16:26:29 26 4
gpt4 key购买 nike

this PDB file以及以下 PyMOL代码:

cd /Users/foo/Desktop/
reinitialize
load pdp_4gg6CD1_I.pdb
as cartoon
select chainI, chain I
select chainC, chain C
select chainD, chain D
show sticks, chainI
spectrum count, cyan_red, chainI
color yellow, chain C

我可以制作这个图像:

enter image description here

我想要做的是显示 chainC 中所选残基之间的距离(黄色)与 chainI(棒)。

我想要的chainC的选定残基是这样的:

[9, 23, 25, 44, 53, 54, 55, 59, 62, 63, 66]

Y Y H W R R F F T N V

我怎样才能做到这一点?

最佳答案

  • 让我们使用cmd.iterate来获取选择中的所有原子(链C和链I),并将坐标和原子名称写入字典以供以后使用。
  • 然后我们可以计算所有原子之间的所有距离,并将最接近的残基和原子名称写入两个列表(min_cmin_i)
  • 在最后一步中,我们只需绘制最近原子之间的距离对象即可完成:)
<小时/>
from math import sqrt

def closestAtoms(list1=[9, 23, 25, 44, 53, 54, 55, 59, 62, 63, 66], list2=[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]):
atoms = {}
atoms2 = {}

for r in list1:
command = "chain C and resi %s" % (r)
coordinates = {'atoms': []}
cmd.iterate_state(-1, command, 'atoms.append([x, y, z, name])', space=coordinates)
atoms[r] = coordinates['atoms']

for i in list2:
command = "chain I and resi %s" % (i)
coordinates = {'atoms': []}
cmd.iterate_state(-1, command, 'atoms.append([x, y, z, name])', space=coordinates)
atoms2[i] = coordinates['atoms']

for i in list2:
min_dist = 10**3
for c in list1:
for cc in atoms[c]:
for ii in atoms2[i]:
dist = sqrt((cc[0] - ii[0])**2 + (cc[1] - ii[1])**2 + (cc[2] - ii[2])**2)
if dist < min_dist:
min_dist = dist
min_c = [c, cc[3]]
min_i = [i, ii[3]]
cmd.distance('dist_%s_%s' % (min_c[0], min_i[0]), 'chain C and resi %s and name %s' % (min_c[0], min_c[1]), 'chain I and resi %s and name %s' % (min_i[0], min_i[1]))

cmd.extend("closestAtoms", closestAtoms)

关于python - 如何显示 Pymol 中残基之间的距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37942272/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com