IPyMOL example

Start PyMOL XML-RPC server


In [1]:
from ipymol import viewer as pymol
pymol.start()

Fetch PDB


In [2]:
pymol.fetch('4MBS')


Out[2]:
'4MBS'

Remove chain A and solvent


In [3]:
pymol.remove('chain A')
pymol.remove('solvent')

Draw ligand as ball+stick model


In [4]:
pymol.select('ligand', 'resn MRV')
pymol.show_as('sticks', 'ligand')
pymol.show('spheres', 'ligand')
pymol.set('stick_radius', '.07', 'ligand')
pymol.set('sphere_scale', '.25', 'ligand')
pymol.set('sphere_quality', '4', 'ligand')

Draw protein as spheres


In [5]:
pymol.show_as('spheres', '4MBS and not ligand')
pymol.set('sphere_transparency', '.2', '4MBS and not ligand')

Orient camera around the ligand


In [6]:
pymol.center('ligand')
pymol.orient('ligand')
pymol.zoom('ligand', '10')
pymol.do('rotate z,180; rotate x,90;')
pymol.center('ligand')
pymol.clip('near', '5')

Set colors and lighting


In [7]:
pymol.bg_color('white')
pymol.do('util.cbaw;')
pymol.color('slate', 'elem N')
pymol.set('light_count', '8')
pymol.set('spec_count', '1')
pymol.set('shininess', '10')
pymol.set('specular', '0.25')
pymol.set('ambient', '0')
pymol.set('direct', '0')
pymol.set('reflect', '1.5')
pymol.set('ray_shadow_decay_factor', '0.3')
pymol.set('ray_shadow_decay_range', '1')
pymol.unset('depth_cue')


# Ligand specific
pymol.color('black', 'elem C and ligand')
pymol.set('stick_color', 'white')

Raytrace


In [8]:
pymol.ray()

Display image


In [9]:
pymol.display()


Out[9]: