Advanced Coloring: Difference between revisions
mNo edit summary |
|||
(14 intermediate revisions by 11 users not shown) | |||
Line 2: | Line 2: | ||
==Basic Coloring== | ==Basic Coloring== | ||
Any molecule in PyMOL can be assigned a color using the small rightmost buttons in the object list (in the upper right part of the main GUI window. The [[ | Any molecule in PyMOL can be assigned a color using the small rightmost buttons in the object list (in the upper right part of the main GUI window. The [[Color]] command will do the same. | ||
PyMOL has a predefined set of colors that can be edited in the ''Settings->Colors'' menu. | PyMOL has a predefined set of colors that can be edited in the ''Settings->Colors'' menu. | ||
Alternatively, you can use the [[ | Alternatively, you can use the [[Set_Color]] command. | ||
Line 12: | Line 12: | ||
To assign helices, sheets and loops individual colors, do: | To assign helices, sheets and loops individual colors, do: | ||
<source lang="python"> | <source lang="python"> | ||
color red, ss h | |||
color yellow, ss s | |||
color green, ss l+'' | |||
</source> | </source> | ||
When the colour bleeds from the ends of helices and sheets into loops, do: | When the colour bleeds from the ends of helices and sheets into loops, do: | ||
<source lang="python"> | <source lang="python"> | ||
set cartoon_discrete_colors, 1 | |||
</source> | </source> | ||
Or activate ''Cartoon -> Discrete Colors'' in the GUI menu. | Or activate ''Cartoon -> Discrete Colors'' in the GUI menu. | ||
==Coloring by atom type== | ==Coloring by atom type== | ||
The util.cba* ("Color By Atom") commands color atoms according to type: oxygen in red, nitrogen in blue, hydrogen in white. Carbon will get a different colors, depending on the command: | The util.cba* ("Color By Atom") commands color atoms according to type: oxygen in red, nitrogen in blue, hydrogen in white. Carbon will get a different colors, depending on the command: | ||
{| | |||
! command | |||
! carbon color | |||
|- | |||
| util.cba'''g''' | |||
| green | |||
|- | |||
| util.cba'''c''' | |||
| cyan | |||
|- | |||
| util.cba'''m''' | |||
| light magenta | |||
|- | |||
| util.cba'''y''' | |||
| yellow | |||
|- | |||
| util.cba'''s''' | |||
| salmon | |||
|- | |||
| util.cba'''w''' | |||
| white/grey | |||
|- | |||
| util.cba'''b''' | |||
| slate | |||
|- | |||
| util.cba'''o''' | |||
| bright orange | |||
|- | |||
| util.cba'''p''' | |||
| purple | |||
|- | |||
| util.cba'''k''' | |||
| pink | |||
|} | |||
For instance: | For instance: | ||
<source lang="python"> | <source lang="python"> | ||
Line 31: | Line 65: | ||
will color the object ''three'' by atom type, with the carbon atoms in yellow. | will color the object ''three'' by atom type, with the carbon atoms in yellow. | ||
The util.cnc command will color all the atoms according to type, as in the util.cba* commands stated above, except for the C-atoms. | |||
For instance: | |||
<source lang="python"> | |||
util.cnc three | |||
</source> | |||
will color the object ''three'' by atom type, but leave the color of the C-atom unaltered. | |||
==CMYK-safe Colors== | ==CMYK-safe Colors== | ||
There are two distinct color spaces on computers: RGB (red-green-blue), which is for screens, and CMYK (cyan-magenta-yellow-black), which is for printing. | There are two distinct color spaces on computers: RGB (red-green-blue), which is for screens, and CMYK (cyan-magenta-yellow-black), which is for printing. | ||
Some RGB triplets do have equivalents in CMYK space. As a result, a figure that looks great on a screen can come out with unpredictable colors when printed. | Some RGB triplets do not have equivalents in CMYK space. As a result, a figure that looks great on a screen can come out with unpredictable colors when printed. | ||
Most applications do a good job with RGB-to-CMYK conversions for photos, but do not do such a good job with graphics that use pure primary colors. For example, reds are generally OK, but pure blues and greens do not translate very well. | Most applications do a good job with RGB-to-CMYK conversions for photos, but do not do such a good job with graphics that use pure primary colors. For example, reds are generally OK, but pure blues and greens do not translate very well. | ||
Line 80: | Line 121: | ||
==Assign color by B-factor== | ==Assign color by B-factor== | ||
B-factor coloring can be done with the [[spectrum]] command. Example: | |||
spectrum b, blue_white_red, minimum=20, maximum=50 | |||
as cartoon | |||
spectrum b, | cartoon putty | ||
= See Also = | = See Also = | ||
[[Color]], [[ | [[Color]], [[Spectrum]] | ||
==Creating a Color bar== | ==Creating a Color bar== | ||
Line 101: | Line 134: | ||
# Create a pdb-file which contains CA positions only, whereas the numbers correspond to your wanted increments of colors. Be sure that CA's are separated by a contant value, say 5 Angstroem. | # Create a pdb-file which contains CA positions only, whereas the numbers correspond to your wanted increments of colors. Be sure that CA's are separated by a contant value, say 5 Angstroem. | ||
# Load this new pseudobar-pdb file into PyMOL, make bonds between increment 1 and increment 2 [increment 2 and increment 3 and so on...], define/assign a smooth color for each increment (copy colors definition from automatically created colors made by b-factor script) and show the b-factor bar as lines (or sticks). | # Load this new pseudobar-pdb file into PyMOL, make bonds between increment 1 and increment 2 [increment 2 and increment 3 and so on...], define/assign a smooth color for each increment (copy colors definition from automatically created colors made by b-factor script) and show the b-factor bar as lines (or sticks). | ||
Also, see the newly created [[spectrumbar]] script! | |||
==Coloring insides and outsides of helices differently== | ==Coloring insides and outsides of helices differently== | ||
Line 111: | Line 146: | ||
==Coloring all objects differently== | ==Coloring all objects differently== | ||
Is there a simple way to colour each object currently loaded, with a different colour? | Is there a simple way to colour each object currently loaded, with a different colour? | ||
There is a script color_obj.py that does the job. | There is a script [[Color_Objects |color_obj.py]] that does the job. | ||
USAGE | USAGE | ||
Line 124: | Line 157: | ||
gets the same colour as the first), or are the colours of the rainbow | gets the same colour as the first), or are the colours of the rainbow | ||
==List the color of atoms== | ==List the color of atoms== | ||
To retrieve the color for all residues in a selection, you can iterate over it from the PyMOL command line | To retrieve the color for all residues in a selection, you can iterate over it from the PyMOL command line | ||
Line 138: | Line 169: | ||
print pymol.color_list | print pymol.color_list | ||
</source> | </source> | ||
The colors listed will be in terms of Pymol indexing system, see [[Get Color Indices]] for converting to names or rgb values. | |||
== See also == | |||
* [[Ramp_New]] | |||
[[Category:Publication_Quality|Advanced Coloring]] | [[Category:Publication_Quality|Advanced Coloring]] | ||
[[Category:Coloring|Advanced Coloring]] |
Latest revision as of 16:23, 2 March 2016
Coloring Molecules
Basic Coloring
Any molecule in PyMOL can be assigned a color using the small rightmost buttons in the object list (in the upper right part of the main GUI window. The Color command will do the same.
PyMOL has a predefined set of colors that can be edited in the Settings->Colors menu. Alternatively, you can use the Set_Color command.
Coloring secondary structures
To assign helices, sheets and loops individual colors, do:
color red, ss h
color yellow, ss s
color green, ss l+''
When the colour bleeds from the ends of helices and sheets into loops, do:
set cartoon_discrete_colors, 1
Or activate Cartoon -> Discrete Colors in the GUI menu.
Coloring by atom type
The util.cba* ("Color By Atom") commands color atoms according to type: oxygen in red, nitrogen in blue, hydrogen in white. Carbon will get a different colors, depending on the command:
command | carbon color |
---|---|
util.cbag | green |
util.cbac | cyan |
util.cbam | light magenta |
util.cbay | yellow |
util.cbas | salmon |
util.cbaw | white/grey |
util.cbab | slate |
util.cbao | bright orange |
util.cbap | purple |
util.cbak | pink |
For instance:
util.cbay three
will color the object three by atom type, with the carbon atoms in yellow.
The util.cnc command will color all the atoms according to type, as in the util.cba* commands stated above, except for the C-atoms.
For instance:
util.cnc three
will color the object three by atom type, but leave the color of the C-atom unaltered.
CMYK-safe Colors
There are two distinct color spaces on computers: RGB (red-green-blue), which is for screens, and CMYK (cyan-magenta-yellow-black), which is for printing. Some RGB triplets do not have equivalents in CMYK space. As a result, a figure that looks great on a screen can come out with unpredictable colors when printed.
Most applications do a good job with RGB-to-CMYK conversions for photos, but do not do such a good job with graphics that use pure primary colors. For example, reds are generally OK, but pure blues and greens do not translate very well.
Here are some RGB values that are within the CMYK gamut (i.e. are "CMYK-safe"):
#optimized rgb values for cmyk output:
set_color dblue= [0.05 , 0.19 , 0.57]
set_color blue= [0.02 , 0.50 , 0.72]
set_color mblue= [0.5 , 0.7 , 0.9 ]
set_color lblue= [0.86 , 1.00 , 1.00]
set_color green= [0.00 , 0.53 , 0.22]
set_color lgreen=[0.50 , 0.78 , 0.50]
set_color yellow=[0.95 , 0.78 , 0.00]
set_color orange=[1.00 , 0.40 , 0.0 ]
# these are trivial
set_color red= [1.00 , 0.00 , 0.00]
set_color mred= [1.00 , 0.40 , 0.40]
set_color lred= [1.00 , 0.80 , 0.80]
set_color vlred= [1.00 , 0.90 , 0.90]
set_color white= [1.00 , 1.00 , 1.00]
set_color vlgray=[0.95 , 0.95 , 0.95]
set_color lgray= [0.90 , 0.90 , 0.90]
set_color gray= [0.70 , 0.70 , 0.70]
set_color dgray= [0.50 , 0.50 , 0.50]
set_color vdgray=[0.30 , 0.30 , 0.30]
set_color black= [0.00 , 0.00 , 0.00]
##
Note that there are default atom colors such as "carbon", "nitrogen", "oxygen", "hydrogen", "sulfur", etc. which should also be redefined:
set_color carbon= [0.00 , 0.53 , 0.22]
etc.
Coloring with 'chainbows' from a script
The chainbow function can be invoked by:
util.chainbow("object-name")
Assign color by B-factor
B-factor coloring can be done with the spectrum command. Example:
spectrum b, blue_white_red, minimum=20, maximum=50 as cartoon cartoon putty
See Also
Creating a Color bar
To show a vertical/horizontal color bar indiacting the b-factor variation, use the script pseudobar.pml on the structure pseudobar.pdb, or do the following:
- Create a pdb-file which contains CA positions only, whereas the numbers correspond to your wanted increments of colors. Be sure that CA's are separated by a contant value, say 5 Angstroem.
- Load this new pseudobar-pdb file into PyMOL, make bonds between increment 1 and increment 2 [increment 2 and increment 3 and so on...], define/assign a smooth color for each increment (copy colors definition from automatically created colors made by b-factor script) and show the b-factor bar as lines (or sticks).
Also, see the newly created spectrumbar script!
Coloring insides and outsides of helices differently
The inside of helices can be adressed with:
set cartoon_highlight_color, red
Coloring all objects differently
Is there a simple way to colour each object currently loaded, with a different colour? There is a script color_obj.py that does the job.
USAGE
color_obj(rainbow=0)
This function colours each object currently in the PyMOL heirarchy with a different colour. Colours used are either the 22 named colours used by PyMOL (in which case the 23rd object, if it exists, gets the same colour as the first), or are the colours of the rainbow
List the color of atoms
To retrieve the color for all residues in a selection, you can iterate over it from the PyMOL command line
iterate all, print color
In Python, it looks like this:
import pymol
pymol.color_list = []
cmd.iterate('all', 'pymol.color_list.append(color)')
print pymol.color_list
The colors listed will be in terms of Pymol indexing system, see Get Color Indices for converting to names or rgb values.