0
votes

I have a trajectory contains 75 frames (*.dcd file). But when I try to calculate the number of frames by the tcl commands:

set id [molinfo top get id ]
puts [molinfo $id get numframes]

I get much lower number, namely 3.

so how can I get the correct number of frames?

P.S.: I know that I can use VMD for this purpose, but the trajectory file is on a remote computer, and I need to run several calculation, like RMSD, that depends on the frames number through a code(without graphical interface).

1
What piece of software provides molinfo? It's not a generic Tcl command. (I want to tag the question correctly. :))Donal Fellows
Actually I am trying to use tcl scripts for VMD program. However, I pasted the definition below of the molinfo directly from the associated website; more infos.. The definition: "The molinfo command is used to get information about a molecule (or loaded file) including the number of loaded atoms, the filename, the graphics selections, and the viewing matrices. It can also be used to return information about the list of loaded molecules."user2804070
Thanks. I've created the vmd tag for you. (No idea what the answer is.)Donal Fellows
ok, thank you too :)user2804070
Your code looks correct. Have you double-checked that the dcd file contains really 75 frames and it is correctly read by VMD?Giannis

1 Answers

1
votes

This is an old question, but I found the solution and hope it helps someone else.

The problem: VMD doesn't (blocking) load all frames by default

When not all frames are loaded, I have encountered your problem of VMD only appearing to have a few frames. From the VMD focumentation, emphasis mine:

mol addfile waitfor: ... how many frames to load before returning; the default is 1 ... [additional] frames will be loaded in the background ... If frames is -1 or all, then all frames in all files still in progress will be loaded at once before the command returns ...

So, by default, we would only expect to load one frame, unless we specify waitfor . If there are more frames (e.g. 3/75 loaded), it is because VMD has loaded more in the background.

The solution: use waitfor when loading

In particular, when loading, I recommend doing the following:

set id [mol new "example.psf"]
mol addfile "example.dcd" waitfor all molid $id;
set n_frames [molinfo $id get numframes]
puts "There are $n_frames frames"

The critical part is the following line:

mol addfile "example.dcd" waitfor all molid $id;

where the 'waitfor' flag is used, as described above.