CA Distance Plot 2.0
--------------------

REQUIREMENTS: VMD Version 1.5 or newer 

DESCRIPTION:
	Given a selection, this script finds the CA atoms and constructs a
	matrix whose elements are the distances from the CA of residue(i) to
	that on residue(j).  A new graphics molecule is created with the name
	"CA_distance(molid)", where molid is the index of the molecule used
	by the selection.  The distance matrix is plotted by residue number
	in the order they appeared in the PDB (or PSF, ...) file, but only
	the selected residues are shown.  The colors are determined by the
	color scale and may be changed accordingly.

HOW IT WORKS:
         This example creates a distance matrix made of the distance
         between the CAs of two residues.  The only input value is selection
         used to find the CAs.  The distances are stored in the 2D array
         `dist', which is indexed by the atom indices of the CAs (remember,
         atom indices start at 0).

         The distance matrix is a new graphics molecule.  It consists
         of two triangles for each element of the matrix (to make up a square).
         The color for each pair is one of the 32 elements in the color scale
         and is determined so the range of distance values fits linearly
         between 34 and 66 (excluding 66 itself).  The name of the graphics is
         `CA_distance(n)' where `n' is the molecule id of the selection
         used to create the matrix.

         The first graphics command, ``materials off'' is to keep the
         lights from reflecting off the matrix (otherwise there is too much
         glare).  At the end, the corners of the matrix are labeled in yellow
         with the resid values of the CAs.

         One extra procedure, ``vecdist'', is used.  This computes
         the difference between two vectors of length 3.  It is not as general
         as the normal method (vecnorm [vecsub $v1 $v2]) but is almost
         twice as fast, which speeds up the overall subroutine by almost 10%.
         The script is not very fast; after all, for a 234 residue protein,
         27495 distance calculations are made and 54756*2 triangles generated.
         Nearly all of that is done in Tcl.  In terms of times, about 1/3 is
         spent in the distance calculations, another 1/3 in the math to make
         the triangles, and another 1/3 in the three `graphics' calls.  The
         residue 234 example protein took 70 seconds to do everything on an 
         SGI Crimson.

PROCEDURES:
	ca_dist selection -- makes a new graphics molecule which is
	                     the CA-CA distance plot of the given selection
	
EXAMPLE OUTPUT:
	image of bacteriorhodopsin with the CA-CA on the bottom


DOWNLOAD THE FILE:
	ca-dist.tcl
	

AUTHOR:
Andrew Dalke
Justin Gullingsrud
John Stone