Get colors

From PyMOLWiki
Jump to: navigation, search
Type Python Module
Download get_colors.py
Author(s) Andreas Warnecke
License BSD-2-Clause
This code has been put under version control in the project Pymol-script-repo
  • get_colors contains two functions that can be useful when working with colors
    • get_colors : returns all available PyMOL colors
    • get_random_color : returns a random available PyMOL color
  • Note that basic colors can be accessed manually without this script from the PyMOL menu under Setting --> Colors...
  • For instruction on setting up plugin import see Git intro or Plugin Manager
1LSD colored randomly by residue


Usage

get_colors [ selection [, quiet ]]
get_random_color [ selection [, quiet ]]

Examples

# basic example
get_colors # basic colors
get colors all # larger range with intermediates
#get disco funky
import get_colors
from get_colors import get_colors
from get_colors import get_random_color

cmd.delete('all')
cmd.fetch('1LSD', async=0) # :P
cmd.hide('everything')
cmd.show_as('sticks','not hetatm')
cmd.orient()

python # start a python block
from pymol import stored
stored.atom_list=[]
cmd.iterate('name CA','stored.atom_list.append([model, resi])')
resi_list=["model %s and resi %s"%(value[0],value[1]) for value in stored.atom_list]
for resi in resi_list: cmd.color(get_random_color(),resi)
python end # end python block
cmd.ray()


SEE ALSO