From: nordgren_at_sas.upenn.edu
Date: Mon Dec 20 2004 - 18:23:07 CST

Hi folks,

I'm having a little trouble that I wondered if anyone else has seen
before... I didn't turn up any previous posts on this subject...

So, I've been analyzing a NAMD trajectory for a protein simulation,
and trying to extract the phi & psi backbone torsional angles for
each residue. Here is a snippet of my VMD (Tcl) code... (This
loop is nested within another loop, over the various identical
protein structures in my system, and that within yet another loop,
over the frames of the input trajectory.)

   # inner loop: compute the local phi and psi angles
   for {set r_num $resid_min} {$r_num <= $resid_max} {incr r_num} {
      set index [lindex $helix_atoms($h_num) $r_num]
      set now_atom [atomselect top "index $index" frame $frame]
      set now_phi [$now_atom get phi]
      set now_psi [$now_atom get psi]
      # the next line is just for debugging purposes
      puts "residue=$r_num ; index=$index ; phi/psi = $now_phi $now_psi"
      set phi($r_num) [expr {$phi($r_num) + $now_phi}]
      set psi($r_num) [expr {$psi($r_num) + $now_psi}]
      # clear atom selection from memory
      $now_atom delete
   }

Now, most of the time this works fine (and gives physically reasonable
results) but every now and then (repeatably, but only for certain
trajectories from certain MD runs) this code crashes, because the
"get phi" command for a particular atom selection returns a non-numeric
value of "nan0x000002000000"

My inspection of the residue in question leads to the hypothesis that
the "NaN" is turning up due to a torsional angle of 180.0 degrees,
along with some related bug in the phi/psi computation.

So, here are my questions:
1) Is this in fact a bug in VMD? Anyone see this before? If so, is
there a fix?
2) If there is no quick fix, can someone recommend a good Tcl trick
to recognize the "number-ness" of a value, so I can avoid crashing my
algorithm, by screening for NaN's before trying to do arithmetic on them?

Thanks much,
Erik

C. Erik Nordgren, Ph.D.
Department of Chemistry
University of Pennsylvania