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.
Adjust Color in PyMOL
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 C → select 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:
|
|
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.
Change the color of a PyMOL representation
To change the color of a specific representation we can use the set <representation>_color
command.
|
|
For instance, if you want to change the color of your cartoon representation to blue you can use the command:
|
|
![Different colors for a cartoon representation of a protein in Pymol](/pymol_custom/colors.webp)
Change the color of a selection of atoms
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.
|
|
To change the color of the $C_{\alpha}$ in your protein to yellow:
|
|
Color $N$ atoms blue:
|
|
Change the color of a chain (chain A
) to green:
|
|
Color the alpha helices in red:
|
|
Advanced coloring options
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.
|
|
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.
|
|
![Different transparencies of a surface protein in Pymol](/pymol_custom/interior_cartoon.webp)
Modify the transparency 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:
|
|
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>
).
It’s important to note that the transparency needs to be adjusted with different commands depending on the object representation.
We have four commands:
- Surface:
set transparency, <transparency_value> (,<selection>)
- Cartoon:
set cartoon_transparency, <transparency_value> (,<selection>)
- Spheres:
set sphere_transparency, <transparency_value> (,<selection>)
- 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.
|
|
![Different transparencies of a surface protein in Pymol](/pymol_custom/transparency.webp)
Adjust the scale and style of objects in PyMOL representations
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.
Set the style of the cartoon representation
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.
|
|
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.
|
|
![Different style for cartoon representation of a protein in Pymol](/pymol_custom/cartoon_style.webp)
- A very useful trick is to turn on the fancy helices with the
set cartoon_fancy_helices
command followed by1
.
|
|
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:
|
|
- You can also display the helices as cylinders with the
set cartoon_cylindrical_helices
command. This option comes with three modalities0
(no cylinder),1
(curved cylinders),2
(straight cylinders).
|
|
Adjust the size of a cartoon representation
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:
|
|
For $\beta$-sheets we have:
|
|
The radius of the loops can be modified with:
|
|
To modify the dimensions of the fancy helices you will need to use other commands:
|
|
Set the radius of the sticks representation
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.
|
|
The default value of the scale is 0.25. You can decrease it to have thicker sticks and vice versa.
|
|
![Different radius for sticks representation of a propane molecule in Pymol](/pymol_custom/stick_scale.webp)
Set the scale of the sphere representation
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.
|
|
The default value of the scale is 1. You can increase it to have bigger spheres and vice versa.
|
|
![Different scales for sphere representation of a protein in Pymol](/pymol_custom/sphere_scale.webp)