landian666 发表于 2023-6-14 13:13 修改了一下脚本,可以成功导出每一个轨迹点的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." } |
lyj714 发表于 2023-6-14 10:38 proc showtrj {fps1 fps2 space selection output} { set selnow [atomselect top $selection frame $fps1] set selnext [atomselect top $selection frame $fps1] set num [$selnow num] set outfile [open $output w] for {set fps $fps1} {$fps < $fps2} {incr fps $space} { $selnow frame $fps $selnext frame [expr $fps + $space] $selnow update $selnext update puts $outfile "$num" puts $outfile "Frame $fps" for {set i 0} {$i < $num} {incr i 1} { set x [lindex [$selnext get x] $i] set y [lindex [$selnext get y] $i] set z [lindex [$selnext get z] $i] set atomname [lindex [$selnext get name] $i] draw line [lindex [$selnow get {x y z}] $i] [lindex [$selnext get {x y z}] $i] draw sphere [lindex [$selnext get {x y z}] $i] radius 0.12 puts $outfile "$atomname $x $y $z" } puts $outfile "" puts "Frame $fps done" } close $outfile } 修改了一下如上,现在的问题是 1、没有把每一个红色的轨迹点都输出,只输出了一部分。 2、没有输出轨迹红点间的连线。 3、没有输出原始的分子构型。 想请教一下还需如何修改可以解决上述三个问题,感谢!!! |
本帖最后由 lyj714 于 2023-6-14 10:41 编辑 landian666 发表于 2023-6-14 10:03
这就有问题啊,我前面都已经说了你不要出输出pdb,你这根本就是错误的pdb格式,根本没有按照标准的pdb格式输出,你为什么还要用。 |
lyj714 发表于 2023-6-13 23:12 是呀,自己尝试写了一个没搞定,如下,还请不吝赐教。多谢! proc showtrj {fps1 fps2 space selection output} { set selnow [atomselect top $selection frame $fps1] set selnext [atomselect top $selection frame $fps1] set num [$selnow num] set outfile [open $output w] for {set fps $fps1} {$fps < $fps2} {incr fps $space} { $selnow frame $fps $selnext frame [expr $fps + $space] $selnow update $selnext update puts $outfile "MODEL $fps" for {set i 0} {$i < $num} {incr i 1} { set x [lindex [$selnext get x] $i] set y [lindex [$selnext get y] $i] set z [lindex [$selnext get z] $i] set atomname [lindex [$selnext get name] $i] set resid [lindex [$selnext get resid] $i] set segname [lindex [$selnext get segname] $i] draw line [lindex [$selnow get {x y z}] $i] [lindex [$selnext get {x y z}] $i] draw sphere [lindex [$selnext get {x y z}] $i] radius 0.12 puts $outfile "ATOM $i $atomname $segname $resid $x $y $z 1.00 0.00" } puts $outfile "ENDMDL" puts "Frame $fps done" } close $outfile } |
|
本帖最后由 lyj714 于 2023-6-13 23:15 编辑 我记得你之前sob老师不是回复过你吗。直接输出成xyz格式,顶多改一下原子数目。不要自己puts成pdb格式,因为pdb格式的每一列和列宽是有严格定义的,如果你不了解输出的pdb格式就不对。 |
手机版 Mobile version|北京科音自然科学研究中心 Beijing Kein Research Center for Natural Sciences|京公网安备 11010502035419号|计算化学公社 — 北京科音旗下高水平计算化学交流论坛 ( 京ICP备14038949号-1 )|网站地图
GMT+8, 2026-2-25 21:09 , Processed in 0.171685 second(s), 25 queries , Gzip On.