Set up Asn/Gln side-chain NH2 groups

What does the Macro do?

This macro will automatically group your Asn/Gln side-chain peak pairs into the same NmrResidue and rename the NmrAtom names and residue type.
Use this after setting up your backbone NH groups with Assign / Set up NmrAtoms (shortcut SN).

How to run the Macro

Simply select the two peaks you want to group together and run the macro, either from the Python Console or the Macro Editor (or you could link it to a keyboard shortcut).

Code

# A macro to automatically group two NH2 peaks in an HSQC into the same NmrResidue,
# change the NmrAtom names to side chain names and change the NmrResidue type.
# It assumes that the peaks have previously been assigned using Assign / Setup NmrResidues (SN)
#
# To run:
# Select two NH peaks that belong to one NH2 group in an HSQC spectrum and run the macro.
#
# Options:
# If you wish, you can change the new Residue type or Atom names in the top part of the marcro.
#
# Copyright 2024 Vicky Higman
# This code is distributed using the MIT licence. See http://opensource.org/license/mit for details.
########################################################################
from ccpn.core.lib.ContextManagers import undoBlock
 
HDim = 0
NDim = 1
peak1 = current.peaks[0]
peak2 = current.peaks[1]
resType = `ASN/GLN`
NAtom = `ND/E1`
H1Atom = `HD/E21`
H2Atom = `HD/E22`
 
with undoBlock():
    peak1NNmrAtom = peak1.assignmentsByDimensions[NDim][0]
    peak1HNmrAtom = peak1.assignmentsByDimensions[HDim][0]
    peak1NmrRes = peak1NNmrAtom.nmrResidue    
    peak2NmrRes = peak2.assignmentsByDimensions[NDim][0].nmrResidue
 
    peak1NNmrAtom.rename(value = NAtom)
    peak1HNmrAtom.rename(value = H1Atom)
    peak1NmrRes.residueType = resType
 
    peak2NmrRes.delete()
 
    peak2HNmrAtom = peak1NmrRes.fetchNmrAtom(name=H2Atom)
    peak2.assignDimension(axisCode=`H`, value = peak2HNmrAtom)

Credits and References

Vicky Higman, CCPN Team, University of Leicester