From: Andrew DeYoung (
Date: Fri Aug 15 2014 - 16:46:00 CDT


In an archived message on this mailing list ( ), there is
a recipe by John Stone for labeling all atoms of a molecule:

proc label_atoms { molid seltext } {
  set sel [atomselect $molid $seltext]
  set atomlist [$sel list]
  foreach {atom} $atomlist {
    set atomlabel [format "%d/%d" $molid $atom]
    label add Atoms $atomlabel
  $sel delete

which John Stone explains can be called with:

set molid [molinfo top]
label_atoms $molid "name CA"

When I use this recipe, the labels appear to be the residue and atom names.
How can I modify the above recipe so that the atom indices (e.g., 0, 1, 2,
..) -- which, according to "Selections" in the "Graphical Representations"
window, are referred to by "index" -- are displayed instead?

Thank you very much for your time!

Andrew DeYoung
Carnegie Mellon University