Rainbow colors each chain in the specified model(s) (all models if none are specified) from red to blue, transiting through yellow, green, and cyan in the process. This may help in visually tracing molecule chains. Since protein PDB files are ordered from N- to C-terminus, rainbow colors the N-terminus of each peptide chain red and the C-terminus blue.
The model numbers can be preceded by #, as in a normal atom specification, or they can be given without #. Even if a narrower atom specification is given, the entire model(s) containing the specified atoms will be acted upon. If no model numbers are given, all molecule models will be affected.
Rainbow spreads the color gradient across each entire chain in the specified model(s), even if part of the chain is not displayed. Each residue in a chain is assigned a different color.
Visible color is determined by a hierarchy in which color at the model level is overruled by color at the residue level, which is in turn overruled by per-atom color settings. The command rainbow sets color at the residue level and removes any color assignments at the atom level so that the residue colors are visible. The per-residue color assignment is useful since it applies to the secondary structure ribbon representation shown with the command resrepr. For the rainbow coloring to apply to a molecular surface, it may be necessary in some cases to set the surface color source to residues using surfcolor byresidue or the surface attributes panel.