From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Sun May 24 2009 - 19:52:41 CDT

On Thu, 2009-05-21 at 07:20 +0300, Thomas Evangelidis wrote:

tom,

sorry for taking so long to have a look at this.
but it is (obviously) not a trivial problem, and thus
cannot be checked within a few minutes.

> I would appreciate if someone could help me resolve my problem with
> bigdcd. The conventional bibdcd script yields errors (moves to the
> next frame too early) when doing long calculations for each frame like
> in my script, therefore had to adapt it a bit. The problem occurs
> whenever I load a new molecule with "mol new". I have enclosed my
> adapted version at the end of this message, with a simple RunMethod to
> comprehend what I'm talking about. The last time I received advice was
> from John whose message I quote below:
>
> Tom,
> If you are loading frames within the SaveFrame method, you'll need
> to temporarily disable the frame loading trace/callback, to prevent it
> from going into an infinite loop of sorts.

hmmm... i'm not quite certain whether this is the right answer.
i would rather declare a global variable bigdcd_mol set it to
the molid that you want to process upon reading and then
process the callback contents only when the second argument
is equal to $bigdcd_mol. whenever you load a new molecule
the callback is called as well, but it would then automatically
delete the freshly loaded frame in the _new_ molecule _and_
increment your bigdcd_frame variable whithout actually processing
a frame in the molecule you intend to process, or processing
a frame in the wrong molecule.

i would try this w/o the en-/disable and then see if there
are still problems.

cheers,
   axel.

>
> Cheers,
> John
>
> This doesn't help either (see lines 77 and 79). In fact only the first
> frame is saved although the trajectory seems to be loaded.
>
> For the first time in my career I must admit that I cannot fix this
> problem alone. This is not because I haven't spent enough time (in
> fact I've spent several weeks trying to figure out what's happening)
> but rather due to the changes in VMD source code which I'm unable to
> predict. My plugin, for which I have spent significant amount of
> effort, works normally in version 1.8.6 where it was developed. I
> would love to see it included in version 1.8.7 and meanwhile receive
> feedback from users to improve it.
>
> ~Tom
>
>
> set log_adapted [open "adapted.log" "w"]
> set itest 0
>
> proc adaptedBigdcd { script args } {
> global bigdcd_frame bigdcd_proc bigdcd_firstframe vmd_frame
>
>
> set ::bigdcd_is_done 0
>
> set bigdcd_frame 0
> set bigdcd_firstframe [molinfo top get numframes]
> set bigdcd_proc $script
>
> uplevel #0 trace variable vmd_frame w bigdcd_callback
> foreach dcd $args {
> animate read dcd $dcd waitfor 0
> }
> }
>
> proc bigdcd_callback { tracedvar mol op } {
> global bigdcd_frame bigdcd_proc bigdcd_firstframe vmd_frame
>
> # If we're out of frames, we're also done
> set thisframe $vmd_frame($mol)
> puts $::log_adapted "DEBUG: bigdcd_callback thisframe = $thisframe
> bigdcd_firstframe = $bigdcd_firstframe mol = $mol vmd_frame(mol) =
> $vmd_frame($mol)"
> if { $thisframe < $bigdcd_firstframe } {
> bigdcd_done
> return
> }
>
> incr bigdcd_frame
> if { [catch {uplevel #0 $bigdcd_proc $bigdcd_frame} msg] } {
> puts stderr "bigdcd aborting at frame $bigdcd_frame\n$msg"
> bigdcd_done
> return
> }
> animate delete beg $thisframe end $thisframe
> return $msg
> }
>
> proc bigdcd_done { } {
> set ::bigdcd_is_done 1
> puts "bigdcd_done"
> uplevel #0 trace vdelete vmd_frame w bigdcd_callback
> }
>
> proc bigdcd_disable { } {
> uplevel #0 trace vdelete vmd_frame w bigdcd_callback
> }
>
> proc bigdcd_enable { } {
> global vmd_frame
> uplevel #0 trace variable vmd_frame w bigdcd_callback
> }
>
> proc adaptedBigdcd_wait_till_done {} {
> while {! $::bigdcd_is_done} {
> puts "::bigdcd_is_done = $::bigdcd_is_done"
> display update
> }
> }
>
>
> proc SaveFrame { frm } {
> puts "frame = $frm"
> incr itest
> animate write pdb
> "/home/thomas/Documents/Molecular_Dynamics/wholeframe_$frm.pdb" beg 0
> end 0 waitfor all top
> bigdcd_disable
> mol new "/home/thomas/Documents/Molecular_Dynamics/wholeframe_$frm.pdb"
> bigdcd_enable
> }
>
> proc RunMethod {} {
> mol delete all
> mol load psf DCD_with_cell.psf
> adaptedBigdcd SaveFrame sample_DCD_with_cell.dcd
> adaptedBigdcd_wait_till_done
> }
>
> RunMethod

-- 
=======================================================================
Axel Kohlmeyer   akohlmey_at_cmm.chem.upenn.edu   http://www.cmm.upenn.edu
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
=======================================================================
If you make something idiot-proof, the universe creates a better idiot.