Thanks Wayne, got it to work now. (Took out the try/except - which I
inherited from the analysis code, and there was one more import needed).
Will append the working code below for posterity.
I think a bunch of utilities like this would be good and some
macro-writing users should get together to see what we can achieve
maybe. Does anyone already have a set of such things (e.g. to set the
contour level for the whole set of spectra to the same value; even
better to be able to see what the contour level is set to across the
whole series) ? These things do not need to be cluttering up the contour
changer popup, but probably should be an extra tool specifically
thinking of titrations.
Anyhow so far analysis is proving really nice for having a quick look
see at a pH titration (with two sets of spectra: HSQC and histidine
LR-HSQC), with the spectra still left on the spectrometer. Nice.
Oh and before I poke around more: where is levelChanger set in the GUIs
(or is it?) ?
Cheers
Jeremy
Wayne Boucher wrote:
def raiseAllContoursMappedToWindow(argServer = None, windowPopup = None):
# this differs from the contourLevelsUp macro because it does it to ALL
the spectra mapped to window
# (I hope) so all points in titration stay in lock step, whether viewed
or not
from ccpnmr.analysis import Util
from ccpnmr.analysis.ExperimentBasic import changeSpectrumContourLevels
if argServer and not windowPopup:
windowPopup = argServer.getCurrentWindowPopup()
if windowPopup:
views = windowPopup.getSpectrumViews()
for view in views:
# try:
spectrum = view.dataSource
(baseLevel, numberLevels, levelChanger, changeMode) =
Util.getSpectrumLevelValues(spectrum)
if changeMode == 0:
if levelChanger <= 1:
continue
else:
if levelChanger <= 0:
continue
changeSpectrumContourLevels(spectrum, levelChanger, changeMode)
# except:
# print "Some error was raised, better check the macro"
> Hello,
>
> A couple of things. First you should check "if windowPopup" because
> otherwise it falls over (which is what happened when I ran the macro from
> the EditMacros dialog). (Complain and return "if not windowPopup".)
>
> Secondly, because of the windowPopup.contourLevelsUp() you are going to
> raise the visible spectra twice (when the rest of the code is working), so
> that if block should go.
>
Wayne Boucher wrote:
> Hello,
>
> A couple of things. First you should check "if windowPopup" because
> otherwise it falls over (which is what happened when I ran the macro from
> the EditMacros dialog). (Complain and return "if not windowPopup".)
>
> Secondly, because of the windowPopup.contourLevelsUp() you are going to
> raise the visible spectra twice (when the rest of the code is working), so
> that if block should go.
>
> Now the reason the rest of that code is not working is that you need to
> import Util. So
>
> from ccpnmr.analysis import Util
>
> Otherwise you are getting an exception (because it does not know what Util
> is) which is going down a black hole because of the try/except/pass.
>
> Regards, Wayne
>
> On Thu, 20 Sep 2007, Jeremy Craven wrote:
>
>
>> Hi
>>
>> I am looking at a titration and am trying to figure out how to keep
>> control of the contour level viewed in the spectra across the series. I
>> want a way to change the contour level on all of them in one fell swoop.
>>
>> I found the macro ContourLevelsUp ("e" or is it "r" ?)
>>
>> But that seems to only change it for the spectra that I happen to have
>> clicked "ON" onthe spectrum tabs at that moment.
>>
>> Am I missing something ?
>>
>> So I thought I would try to write my own (as a macro writing exercise as
>> well). My attempt is:
>>
>> def raiseAllContoursMappedToWindow(argServer = None, windowPopup = None):
>>
>> # this differs from the contourLevelsUp macro because it does it to ALL the spectra mapped to window
>>
>> # (I hope) so all points in titration stay in lock step, wheterh viewed or not
>>
>> print "-----"
>>
>> if argServer and not windowPopup:
>>
>> windowPopup = argServer.getCurrentWindowPopup()
>>
>> if windowPopup:
>>
>> windowPopup.contourLevelsUp()
>>
>> views = windowPopup.getSpectrumViews()
>>
>> for view in views:
>>
>> try:
>>
>> spectrum = view.dataSource
>>
>> (baseLevel, numberLevels, levelChanger, changeMode) = Util.getSpectrumLevelValues(spectrum)
>>
>> if changeMode == 0:
>>
>> if levelChanger <= 1:
>>
>> continue
>>
>> else:
>>
>> if levelChanger <= 0:
>>
>> continue
>>
>> changeSpectrumContourLevels(spectrum, levelChanger, changeMode)
>>
>> except:
>>
>> pass
>>
>>
>> Which is two functions cobbled together into one, and then I changed
>>
>> getActiveSpectrumViews
>>
>> to
>>
>> getSpectrumViews
>>
>> but it still only seems to change the levels of the clicked ON spectra.
>>
>> Can anyone help me ?
>>
>> Also is the "levelChanger" parameter set in one of the popups.
>>
>> Have lots more thoughts on this topic but will leave this email at that.
>>
>> Cheers
>>
>> Jeremy
>>
>> --
>> *********************************************************************************
>>
>> Dr C. Jeremy Craven
>> Department of Molecular Biology and Biotechnology
>> University of Sheffield,
>> Firth Court, Western Bank
>> S10 2TN Sheffield UK
>>
>> e-mail: [log in to unmask]
>> http://www.nmr.group.shef.ac.uk/CJC.html
>>
>> Phone: x24323
>> >From outside Sheffield: 0114 222 4323
>> >From outside UK: +44 114 2224323
>> Fax: 0114 272 2800
>>
>> *********************************************************************************
>>
>>
--
*********************************************************************************
Dr C. Jeremy Craven
Department of Molecular Biology and Biotechnology
University of Sheffield,
Firth Court, Western Bank
S10 2TN Sheffield UK
e-mail: [log in to unmask]
http://www.nmr.group.shef.ac.uk/CJC.html
Phone: x24323
From outside Sheffield: 0114 222 4323
From outside UK: +44 114 2224323
Fax: 0114 272 2800
*********************************************************************************
|