Manipulating chemical shifts

Hi,

I am trying to extract the chemicalShift uniqueId in a macro.
I thought something like:
cs = get(CS:default.A.4.LYS.H)
cs.uniqueId
should do the job. However, when I define the CS as above I get an empty string in return.
If I do
cs = get(CS:default.10)
cs.uniqueId
I get 10 as expected.
Ultimately I would like to extract the uniqueId for a chemical shift for an atom in a peak. I thought I can use
peak.getByDimensions
somehow but I am getting stuck.
In summary what I am trying to do it:

  1. read in a peak from a peaklist
  2. get the uniqueId for chemical shift of the assignednmrAtom in each dimension.

Thanks,
Józef

Hi Józef,

this is a little convoluted (peaks have multiple dimensions, each of which can have multiple assignments, and the NmrAtoms can have ChemicalShifts in multiple ChemicalShiftLists!) but the following code should give you all the information you want (here I’m just printing it out so you can check it is what you are were hoping for before you go on to use the objects further):

pl = get('PL:hsqc.1')
for pk in pl.peaks:
    for dim in pk.spectrum.dimensions:
        for i in pk.getByDimensions('assignments', [dim]):
            for na in i:
                 for cs in na.chemicalShifts:
                    if cs in pk.spectrum.chemicalShiftList.chemicalShifts:
                        print(pk,dim,na,cs,cs.uniqueId)

Vicky