Esempio n. 1
0
def midge(argServer=None):

    assert argServer

    (resonances, noesyPeaks,
     intensityFactors) = getCloudsResonanceList(argServer)

    # now make the noesy F2 assignments!
    print len(resonances), 'Resonances'
    print len(noesyPeaks), 'Noesy peaks'

    constraintList = optimiseRelaxation(resonances,
                                        noesyPeaks,
                                        intensityMax=36000000,
                                        intensityFactors=intensityFactors,
                                        tmix=60,
                                        sf=500,
                                        tcor=3,
                                        rleak=2)

    structure = argServer.getStructure()

    if structure:
        for constraint in constraintList.constraints:
            resonances = list(constraint, findFirstItem().resonances)

            atomSets1 = list(resonances[0].resonanceSet.atomSets)
            atomSets2 = list(resonances[1].resonanceSet.atomSets)
            distance = getAtomSetsDistance(atomSets1, atomSets2, structure)
            constraint.setDetails('Known Dist: %4.3f' % (distance))

    return constraintList
def within_distance_on_structure(structure, resonances, maxDist):
    '''Check whether the distance between two resonances
       is within the maximum allowed distance.

    '''
    atomSets1 = resonances[0].resonanceSet.atomSets
    atomSets2 = resonances[1].resonanceSet.atomSets
    distance = getAtomSetsDistance(atomSets1, atomSets2,
                                   structure, method='noe')
    if distance > maxDist:
        return False
    else:
        return True
Esempio n. 3
0
    def showResonancesConnection(self, resonance1, resonance2):

        if resonance1.resonanceSet and resonance2.resonanceSet:

            atomSets1 = resonance1.resonanceSet.atomSets
            atomSets2 = resonance2.resonanceSet.atomSets
            value = getAtomSetsDistance(atomSets1,
                                        atomSets2,
                                        self.structure,
                                        self.model,
                                        method=self.distMethod)

            color = self.getNoeColor(value)
            self.showAtomSetsConnection(atomSets1,
                                        atomSets2,
                                        value,
                                        color=color)
Esempio n. 4
0
    def setModel(self, model):

        if model is not self.model:
            self.model = model

            oldConn = self.connections[:]
            drawConn = self.showAtomSetsConnection

            self.connections = []
            self.structFrame.clearConnections()
            self.update()

            for atomSets1, atomSets2, cBond, color, value in oldConn:
                value = getAtomSetsDistance(atomSets1,
                                            atomSets2,
                                            self.structure,
                                            self.model,
                                            method=self.distMethod)

                drawConn(atomSets1, atomSets2, value, color)
Esempio n. 5
0
    def setDistMethod(self, name):

        distMethod = distanceMethods.get(name, 'noe')
        if distMethod != self.distMethod:
            self.distMethod = distMethod

            for i, data in enumerate(self.connections):
                atomSets1, atomSets2, cBond, oldColor, oldVal = data
                value = getAtomSetsDistance(atomSets1,
                                            atomSets2,
                                            self.structure,
                                            self.model,
                                            method=self.distMethod)

                color = self.getNoeColor(value)
                cBond.setColor(color)
                cBond.setAnnotation('%.3f' % value)

                self.connections[i][3] = color
                self.connections[i][4] = value

            self.updateAfter()
Esempio n. 6
0
    def cheatForTesting(self, atomSelection='H'):
        """ Makes a perfect cloud from a structure. """

        project = self.project
        structure = self.guiParent.argumentServer.getStructure()

        constraintStore = makeNmrConstraintStore(project)
        distConstraintList = NmrConstraint.DistanceConstraintList(
            constraintStore)

        chain = structure.findFirstCoodChain()
        structureGeneration.hydrogenResonances = []

        molSystem = structure.molSystem
        atomSets = []
        resonances = []
        i = 0
        for resonance in project.currentNmrProject.resonances:

            if resonance.isotopeCode == '1H':

                if resonance.resonanceSet:

                    atomSet = resonance.resonanceSet.findFirstAtomSet()
                    atom = atomSet.findFirstAtom()
                    seqId = atom.residue.seqId
                    if (seqId < 9) or (seqId > 78):
                        continue

                    if atom.residue.chain.molSystem is molSystem:

                        if atomSelection == 'methyl':
                            if len(atomSet.atoms) == 3:
                                if atom.residue.ccpCode not in ('Ala', 'Val',
                                                                'Ile', 'Leu',
                                                                'Thr', 'Met'):
                                    continue
                            elif atom.name != 'H':
                                continue

                        elif atomSelection == 'amide':
                            if atom.name != 'H':
                                continue

                        if atom.name == 'H':
                            resonance.name = 'HN'
                        else:
                            resonance.name = 'H'

                        resonances.append(resonance)
                        atomSets.append(list(resonance.resonanceSet.atomSets))
                        i += 1

        print "Found %d atomSets" % (len(atomSets))
        weight = 1
        adcWeight = 1
        constrDict = {}
        N = len(atomSets)
        for i in range(N - 1):
            atomSets0 = atomSets[i]
            residue0 = atomSets0[0].findFirstAtom().residue.seqId
            print "R", residue0

            for j in range(i + 1, N):
                if j == i:
                    continue
                atomSets1 = atomSets[j]

                dist = getAtomSetsDistance(atomSets0, atomSets1, structure)
                if not dist:
                    continue

                if dist < 5.5:
                    fixedResonance0 = getFixedResonance(
                        constraintStore, resonances[i])
                    fixedResonance1 = getFixedResonance(
                        constraintStore, resonances[j])
                    constrDict[i] = 1
                    constrDict[j] = 1
                    constraint = NmrConstraint.DistanceConstraint(
                        distConstraintList,
                        weight=weight,
                        targetValue=dist,
                        upperLimit=dist + (dist / 10),
                        lowerLimit=dist - (dist / 10),
                        error=dist / 5)
                    item = NmrConstraint.DistanceConstraintItem(
                        constraint,
                        resonances=[fixedResonance0, fixedResonance1])

                elif (atomSets1[0].findFirstAtom().name
                      == 'H') and (atomSets0[0].findFirstAtom().name
                                   == 'H') and (dist > 7):
                    #else:
                    fixedResonance0 = getFixedResonance(
                        constraintStore, resonances[i])
                    fixedResonance1 = getFixedResonance(
                        constraintStore, resonances[j])
                    constrDict[i] = 1
                    constrDict[j] = 1
                    constraint = NmrConstraint.DistanceConstraint(
                        distConstraintList,
                        weight=adcWeight,
                        targetValue=75,
                        upperLimit=175,
                        lowerLimit=5.0,
                        error=94.5)
                    item = NmrConstraint.DistanceConstraintItem(
                        constraint,
                        resonances=[fixedResonance0, fixedResonance1])

        return (distConstraintList, resonances)
Esempio n. 7
0
    def calculateDistances(self):

        # setup normalisation factor intensityMax

        # self.maxIter
        # what if failure ?

        resDict = {}
        for resonance in self.project.currentNmrProject.resonances:
            resDict[resonance.serial] = resonance

        self.resonances = self.origResonances
        intensityFactors = [1.0 for x in range(len(self.resonances))]

        # optimiseRelaxation will remove unconstrained resonances
        self.distanceConstraintList = optimiseRelaxation(
            self.resonances,
            self.noesyPeaks,
            intensityMax=self.maxIntens,
            intensityFactors=intensityFactors,
            tmix=self.mixTime,
            sf=self.specFreq,
            tcor=self.corrTime,
            rleak=self.leakRate)

        constrainSpinSystems(self.distanceConstraintList)
        # for testing calculate distances from structure overrides any resonances: uses assigned ones
        #(self.distanceConstraintList, self.resonances) = self.cheatForTesting()
        #self.antiDistConstraintList = self.distanceConstraintList
        protonNumbs = {'CH3': 3, 'Haro': 2, 'HN': 1, 'H': 1}

        PI = 3.1415926535897931
        GH = 2.6752e4
        HB = 1.05459e-27
        CONST = GH * GH * GH * GH * HB * HB
        tc = 1.0e-9 * self.corrTime
        wh = 2.0 * PI * self.specFreq * 1.0e6
        j0 = CONST * tc
        j1 = CONST * tc / (1.0 + wh * wh * tc * tc)
        j2 = CONST * tc / (1.0 + 4.0 * wh * wh * tc * tc)
        #jself = 6.0*j2 + 3.0*j1 + j0
        jcross = 6.0 * j2 - j0

        if self.distanceConstraintList:
            constraintStore = self.distanceConstraintList.nmrConstraintStore

            dict = {
                'HN': ['H'],
                'HN HA': ['H', 'HA', 'HA1', 'HA2'],
                'HN HA HB': ['H', 'HA', 'HA1', 'HA2', 'HB', 'HB2', 'HB3']
            }

            self.antiDistConstraintList = makeNoeAdcs(
                self.resonances,
                self.noesyPeakList.dataSource,
                constraintStore,
                allowedAtomTypes=dict[self.adcAtomTypes])

            if self.structure:

                N = len(self.resonances)
                sigmas = [[] for i in range(N)]
                for i in range(N):
                    sigmas[i] = [0.0 for j in range(N)]

                for constraint in self.distanceConstraintList.constraints:
                    resonances = list(constraint, findFirstItem().resonances)

                    ri = resDict[resonances[0].resonanceSerial]
                    rj = resDict[resonances[1].resonanceSerial]
                    i = self.resonances.index(ri)
                    j = self.resonances.index(rj)
                    atomSets1 = list(ri.resonanceSet.atomSets)
                    atomSets2 = list(rj.resonanceSet.atomSets)
                    if atomSets1 == atomSets2:
                        ass = list(atomSets1)
                        atomSets1 = [
                            ass[0],
                        ]
                        atomSets2 = [
                            ass[-1],
                        ]

                    distance = getAtomSetsDistance(atomSets1, atomSets2,
                                                   self.structure)
                    r = distance * 1e-8
                    nhs = protonNumbs[rj.name]
                    sigma = 0.1 * jcross * nhs / (r**6)
                    sigmas[i][j] = sigma

                    constraint.setDetails('Known Dist: %4.3f' % (distance))
                    #for constraint in self.antiDistConstraintList.constraints:
                    #  atomSets1 = list(resonances[0].resonanceSet.atomSets)
                    #  atomSets2 = list(resonances[1].resonanceSet.atomSets)
                    #  distance = getAtomSetsDistance(atomSets1, atomSets2, self.structure)
                    #  constraint.setDetails('Known Dist: %4.3f' % (distance))

                fp = open('sigmas.out', 'w')
                for i in range(N - 1):
                    for j in range(i + 1, N):
                        if sigmas[i][j] != 0.0:
                            fp.write('%3.1d  %3.1d   %9.2e\n' %
                                     (i, j, sigmas[i][j]))
                    #fp.write('\n')
                fp.close()

        self.setButtonStates()
Esempio n. 8
0
    def showPeakConnection(self, peak):

        peakContribs = peak.peakContribs
        dimAtomSets = []
        dimIsotopes = []

        for peakDim in peak.sortedPeakDims():
            isotope = None

            for contrib in peakDim.peakDimContribs:
                resonance = contrib.resonance
                resonanceSet = resonance.resonanceSet

                if resonanceSet:
                    atomSets = resonanceSet.atomSets
                    isotope = resonance.isotopeCode
                    dimAtomSets.append(
                        (peakDim, contrib.peakContribs, atomSets, isotope))

            dimIsotopes.append(isotope)

        M = len(dimAtomSets)
        atomSetsPairs = set()

        if dimIsotopes.count('1H') > 1:
            hOnly = True
        else:
            hOnly = False

        for i in range(M - 1):
            peakDimI, peakContribsI, atomSetsI, isotopeI = dimAtomSets[i]

            if hOnly and (isotopeI != '1H'):
                continue

            for j in range(i + 1, M):
                peakDimJ, peakContribsJ, atomSetsJ, isotopeJ = dimAtomSets[j]

                if peakDimJ is peakDimI:
                    continue

                if isotopeI != isotopeJ:
                    continue

                if hOnly and (isotopeJ != '1H'):
                    continue

                if atomSetsI == atomSetsJ:
                    continue

                if peakContribs:
                    for peakContrib in peakContribsJ:
                        if peakContrib in peakContribsI:
                            atomSetsPairs.add(frozenset([atomSetsI,
                                                         atomSetsJ]))
                            break

                else:
                    atomSetsPairs.add(frozenset([atomSetsI, atomSetsJ]))

        if len(atomSetsPairs):
            for atomSetsI, atomSetsJ in atomSetsPairs:
                value = getAtomSetsDistance(atomSetsI,
                                            atomSetsJ,
                                            self.structure,
                                            self.model,
                                            method=self.distMethod)

                color = self.getNoeColor(value)
                self.showAtomSetsConnection(atomSetsI,
                                            atomSetsJ,
                                            value,
                                            color=color)

        # If the AtomSets could not be paired just highlight the respective atoms.
        else:
            for i in range(M):
                peakDimI, peakContribsI, atomSetsI, isotopeI = dimAtomSets[i]
                self.highlightAtoms(atomSetsI)
Esempio n. 9
0
def makeConstraintsFromStructure(argServer,
                                 structure=None,
                                 atomRoots=None,
                                 threshold=5.5,
                                 tolerance=0.1,
                                 adcThreshold=7.0,
                                 atomTypes=('H', ),
                                 adcAtoms=('H', )):
    # find all NMR visible atom pairs within a specified distance to
    # generate distance constraints

    if not structure:
        structure = argServer.getStructure()

    from ccpnmr.analysis.core.AssignmentBasic import newResonance
    from ccpnmr.analysis.core.StructureBasic import getAtomSetsDistance
    from ccpnmr.analysis.core.ConstraintBasic import getFixedResonance, makeNmrConstraintHead

    notVisible = {
        'Lys': ["H''", "HZ1", "HZ2", "HZ3"],
        'Arg': ["H''", "HH11", "HH12", "HH21", "HH22", "CZ"],
        'Ser': [
            "H''",
            "HG",
        ],
        'Cys': [
            "H''",
            "HG",
        ],
        'His': ["H''", "HD1", "CG"],
        'Thr': [
            "H''",
            "HG1",
        ],
        'Tyr': ["H''", "HH", "CG"],
        'Phe': ["H''", "CG"],
        'Glu': [
            "H''",
            "HE2",
        ],
        'Asp': [
            "H''",
            "HD2",
        ],
        'Trp': ["H''", "CG", "CD2", "CE2"],
    }

    project = structure.root
    chain = structure.findFirstCoordChain().chain

    atomSetDict = {}
    anchorAtomSets = {}
    amideAtomSets = []
    resonanceDict = {}
    adcAtomSets = {}

    print "Getting atomSets and resonances"
    for residue in chain.residues:
        atomSetDict[residue] = []
        exclude = notVisible.get(residue.ccpCode) or [
            "H''",
        ]
        for atom in residue.atoms:
            if atom.name[0] not in atomTypes:
                continue
            if atom.name in exclude:
                continue

            atomSet = atom.atomSet
            if atomSet:
                if resonanceDict.get(atomSet) is None:
                    if atomSet.resonanceSets:
                        resonanceSet = atomSet.findFirstResonanceSet()
                        i = list(resonanceSet.atomSets).index(atomSet)
                        if i >= len(resonanceSet.resonances):
                            i = 0
                        resonance = resonanceSet.resonances[i]

                    else:
                        resonance = newResonance(project, isotopeCode='1H')

                    resonanceDict[atomSet] = resonance
                    atomSetDict[residue].append(atomSet)

                if atom.name in ('H', 'H1'):
                    amideAtomSets.append(atomSet)
                elif (residue.ccpCode == 'PRO') and (atom.name == 'HD2'):
                    amideAtomSets.append(atomSet)

                if atomRoots:
                    if atom.name in atomRoots:
                        anchorAtomSets[atomSet] = 1
                else:
                    anchorAtomSets[atomSet] = 1

                if adcAtoms and (atom.name in adcAtoms):
                    adcAtomSets[atomSet] = 1

    print "Calculating distances"
    resonanceDists = []
    resonanceDists2 = []
    for amide1 in amideAtomSets:
        residue1 = amide1.finsFirstAtom().residue
        print "  %d %s" % (residue1.seqCode, residue1.ccpCode)

        for amide2 in amideAtomSets:
            residue2 = amide2.findFirstAtom().residue
            if amide1 is amide2:
                amideDist = 0.0
            else:
                amideDist = getAtomSetsDistance((amide1, ), (amide2, ),
                                                structure)

            if (amideDist is not None) and (amideDist <= 25.0):
                for atomSet1 in atomSetDict[residue1]:
                    if anchorAtomSets.get(atomSet1) is None:
                        continue

                    for atomSet2 in atomSetDict[residue2]:
                        if atomSet1 is atomSet2:
                            continue

                        dist = getAtomSetsDistance((atomSet1, ), (atomSet2, ),
                                                   structure)
                        if dist and dist <= threshold:
                            resonanceDists.append(
                                (dist, resonanceDict[atomSet1],
                                 resonanceDict[atomSet2]))

            if adcAtoms:
                for atomSet1 in atomSetDict[residue1]:
                    if anchorAtomSets.get(atomSet1) is None:
                        continue
                    if adcAtomSets.get(atomSet1) is None:
                        continue

                    for atomSet2 in atomSetDict[residue2]:
                        if adcAtomSets.get(atomSet2) is None:
                            continue
                        if atomSet1 is atomSet2:
                            continue

                        dist = getAtomSetsDistance((atomSet1, ), (atomSet2, ),
                                                   structure)
                        if dist >= adcThreshold:
                            resonanceDists2.append(
                                (dist, resonanceDict[atomSet1],
                                 resonanceDict[atomSet2]))

    print "Generating constraints"
    if resonanceDists:
        constraintHead = makeNmrConstraintHead(project)
        constraintList = constraintHead.newDistanceConstraintList()

        for dist, resonance1, resonance2, in resonanceDists:
            if resonance1 is resonance2:
                continue
            fixedResonance1 = getFixedResonance(constraintHead, resonance1)
            fixedResonance2 = getFixedResonance(constraintHead, resonance2)
            delta = tolerance * dist
            minDist = max(0.0, dist - delta)
            maxDist = dist + delta

            constraint = constraintList.newDistanceConstraint(
                weight=1.0,
                origData=dist,
                targetValue=dist,
                upperLimit=maxDist,
                lowerLimit=minDist,
                error=delta)
            item = constraint.newDistanceConstraintItem(
                resonances=[fixedResonance1, fixedResonance2])

        if adcAtoms:
            constraintList2 = constraintHead.newDistanceConstraintList()
            # make ADCs
            for dist, resonance1, resonance2, in resonanceDists2:
                if resonance1 is resonance2:
                    continue
                dist = 75.0
                fixedResonance1 = getFixedResonance(constraintHead, resonance1)
                fixedResonance2 = getFixedResonance(constraintHead, resonance2)
                minDist = 5.0
                maxDist = 150
                delta = maxDist - minDist

                constraint = constraintList2.newDistanceConstraint(
                    weight=1.0,
                    origData=dist,
                    targetValue=dist,
                    upperLimit=maxDist,
                    lowerLimit=minDist,
                    error=delta)
                item = constraint.newDistanceConstraintItem(
                    resonances=[fixedResonance1, fixedResonance2])

    print "Done"
Esempio n. 10
0
    def calculateDistances(self):

        resonances = list(self.resonances)

        resDict = {}
        for resonance in resonances:
            resDict[resonance.serial] = resonance

        ratioHD = self.ratioHDEntry.get() or self.ratioHD

        tmix1 = self.tmix1Entry.get() or 60
        tmix2 = self.tmix2Entry.get() or 120
        tmix3 = self.tmix3Entry.get() or 200

        data = [(tmix1, self.noesyPeakList1), (tmix2, self.noesyPeakList2),
                (tmix3, self.noesyPeakList3)]
        data.sort()

        mixingTimes = [x[0] for x in data]
        peakLists = [x[1] for x in data]

        # get a clean, symmetric and normalised NOE matrix
        noeMatrix = getNoeMatrixFromPeaks(self.noesyPeaks,
                                          resonances,
                                          peakLists,
                                          mixingTimes,
                                          ratioHD=ratioHD,
                                          analysis=self.guiParent)

        # optimiseRelaxation will remove unconstrained resonances
        self.distanceConstraintList, resonances = optimiseRelaxation(
            resonances,
            noeMatrix,
            self.mixTime,
            self.specFreq,
            self.corrTime,
            self.leakRate,
            self.carbonLabel,
            self.nitrogenLabel,
            maxIter=self.maxIter)

        #constrainSpinSystems(self.distanceConstraintList)
        # for testing calculate distances from structure overrides any resonances: uses assigned ones
        #(self.distanceConstraintList, self.resonances) = self.cheatForTesting()
        #self.antiDistConstraintList = self.distanceConstraintList
        protonNumbs = {'CH3': 3, 'Haro': 2, 'HN': 1, 'H': 1}

        PI = 3.1415926535897931
        GH = 2.6752e4
        HB = 1.05459e-27
        CONST = GH * GH * GH * GH * HB * HB
        tc = 1.0e-9 * self.corrTime
        wh = 2.0 * PI * self.specFreq * 1.0e6
        j0 = CONST * tc
        j1 = CONST * tc / (1.0 + wh * wh * tc * tc)
        j2 = CONST * tc / (1.0 + 4.0 * wh * wh * tc * tc)
        #jself = 6.0*j2 + 3.0*j1 + j0
        jcross = 6.0 * j2 - j0

        if self.distanceConstraintList and self.noesyPeakList:
            constraintHead = self.distanceConstraintList.nmrConstraintStore

            if self.adcAtomTypes:
                adcDict = {
                    'HN': ['H'],
                    'HN HA': ['H', 'HA', 'HA1', 'HA2'],
                    'HN HA HB': ['H', 'HA', 'HA1', 'HA2', 'HB', 'HB2', 'HB3']
                }

                allowedAtomTypes = adcDict[self.adcAtomTypes]

                print "Making ADCs"
                self.antiDistConstraintList = makeNoeAdcs(
                    resonances[:],
                    self.noesyPeakList.dataSource,
                    constraintHead,
                    allowedAtomTypes=allowedAtomTypes)
                print "Done ADCs"

            if self.structure:

                N = len(self.resonances)
                sigmas = [[] for i in range(N)]
                for i in range(N):
                    sigmas[i] = [0.0 for j in range(N)]

                for constraint in self.distanceConstraintList.constraints:
                    item = constraint.findFirstItem()
                    resonances = list(item.resonances)

                    ri = resDict[resonances[0].resonanceSerial]
                    rj = resDict[resonances[1].resonanceSerial]
                    i = self.resonances.index(ri)
                    j = self.resonances.index(rj)
                    atomSets1 = list(ri.resonanceSet.atomSets)
                    atomSets2 = list(rj.resonanceSet.atomSets)
                    if atomSets1 == atomSets2:
                        ass = list(atomSets1)
                        atomSets1 = [
                            ass[0],
                        ]
                        atomSets2 = [
                            ass[-1],
                        ]

                    distance = getAtomSetsDistance(atomSets1, atomSets2,
                                                   self.structure)
                    r = distance * 1e-8
                    nhs = protonNumbs[rj.name]
                    sigma = 0.1 * jcross * nhs / (r**6)
                    sigmas[i][j] = sigma

                    constraint.setOrigData(distance)

        self.update()
Esempio n. 11
0
    def update(self,
               contrib,
               peakDim,
               aliasing=False,
               structure=None,
               limitedResonances=None,
               molSystems=None,
               component=None,
               noDisplay=False,
               doubleTol=False,
               resetScrollbars=True,
               showMolSystem=False):

        self.aliasing = aliasing
        self.contrib = contrib
        self.resonances = []
        self.jCouplings = []
        self.structure = structure
        self.component = component
        atomSets1 = []

        if peakDim:
            self.peakDim = peakDim
        elif contrib:
            self.peakDim = None
            peakDim = contrib.peakDim
        else:
            self.scrolledMatrix.update(objectList=[], textMatrix=[
                [],
            ])
            return

        if component and (component.dataDimRef.expDimRef.unit != 'ppm'):
            headingList = ['#', 'Names', 'Delta', 'Coupling', 'SD']
            tipTexts = TIP_TEXTS2
            isCoupling = True
        else:
            tipTexts = TIP_TEXTS
            headingList = ['#', 'Name', 'Delta', 'Shift', 'SD', 'Dist']
            isCoupling = False

        if showMolSystem:
            tipTexts = tipTexts[:]
            tipText = 'Mol System of resonance'
            if isCoupling:
                tipText += 's'
            tipTexts.append(tipText)
            headingList.append('MS')

        dataDimRef = peakDim.dataDimRef
        expDimRef = dataDimRef.expDimRef
        dataDim = dataDimRef.dataDim
        textMatrix = []
        colorMatrix = []

        if isCoupling:

            ppm = getAnalysisDataDim(peakDim.dataDim).assignTolerance
            points = peakDim.dataDimRef.valueToPoint(ppm)
            tolerance = component.dataDimRef.pointToValue(points)

            if doubleTol:
                tolerance *= 2

            # get couplings that might match the splitting
            for delta, coupling in findMatchingCouplings(component, tolerance):
                resonanceA, resonanceB = coupling.resonances
                nameA = makeResonanceGuiName(resonanceA)
                nameB = makeResonanceGuiName(resonanceB)

                self.jCouplings.append(coupling)

                colors = [None, None, None, None, None]
                if coupling.error >= tolerance:
                    colors[4] = '#d0a0a0'

                textMatrix.append([
                    '%d,%d' % (resonanceA.serial, resonanceB.serial),
                    '%s-%s' % (nameA, nameB),
                    '%5.3f' % round(delta, 3), coupling.value,
                    '%5.3f' % round(coupling.error, 3)
                ])
                colorMatrix.append(colors)

                if showMolSystem:
                    molSystemA = getResonanceMolSystem(resonanceA) or ''
                    molSystemB = getResonanceMolSystem(resonanceB) or ''
                    if molSystemA == molSystemB:
                        texts.append(molSystemA and molSystemA.code)
                    else:
                        texts.append('%s,%s' %
                                     (molSystemA and molSystemA.code,
                                      molSystemB and molSystemB.code))
                    colors.append(None)

            objectList = self.jCouplings

        else:
            # set up atomSets for distance calculations where possible
            if self.structure:
                for expTransfer in expDimRef.expTransfers:
                    if expTransfer.transferType in longRangeTransfers:
                        expDimRefs = list(expTransfer.expDimRefs)
                        expDimRefs.remove(expDimRef)

                        for peakDim1 in peakDim.peak.sortedPeakDims():
                            if peakDim1.dataDimRef.expDimRef is expDimRefs[0]:
                                for contrib1 in peakDim1.peakDimContribs:
                                    resonance1 = contrib1.resonance

                                    if resonance1 and resonance1.resonanceSet:
                                        for atomSet in resonance1.resonanceSet.atomSets:
                                            atomSets1.append(atomSet)

            if component:
                # E.g. MQ or reduced dimensionality
                dataDimRef2 = component.dataDimRef

                if dataDimRef is dataDimRef2:
                    ppm = abs(peakDim.value - peakDim.realValue)

                else:
                    realPoint = ppm2pnt(peakDim.realValue, dataDimRef)
                    deltaPoints = abs(peakDim.position - realPoint)
                    ppm = abs(component.scalingFactor *
                              dataDimRef2.pointToValue(deltaPoints))

                peakUnit = dataDimRef2.expDimRef.unit or 'point'

            else:
                ppm = peakDim.realValue
                peakUnit = expDimRef.unit or 'point'

            shiftList = peakDim.peak.peakList.dataSource.experiment.shiftList
            shiftUnit = shiftList.unit

            tolerance = getAnalysisDataDim(dataDim).assignTolerance
            if doubleTol:
                tolerance *= 2

            shifts = self.givePossAssignments(peakDim, tolerance, ppm)

            if len(shifts) > 0:  # resonance matches
                temp = []
                for shift in shifts:
                    resonance = shift.resonance
                    if limitedResonances is not None:
                        if resonance not in limitedResonances:
                            continue

                    if molSystems:
                        molSystem = getResonanceMolSystem(resonance)
                        if molSystem and (molSystem not in molSystems):
                            continue

                        # Kludge until chain states
                        if (
                                not molSystem
                        ) and resonance.resonanceGroup and resonance.resonanceGroup.chains:
                            molSystems2 = set([
                                ch.molSystem
                                for ch in resonance.resonanceGroup.chains
                            ])

                            if not molSystems2.intersection(molSystems):
                                continue

                    if peakUnit != shiftUnit:
                        shiftValue = unit_converter[(shiftUnit,
                                                     peakUnit)](shift.value,
                                                                dataDimRef)
                    else:
                        shiftValue = shift.value

                    points = unit_converter[(peakUnit, 'point')](shiftValue,
                                                                 dataDimRef)

                    numAliasing = findNumAliasing(dataDimRef, points)
                    deltaAliasing = numAliasing - peakDim.numAliasing

                    if deltaAliasing:
                        points -= dataDim.numPointsOrig * deltaAliasing
                        shiftValue = unit_converter[('point',
                                                     peakUnit)](points,
                                                                dataDimRef)
                        shift.isDiffAliasing = 1
                    else:
                        shift.isDiffAliasing = 0

                    delta = abs(ppm - shiftValue)
                    temp.append((delta, shift))
                    shift.delta = delta

                temp.sort()
                shifts = [x[1] for x in temp]

                textMatrix = []
                colorMatrix = []
                for shift in shifts:
                    resonance = shift.resonance
                    if limitedResonances is not None:
                        if resonance not in limitedResonances:
                            continue

                    # wb104, 13 Apr 2016, added below (could check this instead in if statement
                    # but the problem is that shift.delta also needs to exist further down
                    # and also both attributes get deleted at bottom of the loop)

                    if not hasattr(shift, 'isDiffAliasing'):
                        continue

                    if shift.isDiffAliasing:
                        colors = [None, None, '#d0d0a0', None, None, None]
                    else:
                        colors = [None, None, None, None, None, None]

                    name = makeResonanceGuiName(resonance)
                    self.resonances.append(resonance)

                    if shift.error >= tolerance:
                        colors[4] = '#d0a0a0'

                    if self.structure and atomSets1:
                        if resonance.resonanceSet:
                            atomSets2 = list(resonance.resonanceSet.atomSets)
                            dist = getAtomSetsDistance(atomSets1,
                                                       atomSets2,
                                                       self.structure,
                                                       method='noe')
                        else:
                            dist = None
                    else:
                        dist = None

                    texts = [
                        resonance.serial, name,
                        '%5.3f' % round(shift.delta, 3), shift.value,
                        '%5.3f' % round(shift.error, 3), dist or ' '
                    ]

                    if showMolSystem:
                        molSystem = getResonanceMolSystem(resonance)
                        texts.append(molSystem and molSystem.code)
                        colors.append(None)

                    textMatrix.append(texts)
                    colorMatrix.append(colors)

                    del shift.isDiffAliasing
                    del shift.delta

            objectList = self.resonances

        if not noDisplay:
            self.scrolledMatrix.update(headingList=headingList,
                                       tipTexts=tipTexts,
                                       objectList=objectList,
                                       textMatrix=textMatrix,
                                       colorMatrix=colorMatrix,
                                       resetScrollbars=resetScrollbars)