我在 VMD(视觉分子动力学)中使用 tk 控制台运行代码。我遇到的第一个问题是代码占用了我的计算机过多的处理能力并导致 VMD 关闭。我认为这是因为我让它将每个结果都打印到文件中。我真的只需要查看距离小于 20 的结果。下面是导致 VMD 关闭的原始代码:
set seg1 [atomselect top "segname LA0 and name CA"]
set seg2 [atomselect top "segname RA0 and name CA"]
set file [open "Contact_map27.dat" w]
set list1 [$seg1 get index]
set list2 [$seg2 get index]
foreach atom1 $list1 {
foreach atom2 $list2 {
set index1 [atomselect top "index $atom1"]
set index2 [atomselect top "index $atom2"]
set resid1 [[atomselect top "index $atom1"] get resid]
set resid2 [[atomselect top "index $atom2"] get resid]
set resnm1 [[atomselect top "index $atom1"] get resname]
set resnm2 [[atomselect top "index $atom2"] get resname]
puts $file "$resnm1 $resid1 $resnm2 $resid2 [veclength [vecsub [measure center $index1] [measure center $index2]]]"
$index1 delete
$index2 delete
}
}
close $file
以下是我所做的修改,仅在距离小于 20 时才打印值:
set seg1 [atomselect top "segname LA0 and name CA"]
set seg2 [atomselect top "segname RA0 and name CA"]
set file [open "Contact_map27.dat" w]
set list1 [$seg1 get index]
set list2 [$seg2 get index]
foreach atom1 $list1 {
foreach atom2 $list2 {
set index1 [atomselect top "index $atom1"]
set index2 [atomselect top "index $atom2"]
set resid1 [[atomselect top "index $atom1"] get resid]
set resid2 [[atomselect top "index $atom2"] get resid]
set resnm1 [[atomselect top "index $atom1"] get resname]
set resnm2 [[atomselect top "index $atom2"] get resname]
set dist [[veclength [vecsub [measure center $index1] [measure center $index2]]]]
if {$dist < 20} {
puts $file "$resnm1 $resid1 $resnm2 $resid2 $dist"}
else {puts $file " "}
$index1 delete
$index2 delete
}
}
close $file
运行第二个代码时收到的错误消息是“无效的命令名称”26.774817104116487“”
如果有人能给我第二双眼睛,让我知道发生了什么,我将不胜感激!提前致谢!