From: Eduard Schreiner (eduard.schreiner_at_rub.de)
Date: Wed Oct 04 2006 - 06:15:38 CDT

Hey Vlad,

to me it seems that it happens because you are writing
out the same list all the time (your label_number is always 0 in
label graph Bonds 0 test_${donor}_${acceptor}.out
).
One possibility is to delete the label at the end of the loop:

for {set frame 0} {${frame} < ${numframes}} {incr frame} {
.....
   foreach donor [lindex ${hbonds} 0] acceptor [lindex ${hbonds} 1] {
.......
      label add Bonds 0/${donor} 0/${acceptor}
      label graph Bonds 0 test_${donor}_${acceptor}.out
#####this one might help
label delete Bonds all
   }
}

Alternatively you could also provide the correct label_number.

You also should delete the selections you made as soon as they are not needed
anymore to prevent memory leaks:

 set datom [atomselect 0 "index ${donor}" frame ${frame}]
.....
.....
.....
$datom delete; unset datom

I hope it helps.

Eddi

On Tuesday 03 October 2006 21:49, Vlad Cojocaru wrote:
> 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
> }
> }
>
>

-- 
--
=============================================================================
Eduard Schreiner                     e-mail: eduard.schreiner_at_theochem.rub.de
Lehrstuhl fuer Theoretische Chemie          Phone: ++49 (0)234/32-22121
Ruhr-Universitaet Bochum - NC 03/52         Fax:   ++49 (0)234/32-14045
D-44780 Bochum                              http://www.theochem.rub.de
=============================================================================