From: Josh Vermaas (vermaas2_at_illinois.edu)
Date: Fri Jul 05 2013 - 13:37:32 CDT

Another suggestion to improve efficiency: Declare ref once, and change
the frame within the atomselection. May not be noticeably faster, but it
avoids issues that pop up with atomselections not being deleted when
nothing references them.

set numframes [molinfo 0 get numframes]
# Returns 1124 frames which is correct
# Loop over frames
set ref [atomselect 0 "resname CFN"]

for {set frame 0} {${frame} < ${numframes}} {incr frame} {
#Change the frame inside the loop
$ref frame $frame
set com_ref [measure center ${ref} weight mass]
puts $outfile "Frame $frame com $com_ref"

draw sphere $com_ref radius 0.5

}
close $outfile

-Josh Vermaas

On 07/05/2013 12:17 PM, Jérôme Hénin wrote:
> Hi,
>
> This could just be incomplete file I/O. Add a line saying "close $outfile" at the end to flush the buffer.
>
> Cheers,
> Jerome
>
>
> ----- Original Message -----
>> Hi,
>>
>> I am trying to make a script that will display the center of mass of
>> a
>> chosen residue in my simulation. I have run into some issues with the
>> tcl where I am not familiar with the syntax.
>>
>> My first issues is that I would like to loop over all the frame in my
>> simulation
>>
>> set numframes [molinfo 0 get numframes]
>> # Returns 1124 frames which is correct
>> # Loop over frames
>>
>> for {set frame 0} {${frame} < ${numframes}} {incr frame} {
>>
>> set ref [atomselect 0 "resname CFN" frame ${frame}]
>> set com_ref [measure center ${ref} weight mass]
>> puts $outfile "Frame $frame com $com_ref"
>>
>> draw sphere $com_ref radius 0.5
>>
>> }
>>
>> My problem is that it only outputs 1104 frames and not 1124 as I
>> would
>> expect it to do?
>>
>> Thanks
>>