PyMOL

From 22111
Jump to navigation Jump to search

PyMOL

PyMOL quick reference card


Basic handling

Getting a PDB file

You can download PDB files from the PDB homepage and save them on your computer. Alternatively, if you are connected to the Internet, you can simply type on the PyMOL command line:

fetch 2blh

to load the structure with PDB-ID 2blh directly from PDB into PyMOL. This is usually the preferred way of getting structures. Notice that PyMOL has two command lines: One for the viewer window and one for the command window. They do the same thing.

Manipulating a PDB file

Once you have loaded a structure into PyMOL, you need to be able to manipulate the structure. For this purpose, a three-button mouse with a scroll-wheel is very useful. The small pane on the lower right of the PyMOL viewing window – labelled Mouse Mode – shows what different combinations of Control (ctrl), Shift (Shft), buttons and the wheel will do in the viewing window. Try some of the basic moves described below:

  • Left-click and drag to rotate the molecule (left-clicking along the edge of the viewing window lets you rotate the molecule around an axis, the z-axis, perpendicular to the viewing plane).
  • Right-click and drag the mouse to zoom in and out.
  • Use the scroll-wheel to adjust the thickness of the viewing slab surrounding the molecule. This is called adjusting the clipping plane and is very useful for looking inside protein structures without having to look through/past residues on the surface.
  • To center on a molecule/residue/atom, either middle-click it with the wheel or select (see below) the desired centre and subsequently select “center” for the corresponding selection in the object list on the right side of the viewing window (or simply use the drop-down list you get by right-clicking on the selection in the viewing window).

Representations

There are different types of representation available for molecules. These are found in under S(how) in the menu on the right side. Try the different types to see what they look like. Depending on the tasks at hand, different types of representation will be needed. Representations: line, stick, spheres, ribbon, cartoon. The difference between S(how) and S(how)-as is that the latter will overwrite any current representation while S(how) will add the representation to the current. Use the H(ide) menu to hide molecules.

  • To set the colour of or add labels to a molecule, simply use the L(abel) and C(olor) menus.
  • The A(ction) menu lets you duplicate, delete and in other ways manipulate you structures.

PyMOL basic settings

Changing settings

If you choose "Edit all" under "Settings" in the GUI window, you can see all the settings, that PyMOL allows you to change. If you like slimmer sticks, then change the corresponding value in PyMOL (stick_radius). The background color can be changed to any RGB color by changing "bg_rgb". The three numbers from 0-1 represent the amount of red, green and blue, respectively. Try changing the background color to red. Typing the command below is a shortcut using already named colours (see the C(olor) menu on the right of viewer window).

bg white

Saving To save your image, choose "Save Image" in the "File" menu in the GUI window. If you have to leave PyMOL now, but expect to come back and work some more on your image later, you can save your PyMOL session, so you won't have to start all over again next time. Do this by selecting "Save session" or "Save session as" under the "File" menu. It is a good idea to save your session before doing something radical, in this way it works as an "undo" button. Please note that except for a few specialized cases, PyMOL does not have an undo function.

PyMOL objects and selections

Making selections in PyMOL is one of the most essential skills you will need. If you wish to do something with just a subset of the atoms in an object, you can create either a named selection or a new object consisting of the subset you are interested in. Selections and objects play slightly different roles in PyMOL. For most purposes, I recommend creating new objects with the selections you wish to work with. The most important differences between objects and selections are seen in their behaviour with respect to surface representations and cartoon representations. If you want to maintain a continuous cartoon representation or show just part of a surface, use selections rather than objects.

Objects are created by the command "create" which has the syntax

create object_name, selection 

where object_name = object to create (or modify) and selection = atoms to include in the object. Selections are created in a similar fashion:

select selection_name, selection

If you omit the selection_name, your selection will be given the default name sele (and the contents of any previous sele will be overwritten).

select selection

All selections are listed with their names in parenthesis in the right-hand PyMOL menu in the viewing window. Remember that both selections and objects can be renamed under A(ction) in the right-hand menu.

To understand how selections work, let's have another look at the PDB file. After the header records, the actual coordinates of the atoms are listed in the following format:

ATOM      1  N   GLY A   1      14.752  -6.145  13.692  1.00 25.90        N  

In the first column is the field "ATOM" which indicates that the rest of the line contains atomic coordinate information. The next column is the atom number, then comes atom name (in PyMOL called "name"), then residue name (PyMOL: resn), chain id (PyMOL: chain), residue number (PyMOL: resi). The next three columns are the x, y and z coordinates of the atoms, followed by the occupancy (usually 1.00) and the B-factor. The last column is rarely used (and is missing in some PDB files), but gives the atom type (element).

Selection syntax

The selection syntax of PyMOL will be demonstrated through the examples below. To create an object consisting of just the carbon atoms in the structure, enter

create carbons, name ca+cb+cg+cd 

Try this. You will notice, that it chooses all the carbons in all the chains (including chains D-F). If you want to only choose the carbons in chains A-C, you can either delete the object and then recreate the carbons object, or you can limit your selection to chains A-C:

create carbons, (name ca+cb+cg+cd) and (chain A or chain B or chain C) 

Note that if you have a (+)-separated list of identifiers, no spaces are allowed. If you want to show a range of residues, such as the first 10 residues of the N-terminal, you can use a (-):

create Nterminal, (resi 1-10) and (chain A) 

(but you can not use both (+) and (-) in the same go, resi 1-10+36 is NOT allowed).

create bb, name c+o+n+ca

Selection algebra

You have already seen how to include residues that are either in chain A or chain B or chain C in the above example. Below is a list of other useful selection operators and modifiers. Whenever the create command is used (to create objects), the select command could be used instead (to make selections). The examples assume that you have an open PyMOL session which contains two selections called s1 and s2. Whenever a distance is given, any number could be used.

Select atoms that are not included in s1:

create complementary_subset_object, not s1

Select atoms included in both s1 and s2:

create new_subset_object, s1 and s2

Select atoms belonging to either s1 or s2:

create new_combined_object, s1 or s2

Select atoms with centers within 5 Angstroms of the center of any atom in s1:

create neighbouring_atoms_only_object, s1 around 5

Expand s1 by all atoms within 7 Angstroms of the centre of any atom in s1:

create neighbouring_atoms_also_object, s1 expand 7

Select atoms in s1 that are within 3.5 Angstroms of s2:

create partial_neighbouring_object, s1 within 3.5 of s2

Expand selection/object to complete residues:

create complete_residues_object, byres s1		

Expand selection/object to complete objects:

create complete_object, byobject s1

Select atoms directly bonded to s1:

create neighbour_bond_atoms_object, neighbor s1

The iterate command

The iterate command in PyMOL is very useful for writing out the contents of objects and selections, e.g. residues in a selection. In the example below (PDB-ID 2htq), the residue numbers and names for the residues near a bound ligand are written out to the command window.

First, we must select the residues in the vicinity of the ligand named ZMR:

select activesite, 2htq within 5 of resn zmr

This produces a selection called activesite consisting of all atoms in the structure 2htq, which are within 5 Å of the ligand. Next, this selection needs to be completed to consist of full residues. Either type the following:

cmd.select("activesite","(byres activesite)",enable=1)

or go to Action-modify-complete-residues in the right-hand side of the viewer window. Now we need a bit of python code: First create a list object with the following command:

residuelist = []

Next, we will use the iterate command to fill in some pairs of information in the list:

iterate activesite and name CA, residuelist.append((resi, resn))

Notice two things here: First, the iterate command is asked to only consider the information for C-alpha atoms (activesite and name CA). That's why it is important that all atoms for each residue are included. Second, both the residue number (resi) and the residue name (resn) are added to the list as a pair.

Finally, print the information stored in residuelist by typing the following in the command window:

for pair in residuelist: print pair[0], pair[1]

The output should look something like this:

118 ARG
119 GLU
134 LEU
151 ASP
152 ARG
156 ARG
178 TRP
179 SER
222 ILE
224 ARG
227 GLU
246 ALA
276 GLU
277 GLU
292 ARG
347 TYR
371 ARG
406 TYR

Making pretty pictures

To make more fancy-looking pictures, simply press the Ray button (top right) or type:

ray

If you specify X,Y at the end this corresponds to the dimensions of the picture in pixels.

ray 500, 1000

For different ray-tracing modes, try changing (setting) the ray_trace_mode (0-3). For instance:

set ray_trace_mode, 3

Useful Links

Exercise your PyMOL Skills (Advanced)

Subtilisin, elastase and trypsin

  1. Find three structures of subtilisin, elastase and trypsin in PDB.
  2. Try aligning them using the align command found in the A(ctions) menu. What do you see?
  3. Identify the active site residues and highlight these.
  4. Compare active sites between the three proteins. Do they have anything in common?
  5. Try making a simple, ray-traced figure highlighting the active site. Play with the different ray-tracing modes.