I am trying to save a dcd file into a pdb file with VMD. I will be using this .tcl file for several dcd files with different numbers of frames, so I want to make a variable n_frames for the total number of frames, to write the pdb beginning at 0 and ending at n_frames. Please refer below to my efforts.
set id [mol new "file.psf"]
mol addfile "file.dcd" waitfor all molid $id;
set n_frames [molinfo $id get numframes]
puts "There are $n_frames frames"
animate write pdb file.pdb beg 0 end $n_frames skip 100 0
exit
This piece of code works fine if I change $n_frames from the second to last line for any number, for example 100. e.g. animate write pdb file.pdb beg 0 end 100 skip 100 0
works perfectly.
Is there a way I can pass a variable for the end number of frame to achieve this?
I appreciate any guidance. Thanks.