计算化学公社

标题: 求助:VMD脚本输出的原子坐标与设定的范围不一致 [打印本页]

作者
Author:
chieko    时间: 2023-11-23 18:16
标题: 求助:VMD脚本输出的原子坐标与设定的范围不一致
本帖最后由 chieko 于 2023-11-23 18:16 编辑

我对一个体系中的水(SOL)用VMD做氢键分析,我只需要measure给定范围内的水(z1-z2)形成的氢键,然后把所有氢键的供体的H原子和受体氧原子的坐标输出即可。
问题在于,输出的原子的z坐标与脚本中指定的不对应。例如下面希望水在(120,130)的z范围内,但是结果中z的范围基本上只在120-125左右。——当然我的体系中120-130部分肯定是有水的。
改变z1,z2,结果中z坐标范围也会变化至(z1,z1+5左右)的范围,很奇怪。脚本本身明明也很简单。。。
请Sob老师和大家帮我看看是怎么回事,谢谢!
脚本如下,输出文件见附件。
  1. set z1 120
  2. set z2 130
  3. set fps1 99000
  4. set fps2 100000
  5. set output "5nm_hbs_coord.txt"
  6. set outputFile [open $output "w"]

  7. for {set frame $fps1} {$frame <= $fps2} {incr frame} {
  8. animate goto $frame
  9. set selection [atomselect top "resname SOL and (z >= $z1) and (z <= $z2)"]
  10. set hbonds [measure hbonds 3.5 40 $selection]
  11. foreach hbond $hbonds {
  12.         set donor [lindex $hbond 0]
  13.         set hydrogen [lindex $bond 2]
  14.         set acceptor [lindex $hbond 1]

  15.         set h_coord [[atomselect top "index $hydrogen" frame $frame] get {x y z}]
  16.         set a_coord [[atomselect top "index $acceptor" frame $frame] get {x y z}]

  17.         set h_coord [lindex $h_coord 0]
  18.         set a_coord [lindex $a_coord 0]
  19. puts $outputFile "[format "%.3f %.3f %.3f %.3f %.3f %.3f" {*}$h_coord {*}$a_coord]"
  20.     }
  21.     $selection delete
  22. }
  23. close $outputFile
复制代码



作者
Author:
Loading0760    时间: 2023-11-24 12:07
会不会是第14行
        set hydrogen [lindex $bond 2]
这里的变量应该是$hbond。
不是很懂tcl,仅提出自己猜测。




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