# -----------------------------------------------------------------------------
# Tested in Chimera version 1.2510, May 13, 2008.
# Will not work with earlier Chimera versions.
#
def color_surface(surf, volume):

    from SurfaceColor import color_surface, Volume_Color, Color_Map
    vc = Volume_Color()
    vc.set_volume(volume)
    data_values = (-10, 0, 10)
    colors = [(1,0,0,0.9),        # Red,green,blue,opacity
              (1,1,1,0.5),
              (0,0,1,.9)]
    vc.set_colormap(Color_Map(data_values, colors))
    color_surface(surf, vc, caps_only = False, auto_update = False)

# -----------------------------------------------------------------------------
# Open PDB, make surface, open volume
#
pdb_path = '/tmp/1sx3_chainA.pdb'
es_path = '/tmp/1sx3_chainA.dx'

from chimera import runCommand
runCommand('open #0 %s' % pdb_path)
runCommand('surf #0')
runCommand('open #1 %s' % es_path)

# Color surface
from chimera import openModels as om, MSMSModel
surf = om.list(id = 0, modelTypes = [MSMSModel])[0]
vol = om.list(id = 1)[0]
color_surface(surf, vol)
