Here is a macro to copy assignments from one peak to one or more others. This would be useful if you have two spectra recorded under different conditions where some or all of the peaks have moved (e.g with/without ligand, different temperature, buffer etc.) and want to copy the assignments from one spectrum to another.
Select one (fully or partially) assigned peak and one or more unassigned peaks. The assignments from the assigned peak will be copied to the unassigned peaks. This will work both within and between peak lists, spectra and spectrum displays.
The macro works in a similar way to the V2 `Propagate Assignment` function. However, note that the peak dimensions are matched by their Axis Codes and there is no checking of chemical shifts. This is deliberate, so that you can copy assignments in situations where the chemical shift has changed. It will only work for peaks belonging to spectra with the same number/type of axes (e.g. HN and HN, HNC and HNC etc.). Also, your dimensions will be swapped if you apply it to two peaks on opposite sides of the diagonal of a homonuclear spectrum.
- # Macro to copy the peak assignments from one peak to another
-
- from ccpn.core.lib.ContextManagers import undoBlock
-
- with undoBlock():
- assignmentsToCopy = None
- # Check only one peak is fully or partially assigned and get the assignments to copy
- for peak in current.peaks:
- if len(peak.assignments) != 0 and assignmentsToCopy is None:
- assignmentsToCopy = peak.assignmentsByDimensions
- elif len(peak.assignments) != 0 and assignmentsToCopy is not None:
- print("You have more than one assigned peak.")
- assignmentsToCopy = None
-
- if assignmentsToCopy is not None:
- for peak in current.peaks:
- if len(peak.assignments) == 0: # only copy assignments to unassigned peaks
- peak.dimensionNmrAtoms = assignmentsToCopy
- else:
- print("Please make sure you have one assigned peak.")
Any problems, let me know.
Vicky