From: Leonardo G. Trabuco (ltrabuco_at_ks.uiuc.edu)
Date: Wed Jun 07 2006 - 22:14:41 CDT

On Wed, Jun 07, 2006 at 07:33:39PM -0700, Brian Kidd wrote:
> Hello,
>
> I was wondering if there is a way to change the color of two atoms in a
> protein during a trajectory based on their distance? For example, I'd
> like to visualize when two atoms - or any two selections for that
> matter - get within a certain distance of each other during a protein.
> I'm not exactly sure how to embed a case statement into the
> visualization of a trajectory such that the colorID changes. Any help
> is greatly appreciated.

You can write a TCL script that loops over all your frames and set the
user field of the atoms to a certain value, according to the distance.
Something like:

set molid [molinfo top]
set nframes [molinfo $molid get numframes]

set sel1 [atomselect $molid "index 1"]
set sel2 [atomselect $molid "index 2"]

for { set frame 0 } { $frame < $nframes } { incr frame } {
   $sel1 frame $frame
   $sel2 frame $frame

   # assume you calculate the distance between the two selections and
   # put it in the $dist
   
   $sel1 set user $dist
   $sel2 set user $dist
}

$sel1 delete
$sel2 delete

Then, you only have to color your selection by User.

Best,
Leo

-- 
Leonardo Giantini Trabuco
Ph.D. candidate
Center for Biophysics and Computational Biology
University of Illinois at Urbana-Champaign