From: Windle,Stephen (
Date: Fri Dec 15 2017 - 16:39:25 CST

Good evening.

I am running a script to output distances on selected molecules to a specific file. I was trying to get it to loop between all the files loaded, but my loops don't seem to be working. What I want it to do is to run this script, but inside a loop that moves onto the next loaded .pdb file, and do the same, but output it to the end of the .dat file, so that it will cycle through however many files I have loaded and just add them to the end, making one really long file. The script is below (this is what it looks like before I started trying to add a for loop to have it run through the loaded files):

set allsel [atomselect top "sidechain and resname ALA"]
set residuelist [lsort -unique -integer [$allsel get residue]]

set ressellist [list ]
foreach residue $residuelist {
lappend ressellist [atomselect top "residue $residue"]

set file [open "myoutput.dat" w]

for { set i 0 } { $i < [llength $ressellist] } { incr i } {
for { set j [expr {$i+1}] } { $j < [llength $ressellist] } { incr j } {
puts $file "$i $j [veclength [vecsub [measure center [lindex $ressellist $i]] [measure center [lindex $ressellist $j]]]]"


close $file

..I am very new to the VMD environment, and haven't had luck looking through the manuals and readme files, so I'm not sure what I'm doing wrong. Thanks!