PYMOL技巧及常用命令
(2013-05-08 21:30:16)
标签:
365 |
转来至
基本命令(也可使用鼠标操作,但不如命令来得简单)
pwd
dir
cd directory
#change directory
load
xxx
reat name, (selection) #name=object to
creat, selection=atom to include in the new
object,
Manipulating object:
show representation, (selection)
hide representation, (selection)
#the available representations are: (前面是个人比较常用的)lines, spheres, ribbon, cartoon, sticks, surface, /// mesh, dots, labels, extent
例如:
Turn an object on and off:(这个直接用鼠标就ok了)
enable/disable, object-name #turn on/off all representation
Basic atom selections:
name
resn
resi
chain
elem
Selection
algebra:
交集是and、&,例如
并集是or/|,补集是not/!
Change your point of view:
zoom,
(selection)
orient,
(selection)
enter, (selection) # size not changed
turn axis, angle #rotate camera
move axis,
distance
Align (个人认为最重要的功能):
align
(source), (target)
例如:
align mol1 & resi N1, mol2 & resi
N2
align mol1 & resi N1-N2 & name
n+ca+c+o,mol2 & resi
N3-N4 & name
n+ca+c+o
在align的过程中会产生一个root mean square deviation (RMSD),这个值可在一定程度上衡量alignment的效果。
Set
control
例如
set bg_rgb, [1,1,1] #set background as white
set ribbon_sampling, 1
Measurement
dist
angel
dihedral #测量四个原子之间的二面角
Displaying biochemical Properties
- Selecting secondary structures
- Color by atom type from a script
- Displaying double bonds
- Calculating dihedral angles
- Adding hydrogen bonds
- Color by B-factor
- Polar surface area
- Displaying solvent accessible surface
- Display C-Alpha trace of proteins
- Display Phosphate trace of nucleic acids
- Align proteins with CA fit
Selecting secondary structures
Examples:
select helix, (ss h)
select sheet, (ss s)
select loop, (ss l+'')
Color by atom type from a script
The "util" module contains a number of functions that color the atoms according to type, with different colors for the C atoms. For instance,
in a .pml script will color object
"three" by atom type, with the carbon atoms in yellow ("color by
atom yellow").
Other functions from ../modules/pymol/util.py
are
Lieven Buts
Displaying double bonds
You can try going into lines mode and turning on the valence display:
hide
show lines
set valence, 0.1
a higher value for valence spreads things out more. I don't know of a way to get the dotted notation.
Michael George Lerner
Calculating dihedral angles
The get_dihedral function requires four single-atom selections to work:
get_dihedral prot1///9/C, prot1///10/N, prot1///10/CA, prot1///10/C
Adding hydrogen bonds
Regarding H-bonds. There isn't a built-in function yet, but you can show H-bonds between two objects using atom selections so long as hydrogens are present in both molecules. If you don't have hydrogens, you can use h_add on the proteins or provide ligands with valence information and then use h_add.
Two examples are below. For clarity, they draw dashes between the heavy atoms and hide the hydrogens.
EXAMPLE
1:
EXAMPLE
2:
There is also a script drawing nice
hydrogen bonds from
Warren DeLano
Assign color by B-factor
Robert Campbell has
a
it has a number of options including the selection and two types of
colouring schemes (rainbow versus a blue-magenta-red gradient) and
two types of binning of the colours (equal number of atoms in each
colour or equal spacing of colours along the B-factor
range).
See
Robert L. Campbell
Polar surface area
For a solvent accessible PSA approximation:
set dot_density, 3
remove hydro
remove solvent
show dots
set dot_solvent, on
get_area elem N+O
get_area elem C+S
get_area all
For molecular PSA approximation
set dot_density, 3
remove hydro
remove solvent
set dot_solvent, off
get_area elem N+O
get_area elem C+S
get_area all
Showing dots isn't mandatory, but
it's a good idea to confirm that you're getting the value for the
atom dot surface you think you're using.
Please realize that the resulting numbers are only approximate,
reflecting the sum of partial surface areas for all the dots you
see. To increase accuracy, set dot_density to 4, but be prepared to
wait...
Warren DeLano
Display solvent accessible surface
Using the surface display mode,
PyMOL doesn't show the solvent accessible surface, rather it shows
the solvent/protein contact surface. The solvent accessible surface
area is usually defined as the surface traced out by the center of
a water sphere, having a radius of about 1.4 angstroms, rolled over
the protein atoms. The contact surface is the surface traced out by
the vdw surfaces of the water atoms when in contact with the
protein.
PyMOL can only show solvent accessible surfaces using the dot or
sphere representations:
for dots:
show dots
set dot_mode,1
set dot_density,3
for spheres:
alter all,vdw=vdw+1.4
show spheres
Kaushik Raha
Displaying the C-Alpha trace of proteins
hide
show ribbon
set ribbon_sampling,1
And if your model only contains CA atoms, you'll also need to issue:
set ribbon_trace,1
Warren DeLano
Displaying the Phosphate backbone of nucleic acids
Should you ever want to show the phosphate trace of a nucleic acid molecule:
def p_trace(selection="(all)"):
cmd.extend('p_trace',p_trace)
and then:
p_trace (selection)
Luca Jovine
Align proteins with CA fit
If the proteins have significant homology, then you can use the align command:
align prot1////ca,prot2
which will perform a sequence alignment of prot1 against prot2, and then an optimizing fit using the CA positions. I'm not sure if the help text for align got into 0.82, but the next version will definitely have it.
Coloring molecules
- Coloring secondary structures
- Color by atom type from a script
- CMYK-safe Colors
- Color by B-factor
- Creating a Color bar
- Coloring insides and outsides of helices differently
- Coloring all objects differently
- List the color of atoms
Coloring secondary structures
Examples:
color red, ss h
color yellow, ss s
color green, ss l+''
When "the colour bleeds from the ends of helices and sheets into loops," try setting cartoon_discrete_colors to 'on' (or 1).
or from the the "Cartoon" menu of the external GUI find "Discrete Colors" as the last item in the menu.
Robert Campbell
Color by atom type from a script
The "util" module contains a number of functions that color the atoms according to type, with different colors for the C atoms. For instance,
in a .pml script will color object
"three" by atom type, with the carbon atoms in yellow ("color by
atom yellow").
Other functions from ../modules/pymol/util.py
are
Lieven Buts
Use CMYK-safe Colors
Some RGB triplets do have
equivalents in CMYK space, and as a result, a figure that looks
great on a screen can come out with unpredictable colors when
printed.
Most applications do a good job with RGB-to-CMYK conversions for
photos, but do not do such a good job with graphics that use pure
primary colors. For example, reds are generally OK, but pure blues
and greens do not translate very well.
Here are
some
set_color green= [0.00 , 0.53 , 0.22]
Note that there are default atom
colors such as "carbon", "nitrogen", "oxygen", "hydrogen",
"sulfur", etc. which should also be redefined:
set_color carbon= [0.00 , 0.53 , 0.22]
Here's still another URL. Although
the list of colors is not extensive, you can see
colors:
Gil Prive, Dave Fahrney and Warren DeLano
Assign color by B-factor
Robert Campbell has
a
it has a number of options including the selection and two types of
colouring schemes (rainbow versus a blue-magenta-red gradient) and
two types of binning of the colours (equal number of atoms in each
colour or equal spacing of colours along the B-factor
range).
See
Robert L. Campbell
Creating a Color bar
To show a vertical/horizontal color
bar indiacting the b-factor variation, use the
script
1. Create a pdb-file which contains CA positions only, whereas the
numbers correspond to your wanted increments of colors. Be sure
that CA's are separated by a contant value, say 5 Angstroem.
2. Load this new pseudobar-pdb file into PyMOL, make bonds between
increment 1 and increment 2 [increment 2 and increment 3 and so
on...], define/assign a smooth color for each increment (copy
colors definition from automatically created colors made by
b-factor script) and show the b-factor bar as lines (or
sticks).
Bartholomeus Kuettner
Coloring insides and outsides of helices differently
Q: does anyone know how to color the
inside of helices a different color than the outsides?
A:
set cartoon_highlight_color, red
Warren L. DeLano
Coloring all objects differently
Q: Is there a simple way to colour
each object currently loaded, with a different colour?
A: There is a script
The script is also available
at
USAGE
Gareth Stockwell
List the color of atoms
To retrieve the color for a residue as identified in an expression, you can either iterate over a selection from the PyMOL command line
iterate all, print color
Alternatively, this can be done from
a
Rendering molecules
- Displaying in ball-and-stick mode
- Adjusting width of cartoons
- Calculating a partial surface
- Displaying surface inside a molecule
- Displaying all states of a multiple model/NMR structure
- Displaying dashed lines
- Adjusting size of selection indicators
- Adjusting ray traced picture size
- Ray tracing maps
- Nice PovRay settings
- Making stereo pairs
- Meaning of get_view parameters
- Viewing direction vectors (axes)
- Ray-traceable text labels
- CGO label orientation
Displaying in ball-and-stick mode
Q: I've tried several settings and commands but cannot figure out how to make a simple ball-and-stick representation of a molecule. Can it be done in Pymol?
A: Yes, but it is non-obvious:
hide lines
show sticks
show spheres
set stick_radius=0.1
set sphere_scale=0.25
You can change the two numbers above to fit preferences.
Warren DeLano
Adjusting width of cartoon
Try varying the following.
For strands:
cartoon_rect_length
cartoon_rect_width
For helices:
cartoon_oval_length
cartoon_oval_width
or for "fancy" helices:
cartoon_dumbell_length
cartoon_dumbell_width
cartoon_dumbell_radius
In each case "length" refers to what some might call the width and "width" refers to what some might call the thickness.
Robert Campbell
Calculating a partial surface
There is a, until now, undocumented way to calculate a surface for only a part of an object without creating a new one:
flag ignore, not A/49-63/, set
delete indicate
show surface
If the surface was already computed, then you'll also need to issue the command:
rebuild
Warren DeLano
Displaying surface inside a molecule
As far as I can tell, setting
ambient to zero alone doesn't quite do the job, since some
triangles still get lit by the light
source.
The best combination I can find is:
set ambient=0
set direct=0.7
set reflect=0.0
set backface_cull=0
Which gives no shadows and only a
few artifacts.
As an alternative, you might just consider showing the inside of
the surface directly...that will create less visual artifacts, and
so long as ambient and direct are sufficiently low, it will look
reasonable in "ray".
util.ray_shadows("heavy")
set two_sided_lighting=1
set backface_cull=0
Warren DeLano
Displaying all states of a multiple model/NMR structure
Just go to the movies menue and click 'show all states'.
Jules Jacobsen
Displaying dashed lines between two atoms
I think the following commands will do what you want:
This will give you a dashed line object d which is labelled with the distance between the two atoms 'a' and 'b' - you can get rid of the label using
btw, if you want to ray-trace the image, I find the dashes come out a bit fat - so I tend to use
before the 'ray' command.
Gareth Stockwell
·
Adjusting size of selection indicators
Try:
Warren L. DeLano
Adjusting ray trace-image size
The pymol ray tracer can generate an image of any size.
ray height,width
Example:
ray 3000,2400
png filename.png
For more options, try 'help
ray'
Evan Stein and Ben Cornett
Ray tracing maps
For better quality maps with a white background.
set ray_trace_fog,0
set ray_shadows,0
set antialias,1
ray 1600,1200
png img.png
(it will take quite a
while...)
Then open img.png using an external image viewer. It should be high
enough resolution to print nicely.
Warren DeLano
Nive PovRay settings
I typically use
the
Then I edit that file to insert some lines like:
fog {
colour rgbt<1.0, 1.0, 1.0, 0.1>
turbulence 0.8
}
In this case I'm not really doing
depth-cueing but adding fog at the lower background edge (there
were two planes defining the background and a surface below the
molecule) rising up towards the front upper edge of the
scene.
"fog_type 2" means a "rising fog" along the "up" vector. fog_type 1
is a constant fog. To get pure depth cueing, you would want "up" to
be along the <0., 0., 1.> vector (I think!). You'll need to
play around with the distance and fog_offset parameters.
You wouldn't necessarily want the "turbulence" parameter in there
either.
Check out "Atmospheric Effects" in the povray documentation for
many more details:
Robert Campbell
Making stereo pairs
Try:
ray angle=-3
png image1.png
ray angle=3
png image2.png
This is superior to using the "turn"
command because it also rotates the light source. That way shadows
will look right.
To make even more beautiful stereo images, use a program like
Illustrator or Canvas to add the stereo/depth cued labels. This is
a little tricky to describe, but I'll give it my best shot. Place
the two images side by side with their centers separated by 6.0 -
6.5 cm, and aligned horizontally. Now add all your labels on the
LEFT figure. select all of your labels and duplicate them. Move the
duplicated labels to the RIGHT side. For clarity sake let's assume
we have 3 labels on the LEFT side (a,b, and c -- we will call then
aL and aR for the left and right labels, respectively). Place aL
near a recognizable feature of the LEFT figure that you are trying
to label. Now horizontilly align aR with aL. Now using only the L/R
arrow keys move the aR label until the identical portion of the
actual label (let's say the lower right hand tip of the 'a') is
vertically aligned with the identical portion of your model (let's
say where the C alpha-C beta bond leaves the ribbon backbone) on
both the LEFT and RIGHT images. Repeat these steps for each pair of
labels. This is a nice method for adding stereo labels because it
does not require looking at your computer screen in wall-eyed
stereo for 2 hours in order to get proper placement of
labels.
By assuring that the labels are positioned in the LEFT and RIGHT
images at positions that are identical with respect to the part of
the model that is being labeled you automatically are also placing
them so they are at the proper depth when the figure is finally
viewed in stereo.
Scott Classen and Warren DeLano
Meaning of the get_view output
Of the 18 numbers in the output
array,
0-8 is the 3x3 rotation matrix,
9-11 is the camera location,
12-14 is the origin of rotation,
15-16 are the clipping distances,
and 17 is the orthoscopic flag.
Robert Campbell, Paolo Martel and Warren
Viewing direction vectors
Create a python script (I call
it
# axes.py
from pymol.cgo import *
from pymol import cmd
from pymol.vfont import plain
# create the axes object, draw axes with cylinders coloured red, green,
#blue for X, Y and Z
obj = [
# add labels to axes object (requires pymol version 0.8 or greater, I
# believe
cyl_text(obj,plain,[-5.,-5.,-1],'Origin',0.20,axes=[[3,0,0],[0,3,0],[0,0,3]])
cyl_text(obj,plain,[10.,0.,0.],'X',0.20,axes=[[3,0,0],[0,3,0],[0,0,3]])
cyl_text(obj,plain,[0.,10.,0.],'Y',0.20,axes=[[3,0,0],[0,3,0],[0,0,3]])
cyl_text(obj,plain,[0.,0.,10.],'Z',0.20,axes=[[3,0,0],[0,3,0],[0,0,3]])
# then we load it into PyMOL
cmd.load_cgo(obj,'axes')
Then you just need to do "run
axes.py" from the pymol command line.
You can modify the "3" in the above description of the text labels to change the size of the labels. If you are running a version of pymol older the 0.8, then you cannot add the text (that's why I included colour coding of the axes). You can also use just lines instead of cylinders if you wish:
obj = [
would work as well to define the
axes object.
Ray-traceable labels
You can use the cgo text (line or
cylinder versions) as I mentioned in my reply about drawing the xyz
axes, but be warned that the labels rotate with your molecule, so
getting them oriented perpendicular to the view may be a pain
(unless there is something I've missed).
Warren's example from a previous reply of his (cgotext.py):
# draw text using cgo
from pymol import cmd
from pymol.cgo import *
from pymol.vfont import plain
cgo = []
axes = [[2.0,0.0,0.0],[0.0,2.0,0.0],[0.0,0.0,2.0]]
pos = [0.0,0.0,0.0]
wire_text(cgo,plain,pos,'Hello World',axes)
pos = [0.0,-3.0,0.0]
cyl_text(cgo,plain,pos,'Hello Universe',0.10,axes=axes)
cmd.set("cgo_line_radius",0.03)
cmd.load_cgo(cgo,'txt')
cmd.zoom("all",2.0)
Robert Campbell
CGO label orientation
You could use
the
Thus if you have your label in an object called 'text', you could
do,
and repeat this with different angles, until you get the orientation correct. Then use:
(using the appropriate vector, of
course!) to position the label.
Not ideal, but if it is sufficiently important, it can be
done!
Modeling with PyMOL
- Saving transformed coordinates
- Translate/Rotate objects
- Moving one segment relative to the rest
- Split states to objects
- Altering secondary structures
- Altering van der Waals radii
- Altering atom coordinates
- Deleting bonds
- Converting D- to L- amino acids
- Adding disulfide bonds
- Adding hydrogen bonds
- Protonating ligands
- Superposition of two molecules
Saving with transformed coordinates
Here is
a
(invoke it with 'run save_transformed.py' and type the new
save_transformed.py command thereafter).
Paulo Martel
Translate or rotate individual objects
There is a "translate" function similar to "rotate", the docs for these don't exist yet, because the implementation isn't finished. However, feel free to use them in the following forms:
translate vector,object-name,state
rotate axis,angle,object-name,state
Warren DeLano
Moving one segment relative to the rest
This means moving two parts of one
object into different directions. The easiest way to do this is to
split the objects and then use the rotate command.
EXAMPLE:
Warren DeLano
Split states to objects
There is also a new command in the 0.95 series:
which will spread a PDB "biological unit" (or any multi-state object -- including SD files) over a series of independent objects. This makes it possible to interact with such objects more naturally than with "all_states = 1".
Warren DeLano
Altering secondary structures:
Examples:
alter A/10:34/, ss='H'
alter A/35:40/, ss='L'
alter A/41:60/, ss='S'
Altering van der Waals radii
Example:
alter (elem Fe),vdw=1.8
rebuild
(The value for Fe is wrecked in PyMOL at the moment, so running the above line might be a good idea).
Warren DeLano
Altering atom coordinates
Example:
alter_state 1,(pdb1cse),x=x-10.0
The latter section can contain formulae involving at least the xyz coordinates, lots of constants and the (+-*/) operators.
Deleting bonds
Select the bond using Ctrl-right-click, then either
unbond pk1,pk2
or hit Ctrl-D.
Warren DeLano
Converting D- to L- amino acids
The inversion function was changed in version 0.95 to take advantage of multiple picked atoms. To invert a center, Ctrl-middle-click to pick the center atom as pk1 and two stationary atoms as pk2 and pk3. Then type Ctrl-E to invert.
Warren DeLano
Adding disulfide bonds
You can use the "bond" command to attach them:
bond 24/sg,26/sg
bond 56/sg,99/sg
unpick
(unpick will hide the bond baton
which gets displayed.)
Additionally, the residue names can be changed for bonded
cysteines:
alter cys/,name='CYX'
or for specific residues
alter 24+26+56+99/,name='CYX'
Warren DeLano
Adding hydrogen bonds
Regarding H-bonds. There isn't a built-in function yet, but you can show H-bonds between two objects using atom selections so long as hydrogens are present in both molecules. If you don't have hydrogens, you can use h_add on the proteins or provide ligands with valence information and then use h_add.
Two examples are below. For clarity, they draw dashes between the heavy atoms and hide the hydrogens.
EXAMPLE
1:
EXAMPLE
2:
There is also a script drawing nice
hydrogen bonds from
Warren DeLano
Protonating ligands
If your ligands come in with valid
valencies and formal charges, PyMOL's h_add command can protonate
ligands. (NOTE that there is a minor technical hiccup with SD-files
which are loaded by default as immutable "discrete" objects.)
Suffice it to say that in order to make changes to the chemical
structure, an object must be loaded with the "discrete" flag set to
zero.
Unfortunately, much of the molecular editing stuff remains to be
documented. Here's an example sequence, but I'm not sure it will
help to much...as indicated in the manual, this is immature
functionality with some major gaps. Attach in particular is very
limited...
# show valences
set valence=0.05
# load cysteine fragment
fragment cys
# remove hydrogens
remove (hydro)
# edit gamma S
edit cys////sg
# add hydrogen
attach H,1,1
# add planer, trivalent nitrogen onto C terminus
edit cys////C
attach N,3,3
# edit that nitrogen
edit (elem N and neighbor cys////C)
# attach a tetrahedral methyl (note random position)
attach C,4,4
# here's an example of adding a whole residue from the library
edit cys////N
editor.attach_amino_acid("pk1","ace")
# now restore missing hydrogens (note that the names are off...)
h_add
Warren DeLano
Superposition of two molecules
Using pair_fit requires that you specify a set of paired atoms in each structure. Fortunately, you no longer have to specify each pair separately, so long as the ordering is the same in each selection (almost always true).
pair_fit ( trna10 and resid 10:15 and name P ), ( ref4 and resid 10:15 and
name P )
Another example:
pair_fit prot1///11-26/CA, prot2///34-49/CA
would superimpose prot1 on prot2 using C-alphas from residues 11-26 in prot1 and 34-49 in prot2.
Movies with PyMOL
Encoding video files
Assuming you have created a lot of .png files and would like to encode a .mpeg, .avi or other video format, a number of solutions are known:
- The DiVX encoder
using
mplayer/mencoder? There's binaries for Unix and Windows. It makes rather nice compression on a 800x600 (probably higher). It doesn't take too long to produce the nicer quailty movies, but much longer than simply
·mencoder "mf://*.png" -mf type=png:fps=18 -ovc lavc -o output.avi
·Another good program for converting
images into movies of different formats
is
·TMPGEnc
·The
latest
·
·treats as full-screen (due it's wacky metrics).
·Using this codec, a recent 24-second movie consumed only 4.5 MB of space,
·but looks much better than a 640x480 Cinepak-based movie with a file size of
·around ~40 MB.
·A freeware jiffy to convert png
files to an animation
is
·which proved to be very useful:
http://www.fmrib.ox.ac.uk/~yongyue/imgcondl.html