schrodinger.structutils.color module¶
An interface to the Maestro color palette and color schemes.
Color schemes are read from maestro-v<version>/data/res/scheme.res
.
Copyright Schrodinger, LLC. All rights reserved.
-
class
schrodinger.structutils.color.
Color
(color)¶ Bases:
object
Represent a color as either an integer (colormap index), string (color name or hex “RRGGBB” value), or an RGB value (tuple/list of 3 ints, values 0-255).
- Provides the following properties and methods:
- Color.index = int(Color) - mmcolor index of the color
- Color.name = str(Color) - name of the color or RRGGBB hex value
- Color.rgb - (tuple of 0-255 ints)
- equal = (col1 == col2)
When object is initialized from the RGB value, the Color.index and Color.name attributes are set to the closest color in the mmcolor palette.
-
hex_string
¶ Returns the color as string of hex RGB values (RRGGBB). For example, pure red will be returned as “FF0000”.
-
rgb_float
¶ Returns a tuple of (R, G, B) for this color, each ranging from 0.0 to 1.0.
-
class
schrodinger.structutils.color.
ColorRamp
(colors=('white', 'blue'), values=(0, 100))¶ Bases:
object
An object for calculating colors on a customizable color ramp.
Coloring atoms according to a calculated property that ranges from 0 to 10:
color_ramp = ColorRamp(colors=("white", "blue"), values=(0,10)) for atom in st.atom: property = calc_property(atom) r, g, b = color_ramp.getRGB(property) atom.setColorRGB(r, g, b)
Coloring atoms according to a calculated property that ranges from -10 to 10 using blues for negative values and reds for positive values:
color_ramp = ColorRamp(colors=("blue", "white", "red"), values=(-10, 0, 10)) for atom in st.atom: property = calc_property(atom) color = color_ramp.getRGB(property) atom.setColorRGB(*color)
-
getRGB
(value)¶ Determine the color that corresponds to the specified value
Parameters: value (int or float) – The value to calculate the color for Returns: The color corresponding to the specified value, where the color is a represented by a list of (red, green, blue) integers in the 0-255 range. Return type: list
-
-
class
schrodinger.structutils.color.
ColorScheme
(name='element', color_asl_list=[])¶ Bases:
schrodinger.utils.colorscheme.MM_CScheme
Define a Maestro color scheme.
This class provides the following functionality:
colorscheme.apply(st, [atoms]) for color, asl in colorscheme: <do>
-
add
(color_str, asl, rule_description='')¶ Add another set of rules to this color scheme.
Parameters: - color – color string
- asl – what to apply the color to
-
apply
(st, atoms=None)¶ Applies the scheme to the specified Structure <st>.
Parameters: atoms – Optionally specify which atoms to apply the scheme to in format. Can be a list atom atom indices, or a Bitset instance.
-
copy
()¶ Return a copy of this scheme.
-
-
schrodinger.structutils.color.
apply_color_scheme
(st, scheme, atom_list=None)¶ Applies the scheme to the specified Structure <st>. Optionally a list of atom indecies may be specified.
- scheme
- One of the names returned by available_color_schemes() or a ColorScheme object returned by get_color_scheme().
- atom_list
- A list of atom indices to apply color scheme to (default all atoms).
Raises ValueError if such scheme does not exist. Raises RuntimeError if Maestro installation is not available. Raises IOError if scheme.res file could not be found
-
schrodinger.structutils.color.
available_color_schemes
()¶ Return a list of available color schemes (list of names). Raises RuntimeError if Maestro installation is not available. Raises IOError if scheme.res file could not be found
-
schrodinger.structutils.color.
get_color_scheme
(name)¶ Return a ColorScheme object for scheme <name>. Raises ValueError if such scheme does not exist. Raises RuntimeError if Maestro installation is not available. Raises IOError if scheme.res file could not be found
-
schrodinger.structutils.color.
get_rgb_from_color_index
(index)¶ A convenience function for getting the rgb value for a color index.
Parameters: index – an integer specifying the color index Return r,g,b: a tuple of 3 integer values for the red, green, blue values. Range from 0 to 255.