> Would it also be possible to include similar functionality for the
> colour of peaks and annotations. I prefer to use a black background but
> the peaks etc default to black. I know this is not difficult to change
> manually but it would save some time.
Full colour profiles as Wayne says are planned. In the mean time I have
attached a macro that you can use to change colours for contours, peak
annotations and the background.
However, you will have to edit the macro to put in your favourite RGB
colours for the different experiment types as you see fit. Note that the
colour selections go in a list so that you have different setups for
subsequent spectra of the same type.
T.
-------------------------------------------------------------------------------
Dr Tim Stevens Email: [log in to unmask]
Department of Biochemistry [log in to unmask]
University of Cambridge Phone: +44 1223 766022 (office)
80 Tennis Court Road +44 7816 338275 (mobile)
Old Addenbrooke's Site +44 1223 364613 (home)
Cambridge CB2 1GA WWWeb: http://www.bio.cam.ac.uk/~tjs23
United Kingdom http://www.pantonia.co.uk
-------------------------------------------------------------------------------
------ +NH3CH(CH(CH3)OH)C(O)NHCH(CH(CH3)CH2CH3)C(O)NHCH(CH2CH2SCH3)CO2- -------
-------------------------------------------------------------------------------
def setStandardColorProfiles(argServer):
from ccpnmr.analysis.Util import setSpectrumPosContourColor, setSpectrumNegContourColor
from ccpnmr.analysis.Util import getPeakListColor, setPeakListColor
background = 'black'
posColors = {
'H[N]' :[(200,100, 0),(200, 0, 0),(100,200, 0)],
'H[N[CA]]' :[(0 ,100,100),],
'H[N[co[CA]]]':[(200,200, 0),],
}
negColors = {
'H[N]' :[(0 , 0,128),],
'H[N[CA]]' :[(128, 0, 0),],
'H[N[co[CA]]]':[(128, 0,255),],
}
peakColors = {
'H[N]' :[(255,128, 0),(255, 0, 0),(128,255, 0)],
'H[N[CA]]' :[(0 ,128,128),],
'H[N[co[CA]]]':[(255,255, 0),],
}
project = argServer.getProject()
existingColors = project.colors
for window in project.spectrumWindows:
color = project.findFirstColor(name=background)
if (color):
window.background = color
expCount = {}
for experiment in project.nmrExperiments:
if experiment.refExperiment:
key = experiment.refExperiment.name
expCount[key] = expCount.get(key, -1) + 1
for spectrum in experiment.dataSources:
posColorList = posColors.get(key) or [(128, 128, 128),]
negColorList = negColors.get(key) or [(128, 128, 128),]
pksColorList = peakColors.get(key) or [(166, 166, 166),]
color256pos = posColorList[expCount[key] % len(posColorList)]
color256neg = negColorList[expCount[key] % len(negColorList)]
color256pks = pksColorList[expCount[key] % len(pksColorList)]
rgbPos = [x/255.0 for x in color256pos]
rgbNeg = [x/255.0 for x in color256neg]
rgbPks = [x/255.0 for x in color256pks]
hexPos = '#%02x%02x%02x' % color256pos
hexNeg = '#%02x%02x%02x' % color256neg
hexPks = '#%02x%02x%02x' % color256pks
existingColorPos = project.findFirstColor(name=hexPos)
existingColorNeg = project.findFirstColor(name=hexNeg)
existingColorPks = project.findFirstColor(name=hexPks)
if not existingColorPos:
for colorObj in existingColors:
rgb = [colorObj.r, colorObj.g, colorObj.b]
if rgb == rgbPos:
existingColorPos = colorObj
if not existingColorNeg:
for colorObj in existingColors:
rgb = [colorObj.r, colorObj.g, colorObj.b]
if rgb == rgbNeg:
existingColorNeg = colorObj
if not existingColorPks:
for colorObj in existingColors:
rgb = [colorObj.r, colorObj.g, colorObj.b]
if rgb == rgbPks:
existingColorPks = colorObj
if existingColorPos is None:
existingColorPos = project.newColor(name=hexPos, r=rgbPos[0], g=rgbPos[1], b=rgbPos[2])
if existingColorNeg is None:
existingColorNeg = project.newColor(name=hexNeg, r=rgbNeg[0], g=rgbNeg[1], b=rgbNeg[2])
if existingColorPks is None:
existingColorPks = project.newColor(name=hexPks, r=rgbPks[0], g=rgbPks[1], b=rgbPks[2])
setSpectrumNegContourColor(spectrum, existingColorNeg.name)
setSpectrumPosContourColor(spectrum, existingColorPos.name)
for peakList in spectrum.peakLists:
setPeakListColor(peakList, existingColorPks.name)
# deal with invisible peak lists
for experiment in project.nmrExperiments:
for spectrum in experiment.dataSources:
for peakList in spectrum.peakLists:
oName = getPeakListColor(peakList)
if background == 'black' and oName in ('#ffffff','#FFFFFF','black'):
setPeakListColor(peakList, 'white')
elif background == 'white' and oName in ('#000000','white'):
setPeakListColor(peakList, 'black')
|