Some Useful PyMOL Scripts

PyMOL + APBS Plugin
apbs_tools.py
This is a PyMOL plugin which lets you run APBS from within PyMOL.
To install it,
  1. Make sure you have PyMOL version 0.96 or higher.
  2. Make sure you have APBS version 4.0 or higher installed.
  3. At this point, try it out. Current versions of PyMOL usually ship with current versions of this plugin. If it doesn't work, continue on to the next step.
  4. Download a copy of apbs_tools.py and place it in $PYMOL_PATH/modules/pmg_tk/startup/.
  5. The PyMOL Plugins page has instructions for installing plugins on different operating systems, including OS X.
  6. You do not need any of the other plugins on this page to make this work
Now, you'll see "APBS Tools..." under the Plugins menu. This plugin allows fairly complete configuration of APBS, but it's very easy to set up a standard electrostatic potential calculation:
  1. Load your molecule into PyMOL
  2. Load the plugin
  3. Click on "Set grid"
  4. Click on "Run APBS"
  5. Use the plugin's "Visualization" tab to look at the results
This will use PyMOL's new ability to assign AMBER charges and radii. If you wish to use your own externally-generated PQR file, you can set that up on the plugin's main page.

The plugin should auto-detect the location of the APBS binary on your system, but you can set it manually under the "APBS Location" tab.

My plugin can calculate appropriate grid lengths and spacings. It ensures that the grid spacing is 0.5A or finer. If you have APBS's psize.py installed and you wish to use it, you can set that up on the plugin's "APBS Location" tab.

Finally, it's worth noting that the plugin's "Visualization" tab can be used for easy visualization of any electrostatic potential, not just things generated by APBS.

Main Tab Configuration Tab APBS Location Tab Temporary File Locations Tab Visualiztion Tab About Tab
PyMOL Rendering Plugin
rendering.py
This is a PyMOL plugin to aid in publication-quality rendering.
To install it,
  1. Make sure you have PyMOL version 0.99 or higher.
  2. Download a copy of rendering.py and place it in $PYMOL_PATH/modules/pmg_tk/startup/.
  3. The PyMOL Plugins page has instructions for installing plugins on different operating systems, including OS X.
Now, you'll see "Rendering..." under the Plugins menu. Enjoy.
Sidechain Checking Wizard
sidechain_check.py
The electron densities of Carbon, Nitrogen and Oxygen look basically the same to crystallographers. So, sometimes they get them confused in crystal structures. In particular, one often has to flip the orientation of the side chains in Asn or Gln. Also, this means that the Nitrogens may be placed incorrectly in His side chains. Similarly, since x-ray crystallographers cannot see Hydrogens, the crystal structure may not tell you which Nitrogen(s) in the His residue should be protonated. If you're going to use the crystal structure in, for example, a molecular dynamics calculation, it is critical that you get this stuff right. The easiest way to do this is to try out each possibility and see which one looks best with respect to Hydrogen bonding. Since PyMOL is so easy to script, I wrote a little bit of code to automate this process. Here's how you use it:
A word of warning on Histidine protonation: your His residues should be listed as HID, HIE or HIP rather than HIS. If you list them as HIS, we'll assume they're HIP.
  • Running it as a PyMOL wizard (recommended)
    1. Grab sidechain_check.py.
    2. Put it in pymol/modules/pymol/wizard
    3. Open up pymol/modules/pmg_tk/skins/normal/__init__.py
    4. Look for the 'Wizard' section .. you should see lines like this:
            self.menuBar.addmenuitem('Wizard', 'command', 'Sculpting',
                                     label='Sculpting',
                                     command = lambda s=self: s.cmd.do("_ wizard sculpting"))
      		  
    5. Add the following code:
            self.menuBar.addmenuitem('Wizard', 'command', 'Check Side-chains',
                                     label='Check Side-chains',
                                     command = lambda s=self: s.cmd.do("_ wizard sidechain_check"))
      		  
    6. Start PyMOL
    7. Load up a pdb file (e.g. 'load 1ra1.pdb').
    8. Use the wizard.
    9. All Asn, Gln and His residues will be shown in sticks.
    10. Carbons will be green, except on the residue that you're editing. There, they will be purple.
    11. Hydrogen bonds will be shown as dotted yellow lines
    12. Note that you can type 'next' 'flip' 'chp' 'mgzoom' and 'mgstart' from the PyMOL command line in addition to using the wizard buttons.
    13. Here's what it looks like in action: zoomed in
  • Running as a stand alone script
    1. Grab mgzoom.py, my little script. It may be out of date, and I recommend using the wizard version instead.
    2. Start up PyMOL
    3. Type 'run scripts/mgzoom.py' (or whatever you've called it)
    4. Load a pdb file (e.g. 'load 1ra1.pdb').
    5. Type 'mgstart' to begin
    6. Type 'next' to move to the next interesting residue. PyMOL will zoom in on an Asn, Gln or His, showing the current residue with purple Carbons and Hydrogen bonds as yellow dotted lines.
    7. If you're looking at a Histidine, typing 'chp' will cycle between the different protonation states (HIE, HID and HIP)
    8. When you're satisfied that you have the correct orientation/protonation state, type 'next' again to go to the next residue. Rinse. Repeat.
    9. If you like, you can zoom in on a particular residue by number using, e.g., 'mgzoom(141)' or 'mgz(141)'.
Various scripts launched from my .pymolrc
mg_pymol_utils.py
These are various utility functions that I set up via my .pymolrc. Save the file somewhere and launch it via the "run" command in your .pymolrc. Only tested on Linux, etc.
Electrostatics wizard
electrostatics.py
Note that this has been mostly superseded by the APBS plugin above.
This is a wizard I wrote to help examine electrostatics potentials in PyMOL. It's easy to use
  1. Grab electrostatics.py.
  2. Put it in pymol/modules/pymol/wizard
  3. Open up pymol/modules/pmg_tk/skins/normal/__init__.py
  4. Look for the 'Wizard' section .. you should see lines like this:
          self.menuBar.addmenuitem('Wizard', 'command', 'Sculpting',
                                   label='Sculpting',
                                   command = lambda s=self: s.cmd.do("_ wizard sculpting"))
    		  
  5. Add the following code:
          self.menuBar.addmenuitem('Wizard', 'command', 'Electrostatics',
                                   label='Electrostatics',
                                   command = lambda s=self: s.cmd.do("_ wizard electrostatics"))
    		  
  6. Start PyMOL
  7. Load up a molecule and a map and then start the Electrostatics wizard from the Wizard menu.

If you find this useful, or if you have any comments or suggestions, please email me.
Michael George Lerner

Valid HTML 4.01!

Last modified: Wed Aug 25 16:40:32 EDT 2004