Transferring Assignment

Hi Nasreen,

to get the peak heights as well simply insert the line

targetSpectrum.getHeight((atm1.chemicalShifts[0].value, atm2.chemicalShifts[0].value))

at the end of the script.

In total the script will now be:

Python
  1. #Macro to create a CC peak list from a chemical shift list
  2.  
  3. from ccpn.core.lib.ContextManagers import undoBlock
  4.  
  5. # specify NmrChain associated with the imported chemical shifts
  6. nmrChain = project.getByPid(`NC:@2`)
  7.  
  8. # specify CC spectrum
  9. targetSpectrum = project.getByPid(`SP:sh3_uni_pdsd100`)
  10. # find carbon dimensions
  11. carbonAxes= [axis for axis in targetSpectrum.axisCodes if axis.startswith(`C`)]
  12.  
  13.  
  14. def makePairs(theList):
  15. "make pairs from the elements of theList (excluding same-item pairs); return a list of tuples"
  16. result = []
  17. for idx, item1 in enumerate(theList):
  18. for item2 in theList[idx+1:]:
  19. result.append( (item1, item2) )
  20. result.append( (item2, item1) )
  21. return result
  22.  
  23.  
  24. with undoBlock():
  25. # create new peaklist for specified spectrum
  26. peakList = targetSpectrum.newPeakList(isSimulated=True)
  27. print(`created:`, peakList)
  28.  
  29. # Loop through each NmrResidue in the NmrChain
  30. for nmrRes in nmrChain.nmrResidues:
  31. # Loop through each NmrAtom, selecting each carbon
  32. atomList = [nmrAtom for nmrAtom in nmrRes.nmrAtoms if nmrAtom.name.startswith(`C`)]
  33.  
  34. # create all combinations of C-C peaks
  35. pairs = makePairs(atomList)
  36. for atm1, atm2 in pairs:
  37. peak = peakList.newPeak(ppmPositions=(atm1.chemicalShifts[0].value, atm2.chemicalShifts[0].value))
  38. peak.assignDimension(carbonAxes[0], atm1)
  39. peak.assignDimension(carbonAxes[1], atm2)
  40. peak.height = targetSpectrum.getHeight((atm1.chemicalShifts[0].value, atm2.chemicalShifts[0].value))




Vicky