From: Vlad Cojocaru (Vlad.Cojocaru_at_eml-r.villa-bosch.de)
Date: Tue Oct 03 2006 - 14:49:40 CDT

Dear VMD users,

With the script below I am trying to idetify all hydrogen bonds during a
MD trajectory (using specific selections) and then calculate the
distance between each donor and acceptor and output it in a file ready
for plotting. The problem with this script is that all file
"test_${donor}_${acceptor}.out" are the same and that is obviously
because of the integer "0" in line 22. However, I didnt find any way how
to get a list of label numbers such as to replace the "0" with the
different numbers of the different labels. Maybe a better way would be
to calculate the distance in a different way. I looked at sopmething
like "measure distance $donor $acceptor" ... but "measure" cannot do
that. Could somebody give me an advice how to make this script work?

Thanks

Best wishes
vlad

set outfile [open "test.out" w]
set numframes [molinfo 0 get numframes]
for {set frame 0} {${frame} < ${numframes}} {incr frame} {
   set sel1 [atomselect 0 {{name "N.*" "O.*" "S.*"} and {resname FLU}}
frame ${frame}]
   set sel2 [atomselect 0 {{name "N.*" "O.*" "S.*"} and {resid 1 to
467}} frame ${frame}]
   set hbonds [measure hbonds 3.2 60 ${sel2} ${sel1}]
   puts "Frame ${frame}: Hbonds: ${hbonds}"
   foreach donor [lindex ${hbonds} 0] acceptor [lindex ${hbonds} 1] {
      set datom [atomselect 0 "index ${donor}" frame ${frame}]
      set aatom [atomselect 0 "index ${acceptor}" frame ${frame}]
      set datomname [${datom} get name]
      set aatomname [${aatom} get name]
      set datomresid [${datom} get resid]
      set aatomresid [${aatom} get resid]
      set datomresname [${datom} get resname]
      set aatomresname [${aatom} get resname]
      puts "The donor has index ${donor}, name ${datomname}, belongs to
residue ${datomresname} ${datomresid}"
      puts "The acceptor has index ${acceptor}, name ${aatomname},
belongs to residue ${aatomresname} ${aatomresid}"
      puts ${outfile} "donor mask :${datomresid}@${datomname}"
      puts ${outfile} "acceptor mask :${aatomresid}@${aatomname}"
      label add Bonds 0/${donor} 0/${acceptor}
      label graph Bonds 0 test_${donor}_${acceptor}.out
   }
}

-- 
Dr. Vlad Cojocaru
EML Research gGmbH
Molecular and Cellular Modeling Group
Schloss-Wolfsbrunnenweg 33
69118 Heidelberg, Germany
Phone: +49-6221-533266
Fax: +49-6221-533298
e-mail: Vlad.Cojocaru_at_eml-r.villa-bosch.de
http://projects.villa-bosch.de/mcm/people/cojocaru/