Swapping Ca and Cb in HNCACB (/HNCoCACB)

Hello,

If someone was silly enough to assign Ca and Cb peaks the wrong way around for an entire spectra (both my HNCACB and HNCoCACB), is there an easy way to swap them?

Best,
Jaz

Hi,

Save and archive your project before trying anything

Assuming that the assignments are the wrong way round for all your spectra where CA & CB are assigned, a fix is to swap the names of the NmrAtoms that carry the assignments.

You can do the following either in the python console or better by creating a new user macro with the macro editor, or by saving this as a plain text file with a .py extension and running it as a macro

for myNmrResidue in get(‘NC:A’).nmrResidues:
myCA=None
myCB=None
for myNmrAtom in myNmrResidue.nmrAtoms:
if (myNmrAtom.name == ‘CA’):
myCA=myNmrAtom
if (myNmrAtom.name == ‘CB’):
myCB=myNmrAtom
print(myNmrResidue, myCA, myCB)
if (myCA and myCB ):
myCA.name = ‘temp’
myCB.name = ‘CA’
myCA.name = ‘CB’

Assumptions:
your NmrChain is ‘A’ - change to ‘@-’ if you haven’t started linking yet
you haven’t got any NmrAtoms called ‘temp’

This would probably be nicer wrapped in a “with undoBock()” and some suppression of the output but seems to run quickly enough.

I hope that sorts your problem or gives you an idea of how to fix it yourself.

Formatting seems to have been flattened, so attempting to send it in picture form

Oh thank you so much! I’ll give that a go.

Jaz

Here is a code in a code block for copying and pasting:

for myNmrResidue in get(‘NC:A’).nmrResidues:
    myCA=None
    myCB=None
    for myNmrAtom in myNmrResidue.nmrAtoms:
        if (myNmrAtom.name == ‘CA’):
            myCA=myNmrAtom
        if (myNmrAtom.name == ‘CB’):
            myCB=myNmrAtom
    print(myNmrResidue, myCA, myCB)
    if (myCA and myCB ):
        myCA.name = ‘temp’
        myCB.name = ‘CA’
        myCA.name = ‘CB’

Also: if you run a macro in the Macro Editor is will now automatically wrap it in an Undo block, so you should generally be able to undo your macro again without having to make that explicit in the macro (but this is not the case if you run it direct from the Python Console with something like

%run -i "path/to/myMacro.py"

).

Vicky

Thank you both so much, it worked perfectly.

Jaz

1 Like