Das Erwachen

Bioinformatics

"Python looks to me like the illegitimate spawn of C and BASIC, but then I used to program in 6502 machine code so what do I know ..." (Laurence Pearl, PyMOL user)

 
 

Tips for PyMOL from the PyMOL mailing list

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.

Kristian Rother

Available Subtopics:


Rendering molecules


 

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  (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.
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:

	select a, ///A/501/02
	select b, ///B/229/N
	distance d, a, b
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
	hide labels, d
btw, 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.1
before the 'ray' command.
Gareth Stockwell

  • Adjusting size of selection indicators

  •  

    Adjusting size of selection indicators

    Try:

    	set selection_width, 6
    	set selection_width, 7
    

    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 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.

    "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: http://www.povray.org/documentation/view/201/
    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):

    # 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')
    

    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 = [
       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,
       ]
    

    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 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.
    Not ideal, but if it is sufficiently important, it can be done!
    Robert Campbell

     
    Rubor : http://www.rubor.de
    Post an Kristian Rother: kristian.rother@charite.de

    Last modified: Wed Apr 28 07:24:35 CEST 2004