From: Vermaas, Joshua (
Date: Tue Oct 31 2017 - 18:03:12 CDT

Hi Steve,

Tcl can be a messy beast. :) In terms of loading every single pdb in a directory, that is fairly simple:

set pdblist [glob *.pdb]
foreach pdb $pdblist {
mol new $pdb

Now you want to make some sort of measurement afterward. This also isn't *too* bad, but it really depends on what exactly you want to be measuring, why, and what kind of data format you want to get out. The simplest way might be something like this:

set allsel [atomselect top "protein"]
set residuelist [lsort -unique -integer [$allsel get residue]]

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

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

This will measure the distance between any pair of protein residues in the top molecule, while only making a relatively small number of atomselections. Things a beginning VMDer should definitely read are the userguide (, particularly the sections about Tcl/Tk scripting, and the available vector and matrix commands. Additionally, useful tcl commands to know/read up on are things like glob, expr, and the list-related commands. I often will refer back to

Happy coding!

-Josh Vermaas

On 10/31/2017 04:17 PM, Windle,Stephen wrote:

VMD Users,

Good afternoon. I am very new to the VMD software, and I am working on putting together a script for a specific purpose, but I am unsure how much of it can be done as a single script. Essentially, I want to measure the distances between all the side chains of a specific amino acid in a given protein (for example distances between all the valine side chains). However, I want to be able to load anywhere from 1000-10,000 molecules into VMD and have the script do this for each molecule consecutively, exporting them into individual files (I should be able to write a loop for this, I imagine). So far I'm able to load a molecule and isolate the side chains of a specific amino acid. So my two key questions are this: Can a loop be written to load every .pdb file in a given folder, and what are the console commands to measure the distance between each side chain once they've been isolated into a named selection. I have tried searching through the indexed messages but to no avail. If someone could point me in the right
 direction that would be greatly appreciated. Thank you!


Steve Windle