计算化学公社

标题: 小脚本-vmd画虚线 [打印本页]

作者
Author:
Eming    时间: 2015-9-1 22:56
标题: 小脚本-vmd画虚线
本帖最后由 Eming 于 2023-12-15 21:36 编辑

#2023.12.15
      看有人回复说这是快10年的帖子了。想想确实也差不多了,在自己博士和博士后期间虽然都是只做生化实验,但对计算的热情从来没有降低过,尽管都是类似的小脚本,小程序。
工作以来一直将精力放在了药物虚拟筛选和分子对接方法的研究上了,watvina程序自2021年12月开放以来,也已有2年的时间了,与当下红红火火的人工智能相比,watvina依然是基于经验的分子对接,到不是说一定要跟人工智能比什么,而是想知道自己的经验的天花板能到什么程度。
      vmd画虚线一直是一个用户需求,就像在vmd中显示共价键的键级一样,但这种开发就没有对用户认真负责过,也没有照顾过老用户。又一个十年过去了,未来十年可能还是这个样子,我相信解决这些需求的,最终都是用户。这就跟我开发watvina一样,我一开始只是一个分子对接软件的用户而已,我的目的是想用一个好用的分子对接(并不要求非常非常准确),但一定要灵活好用可控,但是等了一个十年,没有等到。最后自己下手了,于是出现了watvina
      十年之前,我也没想到会走这么条路,等到中年,周围无论是炒房的,还是炒paper的,或者是跟着大趋势炒其他行业如AI的,都已经脱离了底层生活。
      十年之后,将年过50,回首半生已过,所剩者是何物,我也想留一点有用的给人间。就像这一个小小的帖子,十年里依然有人陆续在用,或许真的有一点点用。我常常在怀疑,类似FreeBSD是如何撑过几个十年的,而且一直在前进,虽然很慢,虽然用户很少,这到底是因为什么。

      脚本内容,下载附件吧。根据回复建议,draw_hbonds.tcl脚本中添加了 molid的参数。
有了这个脚本你可以随便改键的形态了,可以嵌套在其他的脚本里,例如画氢键我们有时候只是希望画重原子之间的氢键,而把H隐藏掉,以便于简便观察,大家可以试试下面的这个例子
加载附件中的脚本,并且看看如何使用。
###################
# draw_hbonds.tcl #
###################
proc draw_hbonds {molid cutoff angle sel1text sel2text color} {
  set a [atomselect $molid $sel1text]
  set b [atomselect $molid $sel2text]
  #set coords [[atomselect $molid all] get {x y z}]
   
  # get hbonds with 1 as donor and 2 as acceptor
  foreach { d1 a1 h1 } [measure hbonds $cutoff $angle $a $b] break
  # get hbonds wiith 2 as donor and 1 as acceptor
  foreach { d2 a2 h2 } [measure hbonds $cutoff $angle $b $a] break
  # combine the lists
  set dhh [concat $d1 $d2]
  set hyd [concat $h1 $h2]
  set acc [concat $a1 $a2]
  # draw them!
  foreach di $hyd ai $acc {
    #调用draw_bond函数
    draw_bond -mol1 $molid -index1 $di -mol2 $molid -index2 $ai -h_nbars 7 -h_space 1 -h_arrow 0 -h_radius 0.1 -color $color -h_type cylinder
  }
}
#  draw_hbonds top 3.0 45 {chain A} {chain B} yellow


附件如下:
(, 下载次数 Times of downloads: 610)


####################
#Usage example:
#draw_bond -mol1 0 -index1 1 -mol2 1 -index2 1 -h_nbars 25 -h_space 1 -h_arrow 0 -h_radius 0.1 -color yellow -mat Opaque -h_type cylinder -h_resol 25
#--->options:
# -mol1 0; the first molecule id (the default value is top)
# -index1 200; the first atom index number in mol1
# -mol2 0; the molecular id of the second atom
# -index2; the second atom index number in mol2
# -h_nbars 25; number of bars
# -h_space 1; space between bars
# -h_arrow 0; draw arrows on the two sides of the bond or not
# -h_radius 0.1; the bond radius
# -color yellow; the bond color
# -mat Opaque; material for rendering
# -h_type cylinder; supporting sphere, cylinder, pymol, cone, line
# -h_reol 25; bond resolution

##################
#使用调用函数如下
#source draw_bond.tcl
#以下是调用draw_bond函数的draw_hbonds函数调用
#source draw_hbonds.tcl
#draw_hbonds top 3.0 45 {chain A} {chain B} yellow






作者
Author:
sobereva    时间: 2015-9-1 23:02
试了下,挺好用
作者
Author:
Eming    时间: 2015-9-1 23:11
本帖最后由 Eming 于 2015-9-1 23:21 编辑
sobereva 发表于 2015-9-1 23:02
试了下,挺好用

斑竹/社长 速度真快,我还没有编辑完帖子你就加分了
作者
Author:
ksharpstar    时间: 2015-11-10 01:40
学习一下,之前只是用dashed画。
作者
Author:
diaok    时间: 2016-6-20 14:59
感谢分享

然后补充说明下氢键的那个脚本
draw_bond -mol1 0 -index1 $di -mol2 0 -index2 $ai -h_nbars 7 -h_space 1 -h_arrow 0 -h_radius 0.15 -color yellow -h_type cylinder
这里的-mol1  0  -mol2 0
最好改成top,最开始尝试了下,结果在半空中画线,想半天才弄明白
作者
Author:
Eming    时间: 2016-6-20 15:58
diaok 发表于 2016-6-20 14:59
感谢分享

然后补充说明下氢键的那个脚本

如果你的molecule是的id是top的(无论是0,1还是10等)自然可以改,如果不是,还是用数字表示id比较现实啊。
作者
Author:
Eming    时间: 2019-2-12 09:06
diaok 发表于 2016-6-20 14:59
感谢分享

然后补充说明下氢键的那个脚本

已经修改脚本,谢谢建议
作者
Author:
wgg1181543722    时间: 2020-12-30 23:12
不小心画错了 draw_bond  -index1 1  -index2 3  怎么取消呢?楼主
作者
Author:
skdmax    时间: 2020-12-31 10:25
能在一个分子的不同原子之间画虚线吗?
作者
Author:
Eming    时间: 2021-2-24 10:35
skdmax 发表于 2020-12-31 10:25
能在一个分子的不同原子之间画虚线吗?

完全可以,-mol1和-mol2就是用来指定哪两个分子的
作者
Author:
nianbin    时间: 2021-3-1 03:31
请问下这个脚本应该如何使用,能不能出个教程啥的,多谢。
作者
Author:
jluZ    时间: 2021-3-5 15:47
wgg1181543722 发表于 2020-12-30 23:12
不小心画错了 draw_bond  -index1 1  -index2 3  怎么取消呢?楼主

draw delete all
作者
Author:
星斗如盘    时间: 2021-4-30 11:10
没有看到使用方法呀?
作者
Author:
snljty    时间: 2021-4-30 11:33
星斗如盘 发表于 2021-4-30 11:10
没有看到使用方法呀?

那么大的“Usage example:”
作者
Author:
Qingming    时间: 2023-12-1 21:55
究竟怎么用啊,有没有详细点的教程,输入参数好不明确,不知道该怎么输
作者
Author:
Eming    时间: 2023-12-4 11:33
Qingming 发表于 2023-12-1 21:55
究竟怎么用啊,有没有详细点的教程,输入参数好不明确,不知道该怎么输

#Usage example:
#draw_bond -mol1 0 -index1 1 -mol2 1 -index2 1 -h_nbars 25 -h_space 1 -h_arrow 0 -h_radius 0.1 -color yellow -mat Opaque -h_type cylinder -h_resol 25
#--->以下是选项介绍:
# -mol1 0; 第一个原子所在分子的ID
# -index1 200; 第一个原子的index号
# -mol2 0; 第二个原子所在分子的ID
# -index2; 第二个原子的index号
# -h_nbars 25; 虚线的段数
# -h_space 1; 虚线的空隙大小
# -h_arrow 0; 虚线两端要不要画个箭头啊
# -h_radius 0.1; 虚线的粗细
# -color yellow; 虚线的颜色
# -mat Opaque; 虚线的材质
# -h_type cylinder; 虚线的风格,支持sphere, cylinder, pymol, cone, line几种风格,
# -h_reol 25; 虚线的分辨率,平滑度
作者
Author:
Qingming    时间: 2023-12-4 14:11
Eming 发表于 2023-12-4 11:33
#Usage example:
#draw_bond -mol1 0 -index1 1 -mol2 1 -index2 1 -h_nbars 25 -h_space 1 -h_arrow 0  ...

哇,谢谢楼主,差不多十年的帖子了,感谢
作者
Author:
fitterluo    时间: 2024-4-7 21:35
请问这是什么原因呢
作者
Author:
Eming    时间: 2024-4-9 14:01
本帖最后由 Eming 于 2024-4-9 14:04 编辑
fitterluo 发表于 2024-4-7 21:35
请问这是什么原因呢

没有加载脚本吧,source draw_bond.tcl
作者
Author:
TwilyAbyss    时间: 2024-5-13 11:58
楼主您好!可以将虚线的起点设置为某分子片段的中心吗?比如二茂铁中Cp环的中心,谢谢!
作者
Author:
Xstar    时间: 2025-7-8 21:35
Qingming 发表于 2023-12-1 21:55
究竟怎么用啊,有没有详细点的教程,输入参数好不明确,不知道该怎么输

请问您会用了嘛




欢迎光临 计算化学公社 (http://bbs.keinsci.com/) Powered by Discuz! X3.3