コード例 #1
0
    def getTableObjects(self):

        objs = []

        if self.project:
            objs = getThroughSpacePeakLists(self.project)

            if self.constraintSet:
                objs.extend(list(self.constraintSet.constraintLists))

        return objs
コード例 #2
0
ファイル: EditNoeClasses.py プロジェクト: fenglb/ccpnmr2.4
  def getSpectra(self):
  
    spectra = set()
    peakLists = getThroughSpacePeakLists(self.nmrProject)
    
    for peakList in peakLists:
      spectra.add(peakList.dataSource)
 
    spectra = list(spectra)
    spectra.sort()
 
    return spectra
コード例 #3
0
ファイル: MidgePopup.py プロジェクト: fenglb/ccpnmr2.4
    def getNoesys(self):

        peakLists = getThroughSpacePeakLists(self.project)

        names = [
            '<None>',
        ]
        for peakList in peakLists:
            spectrum = peakList.dataSource
            name = '%s:%s:%s' % (spectrum.experiment.name, spectrum.name,
                                 peakList.serial)
            names.append(name)
            self.peakListDict[name] = peakList

            if not self.noesyPeakList:
                self.noesyPeakList = peakList

        return names
コード例 #4
0
    def showPeaks(self):

        if not self.selectedAtoms:
            msg = 'No atoms selected'
            showWarning('Warning', msg, parent=self)
            return

        if self.peakList:
            peakLists = [
                self.peakList,
            ]
        else:
            peakLists = set(getThroughSpacePeakLists(self.project))

        resonances = []
        for coordAtom in self.selectedAtoms:
            atom = coordAtom.atom
            atomSet = atom.atomSet

            if not atomSet:
                continue

            for resonanceSet in atomSet.resonanceSets:
                for resonance in resonanceSet.resonances:
                    resonances.append(resonance)

        peaks = set([])
        for resonance in resonances:
            for contrib in resonance.peakDimContribs:
                peak = contrib.peakDim.peak
                if peak.peakList in peakLists:
                    peaks.add(peak)

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

        if peaks:
            for peak in peaks:
                self.showPeakConnection(peak)
            self.guiParent.viewPeaks(list(peaks))

        self.updateAfter()
コード例 #5
0
    def updatePeakLists(self, obj=None):

        index = 0
        names = []
        peakLists = getThroughSpacePeakLists(self.project)

        if peakLists:
            if self.peakList not in peakLists:
                self.peakList = peakLists[0]

            index = peakLists.index(self.peakList)
            names = ['%s:%s:%d' % (pl.dataSource.experiment.name, \
                     pl.dataSource.name, pl.serial) for pl in peakLists ]

            peakLists.append(None)
            names.append('<All Avail>')

        else:
            self.peakList = None

        self.peakListPulldown.setup(names, peakLists, index)
コード例 #6
0
def analyseNoeAssignments(molSystem, peakLists=None):


  # Row per residue - cols are num NOES: total, intra, inter,
  # seq, short, short non-seq, long, inter chain, intra chain, contacted res
  
  project = molSystem.root
  
  if not peakLists:
    peakLists = getThroughSpacePeakLists(project)
    
  total = {}
  intra = {}
  inter = {}
  seqen = {}
  short = {}
  nonSeqShort = {}
  longr = {}
  interCh = {}
  intraCh = {}
  contact = {}
  
  for peakList in peakLists:
    dataDims = getThroughSpaceDataDims(peakList.dataSource)
    
    if not dataDims:
      initExpTransfers(peakList.dataSource.experiment)
      dataDims = getThroughSpaceDataDims(peakList.dataSource)
    
    if not dataDims:
      experiment = peakList.dataSource.experiment
      print "Something is wrong with ExpTransfer setup for experiment %s" % (experiment.name)
      continue
    
    dims = set([dd.dim for dd in dataDims])
  
    for peak in peakList.peaks:
      dict = {}

      peakDims = [pd for pd in peak.peakDims if pd.dim in dims]
      
      dimGrouped = []
      dimUngrouped = []
      for peakDim in peakDims:
        grouped = []
        ungrouped = []
      
        for contrib in peakDim.peakDimContribs:
          resonanceSet = contrib.resonance.resonanceSet
          
          if not resonanceSet:
            continue
          
          if contrib.peakContribs:
            grouped.append((contrib, resonanceSet))
          else:
            ungrouped.append((contrib, resonanceSet))
        
        dimGrouped.append(grouped)
        dimUngrouped.append(ungrouped)
      
      for contribs in dimGrouped:
        for contrib, resonanceSet in contribs:
          residue = resonanceSet.findFirstAtomSet().findFirstAtom().residue

          for peakContrib in contrib.peakContribs:
            if dict.get(peakContrib) is None:
              dict[peakContrib] = []
            dict[peakContrib].append(residue)
      
      if (len(dimUngrouped[0]) < 2) or (len(dimUngrouped[-1]) < 2):
        for contribs in dimUngrouped:
          for contrib, resonanceSet in contribs:
            residue = resonanceSet.findFirstAtomSet().findFirstAtom().residue
        
            if dict.get(None) is None:
              dict[None] = []
            dict[None].append(residue)
  
      for peakContrib in dict.keys():
        residues = dict[peakContrib]
        
        if len(residues) > 1:
          for i in range(len(residues)-1):
            residueI = residues[i]
            chainI   = residueI.chain
            if contact.get(residueI) is None:
              contact[residueI] = {}
              
            for j in range(i+1,len(residues)):
              residueJ = residues[j]
              chainJ   = residueJ.chain
      
              delta = abs(residueI.seqCode-residueJ.seqCode)
              
              if contact.get(residueJ) is None:
                contact[residueJ] = {}
              
              total[chainI] = total.get(chainI, 0) + 1
              if chainI is not chainJ:
                total[chainJ] = total.get(chainJ, 0) + 1
              
              if residueI is residueJ:
                intra[residueI] = intra.get(residueI, 0) + 1
                total[residueI] = total.get(residueI, 0) + 1
                intra[chainI]   = intra.get(chainI, 0) + 1
              else:
                contact[residueJ][residueI] = True
                contact[residueI][residueJ] = True
                total[residueI] = total.get(residueI, 0) + 1
                total[residueJ] = total.get(residueJ, 0) + 1
                inter[residueI] = inter.get(residueI, 0) + 1
                inter[residueJ] = inter.get(residueJ, 0) + 1
                inter[chainI] = inter.get(chainI, 0) + 1
                if chainI is not chainJ:
                  inter[chainJ] = inter.get(chainJ, 0) + 1
              
              if chainI is chainJ:
                intraCh[chainI] = intraCh.get(chainI, 0) + 1
                intraCh[residueI] = intraCh.get(residueI, 0) + 1
                if residueI is not residueJ:
                  intraCh[residueJ] = intraCh.get(residueJ, 0) + 1
 
                if delta < 5:
                
                  if delta > 0:
                    short[chainI] = short.get(chainI, 0) + 1
                    short[residueI] = short.get(residueI, 0) + 1
                    if residueI is not residueJ:
                      short[residueJ] = short.get(residueJ, 0) + 1
 
                    if delta > 1:
                      nonSeqShort[chainI]   = nonSeqShort.get(chainI, 0) + 1
                      nonSeqShort[residueI] = nonSeqShort.get(residueI, 0) + 1
                      nonSeqShort[residueJ] = nonSeqShort.get(residueJ, 0) + 1
 
                    elif delta == 1:
                      seqen[residueI] = seqen.get(residueI, 0) + 1
                      seqen[residueJ] = seqen.get(residueJ, 0) + 1
                      seqen[chainI]   = seqen.get(chainI, 0) + 1
 
                else:
                  longr[chainI]   = longr.get(chainI, 0) + 1
                  longr[residueI] = longr.get(residueI, 0) + 1
                  longr[residueJ] = longr.get(residueJ, 0) + 1
                 
 
              else:
                longr[residueI] = longr.get(residueI, 0) + 1
                longr[residueJ] = longr.get(residueJ, 0) + 1
                longr[chainI]   = longr.get(chainI, 0) + 1
                longr[chainJ]   = longr.get(chainJ, 0) + 1
                
                interCh[residueI] = interCh.get(residueI, 0) + 1
                interCh[residueJ] = interCh.get(residueJ, 0) + 1
                interCh[chainI]   = interCh.get(chainI, 0) + 1
                interCh[chainJ]   = interCh.get(chainJ, 0) + 1

  
  if len(molSystem.chains) > 1:
    residues = [('%s%5.5d' % (r.chain.code,r.seqCode),
                 '%s%d%s'% (r.chain.code,r.seqCode,r.ccpCode),r)  for r in contact.keys()]
  else:
    residues = [('%5.5d' % (r.seqCode,),
                 '%d%s' % (r.seqCode,r.ccpCode),r) for r in contact.keys()]
  
  residues.sort()
  
  data = []
  
  for key, name, residue in residues:
    datum = [name,
             total.get(residue, 0),
             intra.get(residue, 0),
             inter.get(residue, 0),
             seqen.get(residue, 0),
             short.get(residue, 0),
             nonSeqShort.get(residue, 0),
             longr.get(residue, 0),
             intraCh.get(residue, 0),
             interCh.get(residue, 0),
             contact[residue].keys()]
             
    data.append([residue, datum])        

  if len(molSystem.chains) > 1:
    for residue, datum in data:
      residues2 = [('%s%5.5d' % (r.chain.code,r.seqCode),
                    '%s%d'% (r.chain.code,r.seqCode)) for r in datum[-1]]
                    
      residues2.sort()
      datum[-1] = ' '.join([x[1] for x in residues2])
     
 
  else:
    for residue, datum in data:
      residues2 = [('%5.5d' % (r.seqCode),
                   '%d' % (r.seqCode)) for r in datum[-1]]
      residues2.sort()
      datum[-1] = ' '.join([x[1] for x in residues2])
 
  chains = [(chain.code, chain) for chain in molSystem.chains]
  chains.sort()
  chains.reverse()
  
  for code, chain in chains:
    datum = ['Chain %s' % code,]
    datum.append(total.get(chain, 0))
    datum.append(intra.get(chain, 0))
    datum.append(inter.get(chain, 0))
    datum.append(seqen.get(chain, 0))
    datum.append(short.get(chain, 0))
    datum.append(nonSeqShort.get(chain, 0))
    datum.append(longr.get(chain, 0))
    datum.append(intraCh.get(chain, 0))
    datum.append(interCh.get(chain, 0))
    datum.append(None)
    data.insert(0, [None, datum])      
     
  return data
コード例 #7
0
ファイル: AriaRunFrame.py プロジェクト: fenglb/ccpnmr2.4
 def getPeakLists(self):
   # overwrites superclass
   
   return getThroughSpacePeakLists(self.project)
コード例 #8
0
ファイル: Analysis.py プロジェクト: VuisterLab/cing
    def runRpf(self,
               doAlised=DEFAULT_CONSIDER_ALIASED_POSITIONS,
               distThreshold=DEFAULT_DISTANCE_THRESHOLD,
               prochiralExclusion=DEFAULT_PROCHIRAL_EXCLUSION_SHIFT,
               diagonalExclusion=DEFAULT_DIAGONAL_EXCLUSION_SHIFT):
        """
        Return None on error.
        It's not an error to have no peak list.

        If pyRpf crashes the exception will be propagated up from here.
        """

        nTmessage("Starting cing.PluginCode.Analysis#runRpf")

        if not hasattr(self.project, CCPN_LOWERCASE_STR):
            #            nTdebug("Failed to find ccpn attribute project. Happens when no CCPN project was read first.") # TODO: change when cing to ccpn code works.
            return
        # end if
        self.ccpnProject = self.project[CCPN_LOWERCASE_STR]
        ccpnProject = self.ccpnProject
        if not ccpnProject:
            nTmessage("Failed to find ccpn project.")
            return

        # Find and print this peakList in the CCPN data model.
        peakLists = getThroughSpacePeakLists(ccpnProject)
        if not peakLists:
            nTwarning("No peak list found; skipping runRpf")
            return
        nTmessage('Peaklists: [%s]' % peakLists)

        #        peakLists = [pl for pl in self.peakListTable.objectList if pl.rpfUse]
        #        ensembles = [e for e in self.ensembleTable.objectList if e.rpfUse]
        ensembles = getEnsembles(ccpnProject)
        if not ensembles:
            nTwarning("No ensemble found; skipping runRpf")
            return

        for ensemble in ensembles:
            nTdebug("Using ensemble: %s " % str(ensemble))
            ensemble.rpfUse = True  # set the selection automatically.
        # end for

        tolerances = []
        for peakList in peakLists:
            try:
                tolerance = getNoeTolerances(peakList)
            except:
                nTexception(format_exc())
                nTerror(
                    "Analysis: Crashed on getNoeTolerances and unknown how to be taking default tolerances."
                )
                return

            tolerances.append(tolerance)
            nTdebug("Using peakList.dataSource.name: %s with tolerance: %s" %
                    (peakList.dataSource.name, str(tolerance)))
            #            peakList[RPF_USE] = True # set the selection automatically.
            peakList.rpfUse = True  # set the selection automatically.
        # end for

        #Instead of polluting the RPF code simply prevent it from crashing CING by wrapping the functionality in a try block.
        validResultStores = calcRPF(
            ensembles,
            peakLists,
            tolerances,
            distThreshold,
            prochiralExclusion,
            diagonalExclusion,
            doAlised,
            verbose=cing.verbosity == cing.verbosityDebug)
        #            self.updateResultsTable()
        nTdebug("validResultStores: %s" % str(validResultStores))
        return validResultStores