Beispiel #1
0
  def body(self, guiFrame):

    ProgressBar.body(self, guiFrame)
    guiFrame.expandGrid(2,3)
    
    self.stepLabel = Label(guiFrame, text='Best step:  ', grid=(0,3))

    
    frame = LabelFrame(guiFrame, text='Best mappings', grid=(1,0), gridSpan=(1,4))

    row = 0
    for i in range(self.ensembleSize):
      label = Label(frame, text='', pady=0, font='Courier 10',
                    borderwidth=0, grid=(row,0), sticky='ew')
      self.labels.append(label)
      row +=1

    guiFrame.grid_rowconfigure(2, weight=1)
    self.graph = ScrolledGraph(guiFrame, width=450, height=300,
                               graphType='scatter', title='Typing Scores',
                               xLabel='Spin System', yLabel='Score',
                               grid=(2,0), gridSpan=(1,4))


    self.buttonList = ButtonList(guiFrame, texts=['Close',], commands=[self.done],
                                 grid=(3,0), gridSpan=(1,4))
    self.buttonList.buttons[0].disable() 
Beispiel #2
0
  def __init__(self, parent, ensembleSize=20, *args, **kw):

    self.guiParent = parent
    self.ensembleSize = ensembleSize or 20
    self.labels = []

    ProgressBar.__init__(self, parent, title="Highest Scoring Mappings", text=' Progress', **kw)
Beispiel #3
0
 def update(self):
 
   if self.progress == self.total:
     width = int(self.cWidth)
     self.canvas.coords(self.bar,self.bw,self.bw,width,self.cHeight)
     self.percent.set( ' %3.1d %%' % 100)
     self.buttonList.buttons[0].enable() 
 
   else:
     ProgressBar.update(self)
Beispiel #4
0
 def getProgressBar(self, text='', progress=0, total=100,
                    width=200, height=15, transient=True):
 
   if self.inGui:
     from memops.gui.ProgressBar import ProgressBar
     return ProgressBar(self.parent, text=text, progress=progress, total=total,
                        width=width, height=height, transient=transient)
  def run(self):
  
    if self.chain:
      pattern = self.filenameEntry.get()
      nSteps  = self.numStepsEntry.get() or 4000
      pdbFile = self.pdbEntry.get()
      dist    =  self.distEntry.get() or 3.0
      pgb     = ProgressBar(self, text='Searching', total=nSteps)
      files   = getFileNamesFromPattern(pattern , '.')
      if not files:
        return
      clouds  = getCloudsFromFile(files, self.chain.root)
       
      score, self.scores, self.assignment = cloudHomologueAssign(self.chain, clouds, pdbFile, dist, nSteps, self.graph, pgb)
 
      pgb.destroy()
      self.globalScoreLabel.set(str(score))
      self.update()
Beispiel #6
0
    def readPredictions(self, predictions, gleScores):

        progressBar = ProgressBar(self, text='Reading DANGLE predictions')
        progressBar.total = len(predictions) - 2  # 2 header lines

        residues = self.dangleChain.chain.sortedResidues()
        getDangleResidue = self.dangleChain.findFirstDangleResidue
        newDangleResidue = self.dangleChain.newDangleResidue

        for residue in residues:
            seqId = residue.seqId
            prediction = predictions.get(seqId)

            if prediction is None:
                continue

            gleMatrix = gleScores[seqId]

            progressBar.increment()

            #resNum, resName = prediction[:2];

            numIsland = prediction[2]
            ss = prediction[10]
            angles = [min(179.9999, a) for a in prediction[3:10]]

            phi, phiUpper, phiLower, psi, psiUpper, psiLower, omega = angles

            # Normalise to max
            maxVal = max(gleMatrix)
            gleMatrix = [
                max(0, int(val / maxVal * 65535)) / 65535.0
                for val in gleMatrix
            ]

            dangleResidue = getDangleResidue(residue=residue)
            if not dangleResidue:
                dangleResidue = newDangleResidue(
                    phiPsiLikelihoodMatrix=gleMatrix, residue=residue)

            else:
                dangleResidue.phiPsiLikelihoodMatrix = gleMatrix

            dangleResidue.numIslands = numIsland
            dangleResidue.phiValue = phi
            dangleResidue.phiUpper = phiUpper
            dangleResidue.phiLower = phiLower
            dangleResidue.psiValue = psi
            dangleResidue.psiUpper = psiUpper
            dangleResidue.psiLower = psiLower
            dangleResidue.omegaValue = omega
            dangleResidue.secStrucCode = ss

        progressBar.destroy()
Beispiel #7
0
  def updateChemCompVarTable(self, *extra):

    textMatrix = []
    allChemComps = []
    
    if (self.chemCompEntries is None):
      selected = self.chem_comp_buttons.getSelected()
    else:
      selected = self.chemCompEntries
      
    numberToLoad = self.numberChemCompsToLoad()
    if (selected and (numberToLoad > 1)):
      use_progress_bar = True
      p = ProgressBar(self, text='loading', total=numberToLoad)
    else:
      use_progress_bar = False
    try:
      n = 0
      
      for (molType, ccpCode) in self.chemCompInfoList:
        chemCompInfo = self.chemCompInfoDict[(molType,ccpCode)]
        isShown = self.chem_comps_shown.has_key((molType, ccpCode))
        has_been_loaded = False
        if (isShown):
          chemComp = chemCompInfo.chemComp 
          if not chemComp:
            chemComp = getChemComp(self.project, molType, ccpCode, 
                                   showError=showError)
            
          chemCompAndVars = [chemComp] + list(chemComp.chemCompVars)# this loads data, if needed
          for chemCompOrVar in chemCompAndVars:
            if (self.chemCompShown(chemCompOrVar)):
              n = n + 1
              text = [n]
              for heading in self.chem_comp_var_headings:
                if hasattr(chemCompOrVar,heading):
                  text.append(getattr(chemCompOrVar, heading))
                elif hasattr(chemCompOrVar,'chemComp') and hasattr(chemCompOrVar.chemComp,heading):
                  text.append(getattr(chemCompOrVar.chemComp, heading))
                else:
                  text.append("n/a")
              textMatrix.append(text)
              allChemComps.append(chemCompOrVar)
        if (use_progress_bar and has_been_loaded):
          p.increment()
    finally:
      if (use_progress_bar):
        p.destroy()

    self.chem_comp_var_table.update(objectList=allChemComps, textMatrix=textMatrix)
Beispiel #8
0
 def done(self):
 
   self.progress = self.total
   ProgressBar.update(self)
Beispiel #9
0
    def readPredictionFile(self, filename, chain):

        try:
            fopen = open(filename, 'r')
        except:
            showError('File Reading Error',
                      'DANGLE prediction file %s cannot be open.' % filename,
                      parent=self)
            return

        lines = fopen.readlines()
        progressBar = ProgressBar(self, text='Reading DANGLE predictions')
        progressBar.total = len(lines) - 2  # 2 header lines
        lines = lines[2:]

        for line in lines:
            progressBar.increment()
            if (line == '\n'):
                continue
            array = line.split()  # keep everything as string
            resNum = int(array[0])
            resName = array[1]
            numIsland = int(array[2])
            phi = array[3]
            phiUpper = array[4]
            phiLower = array[5]
            psi = array[6]
            psiUpper = array[7]
            psiLower = array[8]
            omega = array[9]
            ss = array[10]

            if (phi == 'None'):
                phi = None
            else:
                phi = float(phi)
            if (psi == 'None'):
                psi = None
            else:
                psi = float(psi)
            if (omega == 'None'):
                omega = None
            else:
                omega = float(omega)
                if omega == 180:
                    omega = 179.9
            if (phiUpper == 'None'):
                phiUpper = None
            else:
                phiUpper = float(phiUpper)
            if (phiLower == 'None'):
                phiLower = None
            else:
                phiLower = float(phiLower)
            if (psiUpper == 'None'):
                psiUpper = None
            else:
                psiUpper = float(psiUpper)
            if (psiLower == 'None'):
                psiLower = None
            else:
                psiLower = float(psiLower)
            if (ss == 'None'):
                ss = None

            path = os.path.join(self.dangleDir, 'Res_%d.pgm' % resNum)
            gleMatrix = self.readGLE(path)
            residue = chain.findFirstResidue(seqId=int(resNum))

            dangleResidue = self.dangleChain.findFirstDangleResidue(
                residue=residue)
            if not dangleResidue:
                dangleResidue = self.dangleChain.newDangleResidue(
                    phiPsiLikelihoodMatrix=gleMatrix, residue=residue)
            else:
                dangleResidue.phiPsiLikelihoodMatrix = gleMatrix

            dangleResidue.numIslands = numIsland
            dangleResidue.phiValue = phi
            dangleResidue.phiUpper = phiUpper
            dangleResidue.phiLower = phiLower
            dangleResidue.psiValue = psi
            dangleResidue.psiUpper = psiUpper
            dangleResidue.psiLower = psiLower
            dangleResidue.omegaValue = omega
            dangleResidue.secStrucCode = ss

            # Delete temp pgm files to save space once data is in CCPN
            os.unlink(path)

        fopen.close()
        progressBar.destroy()
Beispiel #10
0
    def runDangle(self):

        chain = self.chain
        shiftList = self.shiftList

        if (not chain) or (not shiftList):
            showError('Cannot Run DANGLE',
                      'Please specify a chain and a shift list.',
                      parent=self)
            return

        # check if there is a DangleChain available
        self.checkDangleStore()
        dangleStore = self.dangleStore

        if not dangleStore:
            return

        dangleChain = dangleStore.findFirstDangleChain(chain=chain)
        if dangleChain:
            data = (chain.code, dangleChain.shiftList.serial)
            msg = 'Predictions for Chain %s using Shift List %d already exist.\nReplace data?' % data

            if not showYesNo('Replace Data', msg, parent=self):
                return

            else:
                self.dangleChain = dangleChain
                dangleChain.shiftList = shiftList

        else:
            self.dangleChain = dangleStore.newDangleChain(chain=chain,
                                                          shiftList=shiftList)

        #dangleStore.packageLocator.repositories[0].url.dataLocation = '/home/msc51/ccpn/NexusTestGI'
        #dangleStore.packageName = 'cambridge.dangle'

        repository = dangleStore.packageLocator.repositories[0]
        array = dangleStore.packageName.split('.')
        path = os.path.join(repository.url.dataLocation, *array)
        path = os.path.join(path, dangleStore.name,
                            chain.code)  # Dangle_dir/dangleStoreName/chainCode
        if not os.path.exists(path):
            os.makedirs(path)

        self.dangleDir = path

        inputFile = os.path.join(self.dangleDir, 'dangle_cs.inp')
        if os.path.isfile(inputFile):
            os.unlink(inputFile)

        outputFile = os.path.join(self.dangleDir, 'danglePred.txt')
        if os.path.isfile(outputFile):
            os.unlink(outputFile)

        numShift = self.makeDangleInput(inputFile, chain, shiftList)

        if not os.path.isfile(inputFile):
            msg = 'No DANGLE input has been generated.\nPlease check shift lists.'
            showError('File Does Not Exist', msg, parent=self)
            return
        if numShift == 0:
            msg = 'No shift data in input file.\nPerhaps shifts are not assigned.\nContinue prediction anyway?'
            if not showYesNo('Empty DANGLE input', msg, parent=self):
                return

        rejectThresh = self.rejectPulldown.getObject()

        # Use the Reference info from the main installation
        # location must be absolute because DANGLE could be run from anywhere
        location = os.path.dirname(dangleModule.__file__)

        progressBar = ProgressBar(self)
        self.update_idletasks()

        dangle = Dangle(location,
                        inputFile=inputFile,
                        outputDir=self.dangleDir,
                        reject=rejectThresh,
                        angleOnly=False,
                        progressBar=progressBar,
                        writePgm=False)

        #self.dangleDir = '/home/msc51/nexus/gItest/DanglePred/'
        #outputFile =  '/home/msc51/nexus/gItest/DanglePred/danglePred.txt'

        predictions = dangle.predictor.predictions
        gleScores = dangle.predictor.gleScores

        self.readPredictions(predictions, gleScores)
        self.updatePredictionMatrix()