This is a read-only mirror of pymolwiki.org

Expand To Surface

From PyMOL Wiki
Jump to navigation Jump to search

Overview

This little script will color the surface of your protein the same color as the b-factors from the alpha carbons of each amino acid. This script is useful when you want to color a protein by the b-factor column, but all you have in the b-factor for each alpha carbon. If you try to color a surface based only on the alpha carbon b-factors, then the surface isn't rendered as you typically want.

Note: This script, once run in PyMOL, is called e2s. See examples, below.

Example

# in PyMOL type the following

# fetch 1cll
fetch 1cll

# load your b-factor column; for "1cll" you can simulate fake data
# by writing 144 random integers to /tmp/bb.  If you have some real
# data, then put that there.  1 row for each alpha carbon.
f = open('/tmp/bb', 'r').readlines();

# alter the alpha carbon coords
alter *,b=0
alter n. CA, b=f.pop(0)

# color the surface
e2s 1cll

You can make fake data in a shell by quickly executing:

# in a BASH shell, type the following

for ((i=0; i<144; i++)); do echo $RANDOM.$RANDOM >> /tmp/bb; done

The Code

##########################################################
#
# Expand_to_surface (e2s): Expands alpha-carbon-only 
# b-factor coloring to an entire surface of the protein
# of your choice.
#
# AUTHOR: Jason Vertrees -- Python code; Warren DeLano,
#         the original code.
#
# COPYRIGHT: BSDL.  Feel free to use it.
#
# DATE: 2007-12-03
#
##########################################################
from pymol import cmd
def e2s(sel):
        """
        e2s: Expand to surface

        e2s will color a surface based upon the b-factors
        from the alpha carbons in your selection.

        usage: e2s protName
        """

        cmd.create("ca_obj", sel + " and n. CA" )
        cmd.ramp_new("ramp_obj", "ca_obj", [0, 10], [-1, -1, 0] );
        cmd.set("surface_color", "ramp_obj", sel )

cmd.extend("e2s", e2s);

See Also