Disclaimer: All the contributions displayed on this page were made by subscribers of the PyMOL mailing list at
sourceforge.net and Warren L. DeLano himself. Although i have checked most of the things listed here, i cannot guarantee
that everythings works well. I cannot even guarantee that i have understood everything written on this page. Please be cautious.
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.25You can change the two numbers above to fit preferences.
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 (radius of cylinder at edge of helix ribbon)In each case "length" refers to what some might call the width and "width" refers to what some might call the thickness.
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 surfaceIf the surface was already computed, then you'll also need to issue the command:
rebuild
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=0Which gives no shadows and only a few artifacts.
util.ray_shadows("heavy")
set two_sided_lighting=1
set backface_cull=0
Just go to the movies menue and click 'show all states'.
I think the following commands will do what you want:
select a, ///A/501/02 select b, ///B/229/N distance d, a, bThis 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
hide labels, dbtw, if you want to ray-trace the image, I find the dashes come out a bit fat - so I tend to use
set dash_gap, 0.5 set dash_radius, 0.1before the 'ray' command.
Try:
set selection_width, 6 set selection_width, 7
The pymol ray tracer can generate an image of any size.
ray height,width
ray 3000,2400 png filename.png
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...)
I typically use the make_pov.py script and
"run" it from pymol once to load the function, and then I do
"make_pov('povray.inp')" to create the povray.inp file.
Then I edit that file to insert some lines like:
fog {
distance 10
fog_type 2
fog_alt 10.
fog_offset -160.
up <0.,1.,.4>
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.
Try:
ray angle=-3 png image1.png ray angle=3 png image2.pngThis is superior to using the "turn" command because it also rotates the light source. That way shadows will look right.
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.
Create a python script (I call it axes.py):
# 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 = [ CYLINDER, 0., 0., 0., 10., 0., 0., 0.2, 1.0, 1.0, 1.0, 1.0, 0.0, 0., CYLINDER, 0., 0., 0., 0., 10., 0., 0.2, 1.0, 1.0, 1.0, 0., 1.0, 0., CYLINDER, 0., 0., 0., 0., 0., 10., 0.2, 1.0, 1.0, 1.0, 0., 0.0, 1.0, ] # 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')
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 = [ BEGIN, LINES, COLOR, 1.0, 0.0, 0.0, VERTEX, 0.0, 0.0, 0.0, VERTEX, 10.0, 0.0, 0.0, COLOR, 0.0, 1.0, 0.0, VERTEX, 0.0, 0.0, 0.0, VERTEX, 0.0, 10.0, 0.0, COLOR, 0.0, 0.0, 1.0, VERTEX, 0.0, 0.0, 0.0, VERTEX, 0.0, 0.0, 10.0, END, ]
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)
You could use the cmd.rotate and cmd.translate to position the labels,
but it is likely to be somewhat painful. If I'm not mistaken, the
rotation will always be about and axis through the origin and so you may
need to translate the label into the correct position.
Thus if you have your label in an object called 'text', you could do,
cmd.rotate(axis='x',angle=20.,object='text')and repeat this with different angles, until you get the orientation correct. Then use:
cmd.translate(vector='[1.,2.,3.]',object='text')(using the appropriate vector, of course!) to position the label.
Rubor : http://www.rubor.de
Post an Kristian Rother:
kristian.rother@charite.de
Last modified: Wed Apr 28 07:24:35 CEST 2004