From: Justin Gullingsrud (justinrocks_at_gmail.com)
Date: Thu Mar 03 2005 - 10:33:45 CST

Hi,

The problem is that the "bigdcd" command returns immediately, before
all the frames have been processed, and you then close the file. There
are two things you can do, one easy, one slightly more complex.

(1) Remove the "close" line, and instead call "flush $handle" after
each call to puts.
(2) Put the close command in a callback that gets triggered when the
file is complete:

trace variable vmd_trajectory_read w dcd_done
proc dcd_done { args } {
   global $handle
   close $handle
}

You would execute this code just before calling bigdcd.

Cheers,
Justin

On Mar 3, 2005, at 2:20 AM, Sascha Tayefeh wrote:

>
> Dear vmd-community,
>
> I have some difficulties adapting the analysis-script bigdcd.tcl
> provided at vmd's script_library:
>
> http://www.ks.uiuc.edu/Research/vmd/script_library/scripts/bigdcd
>
> Consider example 1 given in the script:
> --------------------
> proc mycenter { frame } {
> global all
> puts "$frame: [measure center $all weight mass]"
> }
> mol load psf alanin.psf
> set all [atomselect top all]
> $all global
> bigdcd mycenter alanin.dcd
> ---------------------
>
> I would like to write output to a file, so I tried this:
>
> --------------------
> # I want file to be opened *once*
> # rather than each time mycenter is called
> # so I open file from outside mycenter
>
> proc mycenter { frame } {
> global all
> global handle
> puts $handle "$frame: [measure center $all weight mass]"
> }
>
> mol load psf alanin.psf
> set handle [open test.dat w];
> set all [atomselect top all]
> $all global
> bigdcd mycenter alanin.dcd
> close $handle
> ---------------------
>
> which, under any circumstance, ends up with an exeption caught by
> bigdcd::bigdcd_callback that says:
>
> ---------------------
> bigdcd aborting at frame 1
> can not find channel named "file16"
> ---------------------
>
> I am not that familiar with tcl, hence, I am trying to find a
> solution for 2 days, reading tcl-tutorials, references, google,
> newsgroups and on and on -now, I give up.
>
> Any suggestions are *very* welcome!
>
> Sincerly
>
> --
>
> Sascha Tayefeh <sascha_at_pc.chemie.tu-darmstadt.de>
> Dipl.-Biol, PhD-Student
> http://www.pc.chemie.tu-darmstadt.de/staff/sascha/
>
> ---
> Technische Universitaet Darmstadt
> Physikalische Chemie I
> 64287 Darmstadt
> Germany
>
> ---
>
>

--
It is easier to make a theory of everything, than a theory of 
something. -- Aharon Katchalsky