|
|
修改了一下脚本,可以成功导出每一个轨迹点的xyz格式的文件,方便作图和测量,供大家参考。
用法为:showtrj 0 1001 10 "resname LIG and name O1" "/path/1.xyz”
可以导出LIG上O1所有的轨迹点。
proc showtrj {fps1 fps2 space selection output} {
set selnow [atomselect top $selection frame $fps1]
set num [$selnow num]
set outfile [open $output w]
puts $outfile [expr {$num *(int(($fps2 - $fps1) / $space) + 1)}]
puts $outfile "Merged Frame"
for {set i 0} {$i < $num} {incr i 1} {
set x [lindex [$selnow get x] $i]
set y [lindex [$selnow get y] $i]
set z [lindex [$selnow get z] $i]
set atomname [lindex [$selnow get name] $i]
puts $outfile "$atomname $x $y $z"
}
for {set fps [expr $fps1 + $space]} {$fps < $fps2} {incr fps $space} {
$selnow frame $fps
$selnow update
for {set i 0} {$i < $num} {incr i 1} {
set x [lindex [$selnow get x] $i]
set y [lindex [$selnow get y] $i]
set z [lindex [$selnow get z] $i]
set atomname [lindex [$selnow get name] $i]
puts $outfile "$atomname $x $y $z"
}
}
close $outfile
puts "Merged frame generated."
} |
|