From: John Stone (johns_at_ks.uiuc.edu)
Date: Tue Apr 10 2012 - 14:15:07 CDT

Hi,
  If you have it print the number of frames when it starts, do you get
the same count as you are getting in the file? If you are running a script
that loads files and immediately processes them, you will need to ensure that
you use the "waitfor all" flags at the end of your "mol new" and "mol addfile"
commands so that your analysis script won't run until after the file loading
is complete. Checking the frame count right before your analysis script runs
is an easy way to determine if the problem is that the frames hadn't completed
loading, or if there's something causing the script to skip frames or terminate
without processing all of the frames. Do you get any warnings are errors in
the VMD text console when your script runs?

Cheers,
  John Stone
  vmd_at_ks.uiuc.edu

On Tue, Apr 10, 2012 at 11:43:10AM -0500, Andrés Morales wrote:
> Dear VMD users:
> I want to calculate the average angle between the lipid dipole vector (P-N
> dipole vectors in DPPC headgroups ) and the bilayer normal for each frame.
> So I use the following script:
> proc angle_ave {sel_1 sel_2 frame} {
>
> global M_PI
> set conv [expr 180.0/$M_PI]
> set num1 [$sel_1 num]
> set sum 0
> set mol1 [$sel_1 molindex]
> set mol2 [$sel_2 molindex]
> set sel1 [atomselect $mol1 [$sel_1 text] frame $frame]
> set sel2 [atomselect $mol2 [$sel_2 text] frame $frame]
> foreach atom1 [$sel1 get index] atom2 [$sel2 get index] {
> set pos1 [lindex [[atomselect top "index $atom1"] get {x y z}] 0]
> set pos2 [lindex [[atomselect top "index $atom2"] get {x y z}] 0]
> set v [vecsub $pos2 $pos1]
> set z1 [lindex $v 2]
> set theta [expr $conv * asin($z1 / [veclength $v] )]
> set tilt [expr 90 - $theta ]
> set sum [expr $sum + $tilt]
> }
> set prom [expr $sum / $num1]
> return $prom
> }
> set outfile [open tilt angles.txt w];
>
> puts $outfile "Frame Average tilt angle"
> set dppc [mol load psf final.psf dcd final.dcd]
> set nf [molinfo top get numframes]
> set sel1 [atomselect $dppc "lipids and resid 1 to 36 and name P " ]
> set sel2 [atomselect $dppc "lipids and resid 1 to 36 and name N " ]
> for {set i 0 } {$i < $nf } { incr i } {
> $sel1 update
> $sel2 update
> set average [angle_ave $sel1 $sel2 $i]
> puts $outfile "$i $average"
> }
> close $outfile
> It calculates the average angle quite fine, but it only do it for the
> first frame. The output looks like:
> Frame Average tilt angle
> 0 72.3545824395983
> 1 72.3545824395983
> 2 72.3545824395983
> ... ....
> Any suggestions?
> Thanks a lot.
> Hernan Andres Morales Navarrete
>
> Biophysics and Molecular Modeling Group
> Physics Department
> Escuela Politecnica Nacional, Quito - Ecuador
> Ladron de Guevara E11-253.
> Casilla 17-01-1253
> http://www.ciencias.epn.edu.ec/~biomod/

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
http://www.ks.uiuc.edu/~johns/           Phone: 217-244-3349
http://www.ks.uiuc.edu/Research/vmd/       Fax: 217-244-6078