I’m aware that the algorithm is very inefficient, though we won’t be fixing this until we completely overhaul the simulated Peak List creation.
But I do have an old macro for making peaks in CC spectra which is a bit more efficient. I’ve added a couple of lines to removes any of the aliased peaks (i.e. ones that are out of bounds of the spectrum if you have cropped it).
I’ve also added some code which would allow you to restrict the peaks to particular atomNames if you wish (uncomment lines 13 and 22 and amend the atomList as appropriate. Obviously change the NmrChain and peakList PIDs near the top of the macro. One massive proviso (and part of the reason I didn’t mention this macro before, is that it will simply use the first ChemicalShiftList for the NmrAtoms in question). I would need to modify the macro further so you can specify the ChemicalShiftList of your choice. Will try and do that tomorrow.
Here is the code:
#Macro to create a CC peak list from a chemical shift list
from ccpn.core.lib.ContextManagers import undoBlock
# specify NmrChain associated with the imported chemical shifts
nmrChain = get('NC:A')
# specify CC PeakList to place the peak into
peakList = get('PL:sh3_uni_pdsd100.1')
# find carbon dimensions
carbonAxes = [axis for axis in peakList.spectrum.axisCodes if axis.startswith('C')]
# List of atoms to use (optional - uncomment lines 13 and 22 if you want to use this feature)
# atomList = ['CA', 'CB', 'C']
def makePairs(theList):
"make pairs from the elements of theList (excluding same-item pairs); return a list of tuples"
result = []
for idx, item1 in enumerate(theList):
for item2 in theList[idx+1:]:
# uncomment lines 13 and 22 if you want to use atom pairs from the atomList only
# if item1.name in atomList and item2.name in atomList:
result.append( (item1, item2) )
result.append( (item2, item1) )
return result
with undoBlock():
# Loop through each NmrResidue in the NmrChain
for nmrRes in nmrChain.nmrResidues:
# Loop through each NmrAtom, selecting each carbon
naList = [nmrAtom for nmrAtom in nmrRes.nmrAtoms if nmrAtom.name.startswith('C')]
# create all combinations of C-C peaks
pairs = makePairs(naList)
for na1, na2 in pairs:
peak = peakList.newPeak(ppmPositions=(na1.chemicalShifts[0].value, na2.chemicalShifts[0].value))
if peak.aliasing != (0,0):
peak.delete()
else:
peak.assignDimension(carbonAxes[0], na1)
peak.assignDimension(carbonAxes[1], na2)
peak.height = peakList.spectrum.getHeight((na1.chemicalShifts[0].value, na2.chemicalShifts[0].value))