Difference between revisions of "User:Mglerner"

From PyMOLWiki
Jump to navigation Jump to search
 
Line 59: Line 59:
 
= APBS Plugin FAQ =
 
= APBS Plugin FAQ =
  
There is an issue with the freemol version of APBS shipped with PyMOL 1.2r2 for OS X.
+
== Visualizing multiple maps at once ==
  
== Leopard and Snow Leopard (10.5 and 10.6) ==
+
=== Method 1: all at once ===
 +
 
 +
If you're looking at, e.g., a protein-protein interface, it may be useful to map two different electrostatic potentials to two different PyMOL objects. Here's my overly-cautious recipe for doing that:
 +
 
 +
#. Load up PyMOL with one of your structures.
 +
#. Fire up the plugin. Click on "Choose Externally Generated PQR File" and point it at your PQR file.
 +
#. Click on the Temp File Locations tab and change the name of the temporary DX file to something meaningful, e.g. structure1.dx
 +
#. Set grid and Run APBS as normal.
 +
#. Close the plugin.
 +
#. Type "delete all"
 +
#. Load up the second structure.
 +
#. Repeat steps 2-4, changing the name to something like structure2.dx this time.
 +
 
 +
Now you have two correctly generated electrostatics potential maps (note: the reason I had you do things with one structure at a time loaded in PyMOL is so that you wouldn't have to fiddle around with the "Selection to use" section of the Main options tab). Use the load command to load up the other pqr file and the other dx map, then use the visualization panes as normal.
 +
 
 +
=== Method 2: side by side (from Jason) ===
 +
 
 +
I used this technique to look at two similar
 +
proteins side-by-side in PyMOL (see the 2nd image on
 +
http://www.pymolwiki.org/index.php/APBS).  The trick is to (1) use
 +
grid_mode and grid_slots; and (2) rename the maps as appropriate.
 +
It's not hard, but will take a couple minutes.  Here's how:
 +
 
 +
1. get two proteins; use whatever you like
 +
fetch 1rx1 1rx2, async=0
 +
 
 +
2. put them in the same frame of reference for grid mode
 +
align 1rx1, 1rx2
 +
 
 +
3. run APBS on protein #1, 1rx1
 +
Plugin > APBS Tools2 > ...
 +
Under "selection to use" type "(polymer) and 1rx1"
 +
 
 +
4. rename the map
 +
set_name pymol-generated, 1rx1_map
 +
 
 +
5. run APBS on protein 2, 1rx2; remove the waters
 +
Plugin > APBS Tools2
 +
Under "selection to use" type "(polymer) and 1rx2"
 +
 
 +
6. rename the map
 +
set_name pymol-generated, 1rx2_map
 +
 
 +
7. Now, using APBS show the surfaces make sure you choose 1rx1_map for 1rx1 and 1rx2_map for 1rx2; click "Update" if those map names are not present.
 +
...
 +
 
 +
8.  turn on grid mode
 +
set grid_mode
 +
 
 +
9. assign grid slots just to be sure the right maps and proteins are in the right places
 +
set grid_slot, 1, 1rx1
 +
set grid_slot, 1, 1rx1_map
 +
set grid_slot, 1, e_lvl_0_1
 +
 
 +
set grid_slot, 2, 1rx2
 +
set grid_slot, 2, 1rx2_map
 +
set grid_slot, 2, e_lvl_1_1
 +
 
 +
 
 +
== Saving default locations ==
 +
 
 +
=== Via environment variables ===
 +
 
 +
Set the environment variables APBS_BINARY_DIR, APBS_WEB_DIR, APBS_PSIZE_DIR, APBS_PDB2PQR_DIR, and/or TEMP, and things should work properly as long as you're using the most recent version of the plugin.
 +
 
 +
=== Via editing the plugin ===
 +
 
 +
Open up the python file associated with the plugin (typically apbsplugin.py), look for the section near the top labeled "Global config variables" and change the values from None to a string.
 +
 
 +
== There is an issue with the freemol version of APBS shipped with PyMOL 1.2r2 for OS X. ==
 +
 
 +
=== Leopard and Snow Leopard (10.5 and 10.6) ===
 
There are three fairly easy ways to resolve it
 
There are three fairly easy ways to resolve it
  
Line 84: Line 155:
 
The version of libgfortran above is covered by the GNU General Public License (GPL). A copy of the GPL may be found at [http://www.gnu.org/licenses/licenses.html], and the source may be obtained from MacPorts ([http://www.macports.org/]).
 
The version of libgfortran above is covered by the GNU General Public License (GPL). A copy of the GPL may be found at [http://www.gnu.org/licenses/licenses.html], and the source may be obtained from MacPorts ([http://www.macports.org/]).
  
== Tiger (10.4) ==
+
=== Tiger (10.4) ===
 
You'll need to install APBS yourself via MacPorts or via fink. Fink instructions may be found on the [[APBS]] page. Installation via MacPorts requires first installing MacPorts from [http://www.macports.org/] and then typing
 
You'll need to install APBS yourself via MacPorts or via fink. Fink instructions may be found on the [[APBS]] page. Installation via MacPorts requires first installing MacPorts from [http://www.macports.org/] and then typing
  

Latest revision as of 11:16, 15 February 2011

My name is Michael Lerner. I'm currently an IRTA postdoctoral fellow at NIH in the NHLBI's Laboratory of Computational Biology. Before that, I was a member of Heather Carlson's lab at the University of Michigan.

I wrote the PyMOL/APBS plugin.

-- Michael G. Lerner, PhD
m dot g dot lerner (_at-) gmail dot com

Check out a new pre-release version of the PyMOL-APBS plugin!

New Features

I've been working with Jason Vertrees on a new version of the PyMOL-APBS plugin and it's now ready for pre-release. There are several big advantages of the new version:

  • It's been tested modern OS X, Windows and Linux systems and fixes several long-standing bugs.
  • It allows you to call through to PDB2PQR directly.
  • It allows you to show the electric field lines.
  • It has two visualization panels to aid in showing multiple potential surfaces at once.
  • It defaults to using PDB2PQR for PQR generation and APBS's psize.py for grid sizing/spacing.

I've also upped the default maximum allowed memory since typical users have bigger and faster computers these days.

The main reason that I'm sending this out now is to get bug reports. I think it runs everywhere, but *please* let me know if you have problems with it. Once it's shown to be stable, it'll be included in the next PyMOL release.

A slightly longer list of changes is included below.

How to get it

There are two ways to get the new plugin

  • If you have subversion installed, you can always get the latest version via
svn co https://pymolapbsplugin.svn.sourceforge.net/svnroot/pymolapbsplugin/trunk/pymolapbsplugin

That should give you a file called apbsplugin.py

Once you have the plugin, you can install it via PyMOL's plugin installer: Plugin --> Manage Plugins --> Install

Note that the plugin will be installed as "APBS Tools2" so that you can continue to use your old version.

Longer feature list

  • The ability to call through directly to PDB2PQR
  • Visualization of field lines
  • More modern apbs input files
  • Two visualization panels. It's often quite useful to look at two different electrostatic potentials at once. It's also quite useful to look at electrostatic potentials mapped onto two different surfaces at once. Multiple visualization panels makes this a snap: just set up one surface on panel 1 and another surface on panel 2.
  • Defaults to using PDB2PQR for PQR generation and APBS's psize.py for grid sizing/spacing.
  • Fixes several bugs that caused crashes on both OS X and Linux systems
  • Increased maximum allowed memory
  • Switch from os.system to subprocess for running external programs
  • Deals with paths on Windows properly
  • Gives better diagnostic information so that PyMOL/APBS developers can find bugs more easily
  • Lots of internal code cleanup


APBS Plugin FAQ

Visualizing multiple maps at once

Method 1: all at once

If you're looking at, e.g., a protein-protein interface, it may be useful to map two different electrostatic potentials to two different PyMOL objects. Here's my overly-cautious recipe for doing that:

  1. . Load up PyMOL with one of your structures.
  2. . Fire up the plugin. Click on "Choose Externally Generated PQR File" and point it at your PQR file.
  3. . Click on the Temp File Locations tab and change the name of the temporary DX file to something meaningful, e.g. structure1.dx
  4. . Set grid and Run APBS as normal.
  5. . Close the plugin.
  6. . Type "delete all"
  7. . Load up the second structure.
  8. . Repeat steps 2-4, changing the name to something like structure2.dx this time.

Now you have two correctly generated electrostatics potential maps (note: the reason I had you do things with one structure at a time loaded in PyMOL is so that you wouldn't have to fiddle around with the "Selection to use" section of the Main options tab). Use the load command to load up the other pqr file and the other dx map, then use the visualization panes as normal.

Method 2: side by side (from Jason)

I used this technique to look at two similar proteins side-by-side in PyMOL (see the 2nd image on http://www.pymolwiki.org/index.php/APBS). The trick is to (1) use grid_mode and grid_slots; and (2) rename the maps as appropriate. It's not hard, but will take a couple minutes. Here's how:

1. get two proteins; use whatever you like fetch 1rx1 1rx2, async=0

2. put them in the same frame of reference for grid mode align 1rx1, 1rx2

3. run APBS on protein #1, 1rx1 Plugin > APBS Tools2 > ... Under "selection to use" type "(polymer) and 1rx1"

4. rename the map set_name pymol-generated, 1rx1_map

5. run APBS on protein 2, 1rx2; remove the waters Plugin > APBS Tools2 Under "selection to use" type "(polymer) and 1rx2"

6. rename the map set_name pymol-generated, 1rx2_map

7. Now, using APBS show the surfaces make sure you choose 1rx1_map for 1rx1 and 1rx2_map for 1rx2; click "Update" if those map names are not present. ...

8. turn on grid mode set grid_mode

9. assign grid slots just to be sure the right maps and proteins are in the right places set grid_slot, 1, 1rx1 set grid_slot, 1, 1rx1_map set grid_slot, 1, e_lvl_0_1

set grid_slot, 2, 1rx2 set grid_slot, 2, 1rx2_map set grid_slot, 2, e_lvl_1_1


Saving default locations

Via environment variables

Set the environment variables APBS_BINARY_DIR, APBS_WEB_DIR, APBS_PSIZE_DIR, APBS_PDB2PQR_DIR, and/or TEMP, and things should work properly as long as you're using the most recent version of the plugin.

Via editing the plugin

Open up the python file associated with the plugin (typically apbsplugin.py), look for the section near the top labeled "Global config variables" and change the values from None to a string.

There is an issue with the freemol version of APBS shipped with PyMOL 1.2r2 for OS X.

Leopard and Snow Leopard (10.5 and 10.6)

There are three fairly easy ways to resolve it

1. Download and install the most recent (post Dec. 1 2009) version of APBS from [1]. Then copy the apbs binary into the freemol directory (mv it to /Applications/PyMOLX11Hybrid.app/pymol/freemol/bin/apbs.exe, overwriting the version that comes installed with PyMOL).

2. Download File:Libgfortran.3.dylib.bz2, unzip it ("bunzip2 libgfortran.3.dylib.gz2") and move it to /usr/local/lib ("mv libgfortran.3.dylib /usr/local/lib" ... on some machines, you may need "sudo mv libgfortran.3.dylib /usr/local/lib").

bunzip2 libgfortran.3.dylib.gz2
mv libgfortran.3.dylib /usr/local/lib

3. Use macports to install gcc 4.4.2 and link the appropriate library ("ln -s /opt/local/lib/gcc44/libgfortran.3.dylib /usr/local/lib/libgfortran.3.dylib" ... on some machines, you may need "sudo ln -s /opt/local/lib/gcc44/libgfortran.3.dylib /usr/local/lib/libgfortran.3.dylib").

ln -s /opt/local/lib/gcc44/libgfortran.3.dylib /usr/local/lib/libgfortran.3.dylib
sudo ln -s /opt/local/lib/gcc44/libgfortran.3.dylib /usr/local/lib/libgfortran.3.dylib

If you're curious, the problem is that APBS is dynamically linked, but Apple does not provide FORTRAN libraries.

The version of libgfortran above is covered by the GNU General Public License (GPL). A copy of the GPL may be found at [2], and the source may be obtained from MacPorts ([3]).

Tiger (10.4)

You'll need to install APBS yourself via MacPorts or via fink. Fink instructions may be found on the APBS page. Installation via MacPorts requires first installing MacPorts from [4] and then typing

sudo port install apbs

from the command line. This process could easily take several hours on an older machine, as MacPorts will recompile gcc, gfortran, and several other packages along the way.

My open-source toolchain

  • PyMOL (visualization, system setup, etc)
  • Python (all scripting/automation tasks)
  • numpy (efficient numerical library)
  • scipy (including traits for simple GUIs)
  • matplotlib (2D and 3D plotting)
  • GROMACS (simulations)

I also make significant use of CHARMM and Amber.

My ~/.pymolrc runs this .py script

#!/usr/bin/env python
from pymol import cmd,stored
cmd.set('pdb_retain_ids',1)
cmd.set('retain_order',1)
import os
def gro(fnm,name=None):
    os.system("/usr/local/bin/editconf -f %s -o /tmp/tmp.pdb" % fnm)
    print "Just did","/usr/local/bin/editconf -f %s -o /tmp/tmp.pdb" % fnm
    if name is None:
        name = fnm[:-4]
    cmd.load("/tmp/tmp.pdb",name)
cmd.extend("gro",gro)

def splitseq(seq,size):
    """ Split up seq in pieces of size """
    return [seq[i:i+size] for i in range(0, len(seq), size)]

def getIDsInSel(sel, sorted=True, reversed=False):
    """
    PARAMETERS
        sel,
            The selection, object or group to iterate over
        sorted (boolean),
            Should the list be sorted?
        reversed (boolean)
            Should the list be reversed before returned?  (Combined
            with the above, you can return a decreasing-sorted list
            of names
 
    RETURNS
        list[] of strings, representing the object IDs desired.

    CREDITS
        This is a very slightly modified version of getNamesInSel 
        from http://pymolwiki.org/index.php/GetNamesInSel
    """
    stored.tempNames = set()
    cmd.iterate(sel, "stored.tempNames.add(ID)")
    rList = list(stored.tempNames)
 
    # if you want the list reversed or sorted,
    # uncomment the following lines
    if sorted:
        rList.sort()
    if reversed:
        rList.reverse()
    return rList
 
cmd.extend("getIDsInSel", getIDsInSel)
def togrp(selname,fname):
    '''Make a GROMACS index group from a selection'''
    f = file(fname,'w')
    f.write('[ %s ]\n'%selname)
    #   1    2    3    4    5    6    7    8    9   10   11   12   13   14   15 
    #7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 
    idxs = getIDsInSel(selname)
    for g in splitseq(idxs,15):
        line = ' '.join(['%4s'%i for i in g])
        line = line + '\n'
        f.write(line)
    f.write('\n')
    f.close()
cmd.extend('togrp',togrp)

def rayy(width=-1,height=-1,units='in',dpi=-1,**kwargs):
    """
    Slightly better version of the ray command.
    You can specify width and height in the units of your choice, e.g.

    rayy 3,2,units=in,dpi=300
    rayy 3in,2in
    rayy 1in, 2 cm, dpi=600

    Extra keyword arguments get passed on to the normal ray command.

    Units can be 'in' or 'cm'.

    For backwards compatibility, the conversion to dpi (or dots per
    centimeter) is only performed when dpi is specified.
    """
    if type(dpi) in [type('')]: dpi = int(dpi)
    in_per_cm = 0.393700787
    def todots(x,units,dpi):
        if type(x) in [type('')]:
            x = x.lower()
            if 'in' in x:   units = 'in'
            elif 'cm' in x: units = 'cm'
            x = float(x.replace(units,'').strip())
        if (dpi == -1):
            return x
        if units ==   'cm': x = x * in_per_cm
        elif units == 'in': pass
        else:               raise ValueError('Unknown units (%s)'%units)
        print '%s%s at %sdpi'%(x,units,dpi)
        return int(x * dpi)
    # How do we get current width/height of viewport? MainSceneGetSize perhaps
    # But it doesn't matter, as PyMOL will autoscale internally for us when given -1.
    try:
        width,height = todots(width,units,dpi),todots(height,units,dpi)
    except ValueError:
        print "Unknown units"
        return
    print 'width',width,'height',height
    cmd.ray(width=width,height=height,**kwargs)
cmd.extend('rayy',rayy)

To Do

  • Update the PyMOL/APBS plugin page


mglerner Tue Nov 17 14:46:42 EST 2009