Here`s a rough macro that I cooked up to extract peak intensities from a series of EXSY zz-exchange spectra.
It illustrates some ways of navigating the data structure from peaks to assignments and constructing a dictionary for further use fitting the data.
It would be nice to have proper NMRSeries support so that the spectrum names don`t have to be set up for the mixing times.
Comments & suggestions for improvement welcome.
Python
- # user to take care of selecting peaks at all mixing times only from the residues they want
- # auto peaks assigned to different chains to to indicate states
- # cross peaks assigned to one atom from each of the (normally two) chains
-
- from collections import OrderedDict
-
- EXSYdata = []
- mixes = set() # will be an unordered set containing each mixing time once
- #transfers = set() # will be an unordered set containing each peak type once
- for peak in current.peaks:
- #print(peak.peakList.spectrum.name, \
- # peak.dimensionNmrAtoms[0][0].nmrResidue.nmrChain.name, \
- # peak.dimensionNmrAtoms[0][0].nmrResidue.sequenceCode, \
- # peak.dimensionNmrAtoms[1][0].nmrResidue.nmrChain.name, \
- # peak.dimensionNmrAtoms[1][0].nmrResidue.sequenceCode, \
- # peak.height)
- spectrum = peak.peakList.spectrum.name
- #spectra should be named EXSY[0-9]+ where the digits represent the mixing time in ms
- if spectrum[:4] == `EXSY`:
- mix = (float(spectrum[4:])/1000)
- toChain = peak.dimensionNmrAtoms[0][0].nmrResidue.nmrChain.name
- toResid = peak.dimensionNmrAtoms[0][0].nmrResidue.sequenceCode
- fromChain = peak.dimensionNmrAtoms[1][0].nmrResidue.nmrChain.name
- fromResid = peak.dimensionNmrAtoms[1][0].nmrResidue.sequenceCode
- #should test that toResid and fromResid are the same!
- #print(fromChain + toChain+`_`+toResid, mix, peak.height)
- EXSYdata.append([fromChain + toChain+`_`+toResid, mix, peak.height])
- mixes.add(mix)
- #transfers.add(fromChain + toChain+`_`+toResid)
-
- print(sorted(mixes))
- #print(sorted(transfers))
- #print(sorted(EXSYdata))
-
- EXSYdict = OrderedDict()
- for trf, mix, intens in (sorted(EXSYdata)):
- #print(trf, mix, intens)
- EXSYdict.setdefault(trf, []).append(intens) # adds trf to keys if neccessary and appends intens to list of values
-
- print(EXSYdict)
-