OK, started having a hack at this myself, beginning to see the light.
Here is my feeble effort at a macro (setPeakHeightSelected) that will
recalculate the peak heights of selected peaks.
Next steps will be to operate on a whole peak list, add volumes etc. and
maybe think about refitting fully (though probably not for this
application).
Found a few problems with working with macros. The Add Macro window seems
relatively easy to confuse if you're modifying the underlying python and
trying to reload etc. Reload dosn't seem to update consitently (could be
something to do with intermediate oblect files I guess), and if you end up
with a macro loaded, whose underlying code has been removed, it becomes
unselectable (always producing a traceback with ApiError: could not find
function "macroName" in module "filename") and so you can't get rid of the
handle.
Is there a way of getting individual objects' handles easily without going
through the argServer? i.e. is there a way of getting say a single peak's
handle so that one could test/use a function like my setPeakHeight(peak)
in the python shell?
Brian
--
Dr. Brian O. Smith ---------------------- B.Smith at bio.gla.ac.uk
Division of Biochemistry & Molecular Biology,
Institute Biomedical & Life Sciences,
Joseph Black Building, University of Glasgow, Glasgow G12 8QQ, UK.
Tel: 0141 330 5167/6459 Fax: 0141 330 8640
from ccpnmr.analysis.PeakBasic import setManualPeakIntensity
def setPeakHeight(peak, intensityType='height'):
"""Descrn: Define a peak's height (for redefining from data)
Inputs:
Output: None
"""
spectrum = peak.peakList.dataSource
if (not spectrum.block_file):
return
height = peak.cPeak.getIntensity(spectrum.block_file)
peakIntensity = peak.findFirstPeakIntensity(intensityType=intensityType)
if peakIntensity:
if peakIntensity.value != height:
peakIntensity.setValue(height)
else:
method = getMethod(peak.root, task='find peak height', procedure='peak.cPeak.getIntensity')
Nmr.PeakIntensity(peak, intensityType=intensityType, value=height, method=method)
def setPeakHeightSelected(argServer=None, peaks=None):
"""Descrn: Determine a list of peaks' heights from the spectral data specified by its dataSource
Inputs:
Output: None
"""
if not peaks:
peaks = argServer.getCurrentPeaks()
# e.g. Assign all of an unassigned HSQC to different Hn and N resonances
assert argServer or peaks
for peak in peaks:
setPeakHeight(peak)
def setPeakHeightSelectedZero(argServer=None, peaks=None):
"""Descrn: set selected peak heights to 1.0 (for testing)
Inputs:
Output: None
"""
if not peaks:
peaks = argServer.getCurrentPeaks()
# e.g. Assign all of an unassigned HSQC to different Hn and N resonances
assert argServer or peaks
for peak in peaks:
setManualPeakIntensity(peak, value=0.0, intensityType='height')
|