Pretty images of molecules in PyMOL

I recently made the following graphic using PyMOL for use in the Kaggle competition that I recently launched:


The image shows paracetamol, with the opaque highlights showing different types of scalar coupling constants. It was a bit difficult to create, so I figured that other people might benefit from me detailing the procedure to reproduce the image.

Since paracetamol is so small, I manually drew it in Avogadro, followed by optimization with the default force field (the xyz structure file can be downloaded here). It was quite difficult to make the coloured highlights look nice, but I eventually managed by creating a new xyz file for each selection, where I only included the atoms that were to be highlighted. Since the selection radius in PyMOL depends on the van der waal radii, I changed all the elements to be hydrogens (xyz files for the green, orange and grey selection).

With the four xyz files, the procedure to load the molecules and set all the settings used are:

# Load molecule and dummies
# Ball and stick visualization
preset.ball_and_stick(selection=”all”, mode=1)
# Colour of carbons
color grey30, elem c
# Create surfaces
show surface, 1jnh
show surface, 2jch
show surface, 3jhh
# Surface colours
set surface_color, orange, 1jnh
set surface_color, forest, 2jch
set surface_color, grey, 3jhh
# Background colour
set bg_rgb, white
# Smooth edges. 1 is faster but less smooth.
set antialias, 3
# Disable “fog”
set depth_cue, off
# Black outline
set ray_trace_mode, 1
# Size of the highlights. See details below
set solvent_radius, 0.02500
# Turns off reflections. See details below.
set spec_reflect, 0
# Set surface quality. See details below.
set surface_quality, 2
# Surface renderer. 2 also looks cool.
set surface_type, 4
# Controls transparency of highlights.
set transparency, 0.7

The solvent radius was the bane of my existence as it changes with the surface quality and type. I ideally wanted to make the highlight tighter than in the image, but this was as close as I could get. Lower surface quality is tighter, but more jagged, so this was a nice compromise. If the solvent radius is set to lower values, the highlights suddenly become huge. If you make any changes to the surface quality or type, I would suggest setting the the surface radius to the default value of 1.4 and then work your way downwards.

I chose to turn off reflections in the image, as I found that it looked a bit weird with the highlights, although it might be worthwhile playing around with if you’re only visualizing molecules themselves. See here for more details.

Whenever you change settings you can type `ray` to see how the image will turn out. After you are happy with what you see, save your (600 dpi) image with

png fancy_image.png, ray=1, dpi=600

There’s also a lot of settings related to performance that might be worth adjusting if the ray tracing takes too long. Among others, cache_mode, hash_max and max_threads.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s