PyMOL: 10 very basic commands that you really need to know- Part 1

The Bioinformatics Manual
11 min readMay 4, 2022

--

Gracias! Gracias for choosing to read this blog on the 10 commands that you need to know, yes really really need to know, to get your hands dirty on using PyMOL. Now, if you are just a beginner starting out with PyMOL, trust me, these commands are gonna be some of the most useful ones in your bioinformatics journey. So what are we waiting for? Let's begin!

Also, do read the whole blog to find a secret command that could make your life easier! Have fun reading!

We'll cover the very basics of using PyMOL as we go along the blog. And in case you are wondering what PyMOL is used for, PyMOL is a great software, absolutely great, that can be used for the visualization of any kind of protein. PyMOL uses Python programming language in the backend, to show you all the beautiful visualizations, and hence the Py at the beginning of PyMOL.

Pre-requisites: To learn to use PyMOL, we will have to download a protein structure from the RCSB PDB page, and then load it in PyMOL. Follow the steps below to do so.

Step 1 — Go to the RCSB PDB page and type 6FEY in the search box as shown below. 6FEY is the pdb name of the protein that we are interested in. (Crystal structure of Drosophila neural ectodermal development factor Imp-L2 with Drosophila DILP5 insulin). Click on the search icon to make the search.

Step 2 — On the page with the protein structure, you will find a Download files option on the top right corner. Click on the option and download the PDB Format of the file on your system. This will be the file we will be working with.

Another pre-requisite, is a very obvious pre-requisite, which is installation of PyMOL. For downloading PyMOL, go to pymol.org and download the latest version of the software. And for the installation of PyMOL on your system, you can refer to the PyMOL documentation here.

Now that we are done with the pre-requisites, let's begin working with PyMOL. On starting up PyMOL, You might get a window for Activation, and in that case, you can always click on Skip Activation and use the software.

Once PyMOL is set up on your system, this is what it should look like.

This is great! This means we are ready to start working! Woohoo! Let's begin!

Command 1- Loading the protein structure in PyMOL

Now, there are two ways of loading the protein structure in PyMOL-

The usual way-

Go to File on the navigation bar above the PyMOL window, and click on Open, to choose a PDB file from your system. Once you choose the file, it will be loaded into PyMOL, and you will be able to work with the file pretty easily.

The shortcut way-

Just type in fetch 6fey ( which is our protein of interest) in the PyMOL command box and click enter, to get the structure of your protein directly.

fetch 6fey

Yay! That's awesome! Isn't it?

Note- This shortcut works only for structures from the RCSB PDB website, and for structures downloaded from anywhere else, you will have to fetch the structure in the usual way.

Advantage of the shortcut-

When loading files from PDB, this can be a useful command, since, you don't have to download and store the file on your system, and you can directly work with the protein molecule in PyMOL. Cool right! Let's go to Command 2 now!

Command 2- Making and renaming a selection

Let's say we loaded our protein molecule into PyMOL, and we want to make a selection of certain atoms from the molecule, what do we do?

PyMOL is simple. Just click the molecules you want to select and they will get selected.

Just to show you, I have clicked a couple of random places, and the atoms there have got selected. These selected atoms have been marked by the (sele) layer on the right-hand side of our protein atom depiction.

Now, to rename this group of atoms that we have selected, we will go to the 'A' option in the (sele) layer and click on rename selection.

Once you click on rename selection, you will be prompted to enter a new name for the layer. Delete the sele name, and rename it as random selection. Once you're done renaming, click on enter.

This new name will now appear amongst the layers on the right. Yay! Awesome!

The usefulness of this command-

You can select and rename selections or layers, to mark a particular domain or a particular active residue, and even color it to depict it visually. Isn't that awesome?

To deselect your selection, just click anywhere on the PyMOL screen other than the protein. Easy.

Also, since I spoke about coloring, why not color our randomly selected molecules? Woohoo, coloring! Let's head to command 3!

Command 3- Colouring a layer/selection

We learned about loading our protein, selecting some atoms out of it, and renaming the layer of those atoms to a name of our interest, uff… tough work, wasn't it? Well, let's have a bit of fun now coloring all of our atoms.

Go to the PyMOL command box, and type in color yellow, random_selection as shown below.

color yellow, random_selection

This should color your selected atoms yellow.

The format to apply color to a selection of atoms or layers is- the word color followed by name of the color ( could be blue, pink, red, yellow, whatever color's your favorite), followed by a comma and the name of the layer.

Therefore, color yellow, random_selection colors my random selection of molecules yellow. How cool is that!

Let's color a bit more since I am not satisfied. Hehe.

Let's do color cyan.

color cyan

Oooooooo….this looks good. Look, since I haven't mentioned any selection, the whole protein is colored cyan. Now, let's color chain A green in color.

The command for this would be- color green, chain A

color green, chain A

Nice! Please let's color chain B as well!

Cool! The command for that would be- color yellow, chain B

color yellow, chain B

Nice! Such a pretty depiction!

Wow! Feels awesome to have learned to color my layers, selections, and even chains, let's now go to command 4? Sure! Why not!

Command 4- Using buttons A, S, H, L, and C

If you've had a good look, each of the layers on the right-hand side of our protein molecule, have buttons A, S, H, L, and C attached to them. You can just click on any of these buttons and options to execute them.

A: A stands for Action, S: S stands for Show, H: H stands for Hide, L : L stands for Label, and C: C stands for Color.

1. Lights, Camera, ACTION!

The Action button is basically a variation of your edit button, through which you can perform any kind of editing task. There are many options present under the Action button, and we will discuss them later, in a detailed blog on this particular button and its options.

2. SHOW them what you got!

The Show button consists of options to change the appearance of the protein structure and depict other molecules of the protein structure like organic molecules, main chain molecules, side-chain molecules, disulfides, and valence atoms. The default appearance of the protein is called a cartoon-type structure.

3. You can HIDE it from the world, but not yourself.

The Hide button consists of options to basically Hide what you can Show using the show button. Hehe. It also consists of options to hide everything on the PyMOL screen, to hide water and hydrogen molecules from the protein structure, and hide unselected atoms and molecules. You can hide main chain atoms, side-chain atoms, and valence atoms additionally.

The Show and Hide buttons are used together to help you see your structure in a particular light, not light, I mean perspective, not perspective maybe, but you understand right…the way you want to see the structure basically. Let's look at an example to understand this correctly.

2+3. Example using Show and Hide buttons together

Let's say I wanna see my protein structure like a mesh ( if you remember, mesh is an option under the Show button ).

I'll basically go to the Show button on my protein (6fey) layer and click on the mesh option to convert my cartoon protein structure into a mesh protein structure.

This is what a mesh structure looks like.

Isn't it pretty? It absolutely is! But we can still see the cartoon structure from inside the mesh. Let's say we don't want the cartoon structure, and I only want the mesh.

I will now click the Hide button on my protein layer (6fey) and then click the cartoon option to hide the cartoon from my screen.

This is what our mesh structure looks like without the cartoon.

Isn't it super-duper pretty? Uff…I love it. So beautiful!

I love the mesh structure, but then, my bestie wants me to do a surface-type protein structure. I don't wanna part with my mesh, but then I love my bestie too, so okay, let's go for the surface-type structure.

The strategy here is that we will first Show the surface protein structure, and then Hide the mesh structure. Follow the pictures below to understand how we can achieve this.

Awesome! My bestie's happy now, and so am I. We've learned how to use Show and Hide together for our protein structures! Yay!

4. LABEL me a freak!

Talking about the Label button, this gives you various options to label your atoms in the protein structure, including labeling by residue name, atom name, one letter code, b-factor, occupancy, Vander-Waals radius, formal charge, etc.

You can also label using atom identifiers like rank/ID/index and user-given properties like entity_id.

5. COLOR it rainbow! Yay!

You have a Color button too! We learned how we could change the color of our protein, layers, selections, as well as chains using the color command in the PyMOL command box. Alternatively, we also have a color button present on each of the layers, from which we can choose the colors we want.

The following options are also available.

a. We can color the carbons, hydrogens, oxygens, and nitrogen, present in the protein structure by using the color by element option. (by element)

b. We can color the chain by using the color by chain option. (by chain)

c. We can color the secondary structures- helix, sheet, loop by using the color by ss option. (by ss)

d. We can color the structure by representation using the color by representation option. (by rep)

e. We can also use a spectrum of colors. Color it rainbow! (spectrum)

f. And if you're lazy, go to the auto option to color automatically. Hehe.(auto)

Psssssst…A secret button…

So, the secret button we're gonna talk about is the show sequence button. If used correctly, this button can make your PyMOL visualization life so much easier. But where is this button?

This button is located at the bottom-est tab of PyMOL and is denoted by a capital "S".

Clicking on this button will provide you with the sequence of your protein molecule.

Voila!

The advantage of having the sequence of your protein is that, you don't need to make any more randomized selections, you can go ahead and select your own part of the protein from the sequence, and it will get selected in the protein structure on the PyMOL screen. Isn't that awesome?

Awesome! Let's head to command 5 now!

Command 5- Increasing and decreasing the transparency of the structure

This is a fun command now. For increasing and decreasing the transparency of our structure, we can use the command set cartoon_transparency, 0.60 where 0 means more opaque and closer to 1 is more transparent.

Look how transparent our structure looks after decreasing the transparency. And now, if we want to get our structure back to how it looked earlier, we can type set cartoon_transparency, 0 (since 0 refers to opaque) in the PyMOL command box.

set cartoon_transparency, 0

Aaaaand our structure is back!

Let's do set cartoon_transparency, 1 to see what happens.

set cartoon_transparency, 1

Therefore, by setting our cartoon_transparency to 1, our protein structure becomes completely transparent, and we can't see our structure anymore. Boom. Gone.

Cool right! Didn't you have some fun with all these PyMOL commands today? To learn a couple more important commands in PyMOL, do keep on a lookout for Part 2 of this blog. Trust me, things are gonna be so much easier, once you have these commands practiced and learned well.

Lemme know whence you become a PyMOL master, sire! Till then, keep practicing!

Congratulations on making it to the end! You’re a hard worker! Keep learning to work on new software every day! And thanks for reading! Meet you in Part 2!

Simple.Concise.Precise. That’s the motto.

Note from the Author: Hey there! How you doin’? Hope you enjoyed my writing! Let me know if you liked it! You can always write to me if you want me to write the manual for a particular software, give me a feedback, or even want to reach out regarding anything in general. I’ll be happy! Reach out to me at snippetsbio@gmail.com. Thank you!

--

--

The Bioinformatics Manual

If you're a biologist just starting out with bioinformatics, this is the best place you could be at! We discuss all heard & unheard bioinformatic software here!