Re: [PyMOL] ribbon-like with one color
There are actually other spectrums built into the PyMOL. To use one of them, type spectrum palette=, selection= The list of built-in palettes are in cmd.py of the code. All seem to be multi color; so there are none that are just different shades of one color. _ Mark A. Saper, Ph.D. Associate Professor of Biological Chemistry Biophysics Research Division, University of Michigan Chemistry Building Room 3040 930 N University Ave Ann Arbor MI 48109-1055 U.S.A. sa...@umich.edu(734) 764-3353fax (734) 764-3323 http://www.biochem.med.umich.edu/biochem/research/profiles/saper.html Biophysics Interdepartmental Graduate Program: http://www.umich.edu/ ~biophys
Re: [PyMOL] ribbon-like with one color
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 color_b.py ## Author Robert L. Campbell, see pymol wiki colorNames=[] stepsize = (hue1 - hue2) / nbins for j in range(nbins): # for the selection colorName = "hueSpectrum%02d"%(j) colorNames.append(colorName) 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): colorNames=[] 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) colorNames.append(colorName) 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 cmd.as("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? Thank, -- Mario Sanches Laboratório Nacional de Luz Síncrotron Cristalografia e Espectroscopia de Biomoléculas Tel: +55 19 3512 1109
Re: [PyMOL] ribbon-like with one color
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 color_b.py ## Author Robert L. Campbell, see pymol wiki colorNames=[] stepsize = (hue1 - hue2) / nbins for j in range(nbins): # for the selection colorName = "hueSpectrum%02d"%(j) colorNames.append(colorName) 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): colorNames=[] 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) colorNames.append(colorName) 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 cmd.as("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? Thank, -- Andreas Henschel Bioinformatics Group TU Dresden Tatzberg 47-51 01307 Dresden, Germany Phone: +49 351 463 40063 EMail: a...@biotec.tu-dresden.de