Thank you for the script Andreas, it worked fine. Now, is there any way to define wich objet is going to be colored? I want to use different color hues for two different objects.

Thank you,

Mario Sanches

Andreas Henschel wrote:

Hi Mario,

you can define new colors wit the set_color command.
below are two python functions that can define ranges,
one using HSV color space, one RGB. The former is a derivite
of  a script earlier posetd by Robert L. Campbell on the wiki.
Hope that helps.

Cheers, Andreas

def hueSpectrum(hue1=0.0, hue2=0.2, nbins=10, sat=1., value=1.):
   ## by default creates 10 shades of red
   ## Derived from
   ## Author     Robert L. Campbell, see pymol wiki
   stepsize = (hue1  - hue2) / nbins
   for j in range(nbins):
       # for the selection
       colorName = "hueSpectrum%02d"%(j)
       hsv = (hue1 - stepsize * float(j), sat, value)
       #convert to rgb and append to color list
       rgb = colorsys.hsv_to_rgb(hsv[0],hsv[1],hsv[2])
       cmd.set_color(colorName, rgb)
   return colorNames

def hueSpectrum2(r=1., g = .0, b = .0, shades=10, shadeSpec=0.4):
   r0 = max(r - shadeSpec/2, 0.0)
   g0 = max(g - shadeSpec/2, 0.0)
   b0 = max(b - shadeSpec/2, 0.0)
   stepsize = shadeSpec/(shades-1.)
   for j in range(shades):
       # for the selection
       colorName = "hueSpectrum%02d"%(j)
       r0 = min(r0+stepsize, 1.0)
       g0 = min(g0+stepsize, 1.0)
       b0 = min(b0+stepsize, 1.0)
       cmd.set_color(colorName, (r0, g0, b0))
   return colorNames

def colorSpec(residue1, residue2, shades=10):
   ## careful: assumes consecutive resi's ...
   resiPerColor = abs(residue1-residue2)/shades
   for j in range(residue2-residue1):
color = shades*j/(residue2-residue1) ## use only generated shades. Careful: don't exceed!
       cmd.color("hueSpectrum%02d" % color, "resi %s" %(residue1 + j) )

## usage: cmd.load("/group/bioinf/Data/PDBLinks/1god.pdb") ## change path"cartoon")
cmd.color("white", "1god")
#hueSpectrum(0.5, 0.7) ## dark blue to cyan, looks cool, too!
hueSpectrum2() ## reddish
colorSpec(89, 109)

Mario Sanches wrote:

I am trying to color a structure with a ribbon like feature but not going from blue to red, but instead, using differente blue hues (or red hues, etc). Is that possible?

Mario Sanches
Laboratório Nacional de Luz Síncrotron
Cristalografia e Espectroscopia de Biomoléculas
Tel: +55 19 3512 1109

Reply via email to