From: John Stone (johns_at_ks.uiuc.edu)
Date: Thu Jan 24 2002 - 13:23:46 CST

Dear Vlad, and VMD-L
  Vlad was asking how to make an atom selection for atoms with the
name Na+ in the structure file. The easiest way to make an atom selection
for atoms with characters like '+' in them, which can otherwise get
interpreted as regular expression patterns etc, is to double quote the name,
and then use the '\' to escape the problematic symbol.

For the atoms with the name Na+ we would use the selection text
"Na\+" in the atom selection field of the graphics window, or in a
Tcl command like this:
  mol modselect 0 0 name {"Na\+"}

The '\' character escapes the '+' so that it isn't interpreted as a
regular expression. The braces '{','}' and double quote '"' characters
prevent Tcl from interpreting it. If you leave off the braces, Tcl will
interpret the text and mess up the selection. One gotcha to watch out
for with this, is that when you use the VMD "logfile" command, VMD will
log the command back out without the protective braces, as Tcl strips
them out, so it ends up getting logged like this (logfile /dev/tty output):
   vmd > mol modselect 0 0 name {"Na\+"} (command typed into VMD)
   mol modselect 0 0 name "Na\+" (this line is the logfile entry)

If you were to try and run the logged command, it wouldn't work due to
Tcl messing with the text. So, that's the one gotcha to watch out for
with atom selections like these.

I hope this explanation is helpful for everyone, feel free to email
us if you have more questions.

  John Stone
  vmd_at_ks.uiuc.edu

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349              
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078