Pymol: the best protein structure viewer

View and Themes

background color

bg_color grey30

Display Amino Acid

set seq_view, on
set seq_view_format, 0

Add something

Add Hydrogen bonds

Add Hydrogen bonds: PyMOL tutorial

Action → find → polar contacts → select from menu

Add Hydrogen bonds
© PyMOL tutorial

Remove something

cite: © Jan-Philip Gehrcke; 2011

# removing hydrogens
remove (hydro)
remove hydrogens

# removing water
remove resn hoh

# removing solvent
remove solvent

Get informations

Chain information

get_chains 4fqi
 cmd.get_chains:  ['A', 'B', 'C', 'H', 'L']
PyMOL>replace C,4,4

Amino Acid Sequence

source: pymolwiki

print(cmd.get_fastastr('all'))

# for only show chain B:
print(cmd.get_fastastr('5WL2 and chain B'))
>5WL2_H
QVQLVQSGAEVKKPGSSVKVSCKASGGTFSSYAISWVRQAPGQGLEWMGGIIPIFGTANYAQKFQGRVTI
TADESTSTAYMELSSLRSEDTAVYYCARHGNYYYYSGMDVWGQGTTVTVSSASTKGPSVFPLAPSSKSTS
GGTAALGCLVKDYFPEPVTVSWNSGALTSGVHTFPAVLQSSGLYSLSSVVTVPSSSLGTQTYICNVNHKP
SNTKVDKRVEPKSCHHHHHH
>5WL2_L
QSVLTQPPSVSEAPRQRVTISCSGSSSNIGNNAVNWYQQLPGKAPKLLIYYDDLLPSGVSDRFSGSKSGT
SASLAISGLQSEDEADYYCAAWDDSLNGAVFGGGTQLTVLGQPKAAPSVTLFPPSSEELQANKATLVCLI
SDFYPGAVTVAWKADSSPVKAGVETTTPSKQSNNKYAASSYLSLTPEQWKSHRSYSCQVTHEGSTVEKTV
APTECS
...

Object manipulation

movement

rotate y,-.2, 4fqh
rotate x,-.2, 4fqh
rotate z,-.2, 4fqh

hide chain

hide representation [,object]
hide representation [,(selection)]
hide (selection)

Show Chain

show cartoon, Mos99 and chain A chain B

Colors for Pymol

pymolwiki: Colors’ name and values

Assign the name of color into an object

# assign the color into an object
color red, Mos99
# assign the color into selected molecules
select part1, Mos99 and chain A and resi 50+56+60
color hotpink, part1

Example of set a color by RGB value and assign it into an object

set_color red2, [1,0.3,0.01]
color red2, Mos99

Strcture align

Protein Structure Align
© Pymol
fetch 1oky 1t46, async=0

# 1) default with outlier rejection
align 1oky, 1t46

# 2) with alignment object, save to clustalw file
align 1oky, 1t46, object=alnobj
save alignment.aln, alnobj

# 3) all-atom RMSD (no outlier rejection) and without superposition
align 1oky, 1t46, cycles=0, transform=0

Partial structure align

Cite: Queen’s University

align 5cha and resi 1-100, 2xxl and resi 300-400
# or in short form:
align structure2 & i. 1-100, structure 1 & i. 300-400

# Furthermore, you may wish to restrict the alignment to just the backbone atoms, so you can say:

align structure2 and resi 1-100 and name n+ca+c+o, structure1 and resi 300-400 and name n+ca+c+o

# or in short form:

align structure2 & i. 1-100 & n. n+ca+c+o, structure1 & i. 300-400 & n. n+ca+c+o

Align chains

align 5cha and chain A+B+C, 2xxl and chain A

Atom

Atom color

## change the whole proteins color
color grey90, 2xxl
color grey80, 2xxl 5cha # 2 proteins

Select Atom

Select Properties

PyMol
select aas, resn ASP+GLU in 2xxl

Create a variate ass which contain all ASP and GLU residues.

Distance

In pymol, you cannot calculate the distance between 2 residues. You can only do it on molecules. For calculate the distance between 2 residues, we could use alpha carbon (CA) as the reference

distance my_distance, 1tzg and chain P and resi 4 and name CA, 1tzg_H_L_P and chain H and resi 50 and name CA

For searching the nearest distance between 2 residues, a easiest way is using python pymol module.
But when if you could use python, than, maybe Biopython could be a better choice.

from pymol import cmd

# Load the structures (skip if already loaded)
cmd.load("1tzg.pdb")
cmd.load("1tzg_H_L_P.pdb")

# Select atoms in the specified residues
residue1 = "1tzg and chain P and resi 4"
residue2 = "1tzg_H_L_P and chain H and resi 50"

# Get atom identifiers for both residues
atoms1 = cmd.get_model(residue1).atom
atoms2 = cmd.get_model(residue2).atom

# Iterate over all atom pairs and calculate distances
MIN = 1000
for atom1 in atoms1:
for atom2 in atoms2:
distance = cmd.get_distance(f"{residue1} and name {atom1.name}", f"{residue2} and name {atom2.name}")
print(f"Distance between {atom1.name} in residue {atom1.resi} and {atom2.name} in residue {atom2.resi}: {distance:.2f} Å")
if distance <= MIN:
MIN = distance

Zoom

In pymol, you could zoom into a specific residues. Those different codes works differently. But they could achieve similar effects.

zoom 1tzg and chain A and resi 51
center 1tzg and chain A and resi 51
orient 1tzg and chain A and resi 51

Location Moving

Transition

# Moving the entire chain A 10 unit from 8a95 
cmd.translate([10.0, 0.0, 0.0], '8a95 and chain A')
cmd.rotate('z', 45, chain_to_move)

Change the Chain Name

cmd.alter("Native and chain A", "chain='B'")
alter Native and chain A, chain='B' 

Pymol: the best protein structure viewer

https://karobben.github.io/2021/09/17/Bioinfor/pymol/

Author

Karobben

Posted on

2021-09-17

Updated on

2024-12-20

Licensed under

Comments