From: Abhishek Bagusetty (
Date: Sat Oct 24 2015 - 14:19:36 CDT


I am trying to wrap coordinates (of all frames) in a xyz file using PBC
tools along with writing the wrapped coordinates of all frames to a new xyz
file. There are about 200,000 frames with 53 atoms. I have written a simple
script that loads the unwrapped frames, sets the PBC. Within the loop, I am
getting an error : atomsel: frame 1 out of range for molecule 15. This
error comes while performing writexyz. There is a also an outfile produced
with just a frame 0 wrapped coordinates. I am not quote sure how to fix

The code snippet is given below :

package require pbctools
display projection Orthographic
mol new
set sel [atomselect top all]
pbc set {9.856 7.392 20.000 90.0 90.0 120.0} -all
pbc box_draw
set num_frames [molinfo top get numframes]
for { set i 0 } { $i <= $num_frames } { incr i } {
    set frame $i
    pbc wrap
    set sel1 [atomselect top all frame $i]
    $sel1 writexyz
    $sel1 delete
    $sel delete

I have recently started with TCL scripting and any help regarding this
would be helpful.


Abhishek Bagusetty
PhD Student, Computational Modeling & Simulation
Center for Simulation and Modeling
Department of Chemical & Petroleum Engineering
University of Pittsburgh
Pittsburgh, PA - 15261
Office : 920 Benedum Hall
Email :