PyMOL colors and basic customization

How to color and modify the appearance of your system in PyMOL

 

PyMOL is a popular and widely used tool for visualizing and analyzing 3D molecular structures. Sometimes you will find that the default visualization settings may not fit your needs. For instance, you may want bigger spheres, different colors, or increase the transparency of your objects.

That’s where PyMOL’s customization options come in.

One of the most important features of PyMOL is its ability to color and customize the representation of molecular structures, which can greatly aid in their analysis and interpretation as well as with the rendering of images.

PyMOL gives you different options to change the colors of your representations and style your project in many ways.

In this guide, we will explore the basics of customization and focus on how to change the color and transparency, and how to adjust the size of objects in the visualization of molecular structures providing examples and explanations on how to use them effectively.

You can accomplish almost everything you can imagine in PyMOL. Here, I will just show you a few examples of some of the most common operations that you may need in your analysis.

 

 

The first basic operation that you may want to achieve in PyMOL is to change the color of your system.

The most straightforwadr way to do so is to use the object menu panel by clicking on Cselect the color. You will have the possibility to select a cpecific color as well different coloring schemes such as color by chain or secondary structure.

As always, the second option is to use the color command followed by the name of the color you need. For instance, to color a molecule red, you simply need to type:

1
color red

 

PyMOL provides you with a wide range of colors including standard options as well as more “exotic” choices. You can access all the colors available in PyMOL and their corresponding names here.

To achieve more control over the coloring process PyMOL gives you different options. Here, we will explore a few of the most common.

 

 

To change the color of a specific representation we can use the set <representation>_color command.

1
set <representation>_color, <color_name>:
Example

For instance, if you want to change the color of your cartoon representation to blue you can use the command:

1
set cartoon_color, blue
Different colors for a cartoon representation of a protein in Pymol

 

 

To alter the color of a specific subset of atoms, use the color command followed by a selection of atoms (my_selection). Find more info on the PyMOL selection tool here. Some examples are given below.

1
color <color> , <my_selection>
Examples

To change the color of the $C_{\alpha}$ in your protein to yellow:

1
color yellow, name CA

Color $N$ atoms blue:

1
color blue , elem N

Change the color of a chain (chain A) to green:

1
color green, chain A

Color the alpha helices in red:

1
color red, ss h

 

 

Here we will explore a couple of advanced coloring options available in PyMOL.

Let’s say that you want to color your system by atom type. Sure, you could do this by manually assigning each element to a different color but this can be tedious and time-consuming.

A more efficient approach is to use the built-in PyMOL command util.cba (“Color By Atom”) which can be used to color atoms based on their atom type. This is a useful tool for visualizing the different chemical components of a molecule.

Specifically, oxygen atoms will be displayed in red, nitrogen atoms in blue, and hydrogen atoms in white. To set the color for carbon atoms, you can specify a letter code at the end of the command.

For example, to color carbon atoms green, you would add the letter “g” (cbag) in the command (yellow “cbay”, cyan “cbac”,…). You can also use a selection to color a certain part of the system.

1
2
3
4
5
#this will color everything by atom type with green carbons (cbag)
util.cbag  

#this will color organic molecules by atom type with yellow carbons (cbay)
util.cbay organic 

 

Another common option is one that you may have seen in a few papers and consists of a cartoon representation where the interior part of the helix has a different color.

To achieve this you can use the set cartoon_highlight_color command followed by the name of the color. Generally, the inner part of the helices is reported in grey but as usual, you can play with the customization as you wish.

1
2
3
4
5
set cartoon_color, red
set cartoon_highlight_color, grey85

set cartoon_color, green
set cartoon_highlight_color, grey
Different transparencies of a surface protein in Pymol

 

 

PyMOL offers the possibility to modify the transparency of your system or particular regions with the set transparency command. The syntax is as follows:

1
set transparency, <transparency_value> (,<selection>)

 

The <transparency_value> is a number ranging from 0 to 1, with 0 being completely opaque and 1 being completely transparent. Optionally, you can also decide to apply the transparency to a specific part of your system by using a selection (<selection>).

 

Note

It’s important to note that the transparency needs to be adjusted with different commands depending on the object representation.

We have four commands:

  1. Surface: set transparency, <transparency_value> (,<selection>)
  2. Cartoon: set cartoon_transparency, <transparency_value> (,<selection>)
  3. Spheres: set sphere_transparency, <transparency_value> (,<selection>)
  4. Sticks: set stick_transparency, <transparency_value> (,<selection>)

 

Here is a brief illustration to show how transparency changes moving from 0 to 1. From left to right we have.

1
2
3
set transparency, 0
set transparency, 0.5
set transparency, 0.9
Different transparencies of a surface protein in Pymol

 

 

Another possible customization you may want to accomplish in PyMOL is to adjust the scale or style of different representations.

In this article, I will suggest you a few useful modifications for the cartoon, sticks, and spheres representations.

 

 

The cartoon representation is a popular tool for visualizing the overall shape and structure of a protein in PyMOL.

Different cartoon styles are available in PyMOL and they can be changed by using this command.

1
cartoon <style> (,<selection>)

 

There are several <style> keywords that you can use:

  • automatic
  • loop
  • rectangle
  • oval
  • tube
  • arrow
  • dumbbell

 

Feel free to customize your protein as you prefer. As always, remember that you can pass a selection to apply the changes to a restricted group of atoms.

Some of the styles (automatic, dumbbell, and tube) are reported in the image below.

1
2
3
cartoon automatic
cartoon dumbbell
cartoon tube
Different style for cartoon representation of a protein in Pymol

 

Bonus tips
  1. A very useful trick is to turn on the fancy helices with the set cartoon_fancy_helices command followed by 1.
1
set cartoon_fancy_helices, 1

This will display them with tubular edges making them more visually appealing.

If you don’t like what you see you can always turn them off like this:

1
set cartoon_fancy_helices, 0

 

  1. You can also display the helices as cylinders with the set cartoon_cylindrical_helices command. This option comes with three modalities 0 (no cylinder), 1 (curved cylinders), 2 (straight cylinders).
1
2
3
set cartoon_cylindrical_helices, 0
set cartoon_cylindrical_helices, 1
set cartoon_cylindrical_helices, 2

 

 

The cartoon representation is composed of three main elements: alpha helices, beta sheets, and loops.

We can modify the width and the thickness of each of the three components using different options followed by a numerical value (hereafter referred to as <value>) that it’s up to you to decide.

To change the appearence of the $\alpha$-helices you can use:

1
2
set cartoon_oval_length , <value> # default is 1.20
set cartoon_oval_width , <value>  # default is 0.25

 

For $\beta$-sheets we have:

1
2
set cartoon_rect_length , <value>
set cartoon_rect_width , <value>

 

The radius of the loops can be modified with:

1
set cartoon_loop_radius, <value>

 

Note

To modify the dimensions of the fancy helices you will need to use other commands:

1
2
3
set cartoon_dumbbell_length, <value>
set cartoon_dumbbell_width, <value>
set cartoon_dumbbell_radius, <value>

 

 

The stick representation in PyMOL is a useful tool for visualizing the detailed atomic structure of a molecule.

The radius of the sticks can be adjusted using the set_stick_radius command, which allows you to change the size of the sticks. You can do that for the overall system or a certain selection.

1
set stick_radius, <value> (, <selection>)

 

The default value of the scale is 0.25. You can decrease it to have thicker sticks and vice versa.

1
2
3
set stick_radius, 0.5
set stick_radius, 0.25
set stick_radius, 0.1
Different radius for sticks representation of a propane molecule in Pymol

 

 

The scale of the sphere representation can be adjusted using the set_sphere_scale command, which allows you to tailor the size of the spheres to your needs creating a more informative or visually appealing representation. As always, you can decide to pass a selection to modify the scale for a certain group of atoms.

1
set sphere_scale, <value> (, <selection>)

 

The default value of the scale is 1. You can increase it to have bigger spheres and vice versa.

1
2
3
set sphere_scale, 1.5
set sphere_scale, 1
set sphere_scale, 0.5
 Different scales for sphere representation of a protein in Pymol