Ejemplo n.º 1
0
    def setSpectrum(self, *event):

        if self.currentObject:
            text = self.spectrumEntry.get()
            if text and text != ' ':
                for data in self.scrolledMatrix.objectList:
                    if data is self.currentObject:
                        continue
                    if (data.specName
                            == text) and (data.exptName
                                          == self.currentObject.exptName):
                        showWarning(
                            'Repeated name',
                            'Spectrum name (%s) already in use for experiment (%s)'
                            % (data.specName, data.exptName),
                            parent=self)
                        return
                    elif (self.experiment) and (
                            self.experiment.findFirstDataSource(name=text)):
                        showWarning(
                            'Repeated name',
                            'Spectrum name (%s) already in use for experiment (%s)'
                            % (data.specName, data.exptName),
                            parent=self)
                        return

                self.currentObject.specName = text
            self.update()
Ejemplo n.º 2
0
    def updateResidueRanges(self, event=None, fromChain=False):

        self.residues = set()

        subRanges = self.residueRangeEntry.get()
        if not subRanges or fromChain:
            self.residues = set(self.chain.residues)
            residues = self.chain.sortedResidues()
            text = '{}-{}'.format(residues[0].seqCode, residues[-1].seqCode)
            self.residueRangeEntry.set(text=text)
            return

        for subRange in subRanges:
            indeces = subRange.split('-')
            start = int(indeces[0])
            stop = int(indeces[-1]) + 1
            for seqCode in range(start, stop):
                residue = self.chain.findFirstResidue(seqCode=seqCode)
                if not residue:
                    showWarning('Residue out of range.',
                                'There is no residue at position {}'.format(seqCode),
                                parent=self.guiParent)
                    self.residues = set()
                    return
                self.residues.add(residue)
Ejemplo n.º 3
0
    def updateAcceptanceConstantList(self, event=None):
        '''Updates the list with constants that are used
           during the monte carlo procedure to decide whether
           a changed is accepted or not.
        '''

        acList = self.tempEntry.get()
        newList = []

        for constant in acList:

            try:

                number = float(constant)
                newList.append(number)

            except ValueError:

                string = constant + \
                    ' in temperature constants is not a number.'

                showWarning('Not A Number', string, parent=self.guiParent)

                return False

        self.acceptanceConstantList = newList

        return True
Ejemplo n.º 4
0
    def clusterSelectedPeaks(self):

        peaks0 = self.parent.currentPeaks
        peaks = []
        for peak in peaks0:
            if peak.peakList in self.peakLists:
                peaks.append(peak)

        if not peaks:
            showWarning('Cluster Failure',
                        'No peaks selected from active peak lists',
                        parent=self)
            return

        if not self.multiplet:
            showWarning('Cluster Failure',
                        'No multiplet pattern selected',
                        parent=self)
            return

        cluster = makeMultipletPeakCluster(peaks, self.multiplet,
                                           self.windowPane)

        if cluster:
            self.clusterMatrix.selectObject(cluster)
Ejemplo n.º 5
0
    def setAtomTypeDefault(self):

        if self.scheme:
            atomName = askString(
                'Query',
                'Specify atom name to set\ndefault abundance for',
                'H',
                parent=self)

            if not atomName:
                return

            atomLabels = []
            for chemCompLabel in self.scheme.chemCompLabels:
                if chemCompLabel.molType == self.molType:
                    for isotopomer in chemCompLabel.isotopomers:
                        # Multiple because of isotopes and subTypes
                        atomLabels += isotopomer.findAllAtomLabels(
                            name=atomName)

            if atomLabels:
                for atomLabel in atomLabels:
                    isotope = atomLabel.isotope
                    weight = self.defaultAbun.get(isotope,
                                                  100.0 * isotope.abundance)
                    atomLabel.weight = weight

            else:
                data = (atomName, self.scheme.name)
                msg = 'Atom name %s does not match any atoms in %s scheme isotopomers' % data
                showWarning('Failure', msg)
Ejemplo n.º 6
0
def sendRequest(url, fields, files):
    """Function to send form fields and files to a given URL.
    """

    contentType, bodyData = encodeForm(fields, files)
    
    headerDict = {'User-Agent': 'anonymous',
                  'Content-Type': contentType,
                  'Content-Length': str(len(bodyData))
                  }
        
    request = urllib2.Request(url, bodyData, headerDict)
    response = urlOpen(request)
    
    if not response:
      return
    
    jsonTxt = response.read()
            
    result = _processResponse(jsonTxt)
    if result.get(RESPONSE_EXIT_CODE) != RESPONSE_SUCCESS:
        msg  = 'Request not successful. Action was: %s' % fields
        msg += ' Response was: %s' % jsonTxt
        showWarning('Failure', msg)
        return
    
    return result
Ejemplo n.º 7
0
    def finaliseImport(self):

        if not self.depositionImportNums[6]:
            showWarning('Failure',
                        'Need connected molecule and shift information first')
            return

        if showYesNo(
                "Save project and continue annotation",
                "Are you sure you want to save this project and continue?",
                parent=self):

            if self.depositionImportNums[5] or showYesNo(
                    "No coordinates",
                    "No coordinates are available - are you sure you want to continue?",
                    parent=self):

                showInfo("Project name",
                         "Your project will be saved in the %s directory." %
                         self.project.name,
                         parent=self)

                self.project.saveModified()

                #userData = self.project.findFirstRepository(name='userData')
                #currentPath = userData.url.path
                #currentProjectName = self.project.name

                #projectDir = os.path.join(currentPath,currentProjectName)

                eci = EntryCompletionGui(self.basePopup.root)
                eci.initProject(self.project)
Ejemplo n.º 8
0
  def purgeCingServer(self):

    if not self.project:
      return

    if not self.run:
      msg = 'No CING run setup'
      showWarning('Failure', msg, parent=self)
      return

    if not self.serverCredentials:
      msg = 'No current iCing server job'
      showWarning('Failure', msg, parent=self)
      return

    url = self.iCingBaseUrl
    results = iCingRobot.iCingPurge(self.serverCredentials, self.getServerUrl(url))

    if results:
      showInfo('Info','iCing server results cleared')
      self.serverCredentials = None
      self.iCingBaseUrl = None
      self.serverDone = False
      deleteRunParameter(self.run, iCingRobot.FORM_USER_ID)
      deleteRunParameter(self.run, iCingRobot.FORM_ACCESS_KEY)
      deleteRunParameter(self.run, HTML_RESULTS_URL)
    else:
      showInfo('Info','Purge failed')

    self.update()
Ejemplo n.º 9
0
def transferChainAssignments(chainA, chainB):
    """Transfer any atomic assignments from one chain to another where possible.
  .. describe:: Input
  
  MolSystem.Chain, MolSystem.Chain

  .. describe:: Output
  
  None
  """

    mapping = getChainResidueMapping(chainA, chainB)
    for residueA, residueB in mapping:
        if residueB:
            resonancesB = getResidueResonances(residueB)
            if resonancesB:
                msg = 'Destination residue %s%d has assignments. Continue?.'
                data = (residueB.seqCode, residueB.ccpCode)
                if not showOkCancel('Warning', msg % data):
                    return

    for residueA, residueB in mapping:
        if residueA:
            if residueB is None:
                msg = 'Residue %d%s has no equivalent in destination chain'
                data = (residueA.seqCode, residueA.ccpCode)
                showWarning('Warning', msg % data)
            else:
                transferResidueAssignments(residueA, residueB)
Ejemplo n.º 10
0
  def importPdbCoords(self):

    if not self.project:
      showWarning('Failure','Please create a new CCPN project.', parent=self)
      return

    fileTypes = [ FileType('PDB', ['*.pdb']),
                  FileType('PDB Entry', ['*.ent']),
                  FileType('All', ['*']) ]

    fileSelectPopup = FileSelectPopup(self, file_types=fileTypes,
                        title='Import PDB coordinates file', dismiss_text='Cancel',
                        selected_file_must_exist=True, multiSelect=False,)

    fileName = fileSelectPopup.getFile()

    if not os.path.exists(fileName):
      showWarning('Failure','No such file.', parent=self)
      return

    if fileName:
      name = os.path.split(fileName)[1]
      if '.' in name:
        name = name.split('.')[0]

      pdbObj = PseudoPdbFormat(self.project, self, verbose=True)
      pdbObj.readCoordinates(fileName, minimalPrompts=True)

      self.eciFrame.updateAll()

      return pdbObj
Ejemplo n.º 11
0
  def importFastaSeq(self):

    if not self.project:
      showWarning('Failure','Please create a new CCPN project.', parent=self)
      return

    fileTypes = [ FileType('Fasta', ['*.fsa']),
                  FileType('All', ['*']) ]

    fileSelectPopup = FileSelectPopup(self, file_types=fileTypes,
                        title='Import Fasta sequence file', dismiss_text='Cancel',
                        selected_file_must_exist=True, multiSelect=False,)

    fileName = fileSelectPopup.getFile()

    if not os.path.exists(fileName):
      showWarning('Failure','No such file.', parent=self)
      return

    if fileName:
      name = os.path.split(fileName)[1]
      if '.' in name:
        name = name.split('.')[0]

      fastaObj = FastaFormat(self.project, self, verbose=True)
      fastaObj.readSequence(fileName, minimalPrompts=True)

      self.eciFrame.updateAll()

      return fastaObj
Ejemplo n.º 12
0
  def importNmrStar31(self):

    if not self.project:
      showWarning('Failure','Please create a new CCPN project.', parent=self)
      return

    fileTypes = [ FileType('STAR', ['*.str']),
                  FileType('All', ['*'])]

    fileSelectPopup = FileSelectPopup(self, file_types=fileTypes,
                        title='Import NMR-STAR 3.1 file', dismiss_text='Cancel',
                        selected_file_must_exist=True, multiSelect=False,)

    fileName = fileSelectPopup.getFile()

    if not os.path.exists(fileName):
      showWarning('Failure','No such file.', parent=self)
      return

    if fileName:
      nmrStarObj = NmrStarFormat(self.project, self, verbose=True)
      nmrStarObj.readProject(fileName, minimalPrompts=True, version='3.1')

      self.eciFrame.updateAll()

      return nmrStarObj
Ejemplo n.º 13
0
  def importPdb(self):

    if not self.project:
      showWarning('Failure','Please create a new CCPN project.', parent=self)
      return

    fileTypes = [ FileType('PDB', ['*.pdb']),
                  FileType('PDB Entry', ['*.ent']),
                  FileType('All', ['*']) ]

    fileSelectPopup = FileSelectPopup(self, file_types=fileTypes,
                        title='Import PDB 3.20 file', dismiss_text='Cancel',
                        selected_file_must_exist=True, multiSelect=False,)

    fileName = fileSelectPopup.getFile()

    if not os.path.exists(fileName):
      showWarning('Failure','No such file.', parent=self)
      return

    if fileName:
      name = os.path.split(fileName)[1]
      if '.' in name:
        name = name.split('.')[0]

      pdbObj = ReadPdb(fileName, self.project, 'PDB_'+ name, self)

      self.eciFrame.updateAll()

      return pdbObj
Ejemplo n.º 14
0
def setResidueScheme(molLabel, molResidue, scheme):
  """Descrn: Link a given input residue to a standard set of itotopomers
             specified in a given labelling scheme. The residue labelling
             is only set within a given molLabel instance and so may 
             correspond to only one component of a mixture.
     Inputs: LabeledMolecule.MolLabel, Molecule.molResidue,
             ChemCompLabel.LabelingScheme
     Output: LabeledMolecule.ResLabel
  """

  chemComp = molResidue.chemComp
  chemCompLabel = scheme.findFirstChemCompLabel(chemComp=chemComp)

  if (not chemCompLabel) or not chemCompLabel.isotopomers:
    data = (chemComp.molType, chemComp.ccpCode, scheme.name)
    msg = 'No isotopomer information found for %s %s in labelling scheme %s' % data
    showWarning('Failure', msg)
    return

  resLabel = molLabel.findFirstResLabel(resId=molResidue.serial)

  if resLabel:
    for oldFraction in resLabel.resLabelFractions:
      oldFraction.delete()
    
  else:  
    resLabel = molLabel.newResLabel(resId=molResidue.serial)

  # Weight 1.0 is he default in any case
  # Isotopomer serial zero means standard set  

  resLabel.newResLabelFraction(schemeName=scheme.name,
                               weight=1.0, isotopomerSerial=0)
                               
  return resLabel
Ejemplo n.º 15
0
    def propagatePath(self):

        dataStores = self.dataStoreTable.currentObjects

        if self.dataStore and len(dataStores) > 1:
            sourcePath = self.dataStore.dataUrl.url.dataLocation
            if os.path.exists(sourcePath):
                directory = sourcePath
            elif os.path.exists(os.path.dirname(sourcePath)):
                directory = os.path.dirname(sourcePath)
            else:
                directory = None

            if not directory:
                msg = 'Source directory does not exist'
                showWarning('Failure', msg, parent=self)
                return

            msg = 'Transfer path "%s" to selection?' % directory
            if showOkCancel('Confirm', msg, parent=self):
                for dataStore in dataStores:
                    if dataStore is self.dataStore:
                        continue

                    if dataStore.dataUrl.url.dataLocation == directory:
                        continue

                    changeDataStoreUrl(dataStore, sourcePath)
Ejemplo n.º 16
0
    def saveDataToPyc(self, fileName):
        '''Pickle the data model and save it to file to
           be use later. Since this storage method relies
           on pickle, it is not guaranteed that the data
           can be loaded in future versions of this macro.
        '''

        if self.results:

            if not fileName[-4:] == '.pyc':

                fileName = fileName + '.pyc'

            if os.path.exists(fileName):
                if not showYesNo('File exists',
                                 'File "%s" exists, overwrite?' % fileName,
                                 parent=self.GUI):

                    return

            self.updateInfoText('Saving results...')
            writeFile = open(fileName, 'wb')
            cPickle.dump(self.results, writeFile, protocol=2)
            writeFile.close()
            self.updateInfoText('Results succesfully saved.')

        else:

            string = 'There are no results to save at the moment.'
            showWarning('No results to save', string, parent=self.GUI)
Ejemplo n.º 17
0
    def get(self):

        # TBD: str below is used to convert unicode to string
        # (in Tcl/Tk 8.5 it looks like everything is unicode)
        ###s = str(Tkinter.Entry.get(self).strip())
        s = Tkinter.Entry.get(self).strip().encode('utf-8')
        if (self.isArray):
            if (self.maxCharsPerLine):
                s = s.replace(self.joiner, self.separator)
            if (s):
                value = re.split(self.array_re, s)
            else:
                value = []
            if (self.strToVal):
                value = map(self.strToVal, value)
        elif (self.strToVal):
            if (s):
                try:
                    value = self.strToVal(s)
                except:
                    value = None
                    showWarning('Error',
                                'Could not convert value to required type')
            else:
                value = None
        else:
            value = s

        return value
Ejemplo n.º 18
0
    def checkDangleStore(self):

        if not self.dangleStore:

            N = len(self.project.dangleStores) + 1
            name = askString('Request',
                             'Dangle Run Name:',
                             'Run%d' % N,
                             parent=self)
            if not name:
                return None

            for character in whitespace:
                if character in name:
                    showWarning('Failure',
                                'Name cannot contain whitespace',
                                parent=self)
                    return None

            if self.project.findFirstDangleStore(name=name):
                showWarning('Failure', 'Name already used', parent=self)
                return None

            self.dangleStore = self.project.newDangleStore(name=name)
            self.updateDangleStorePulldown()
Ejemplo n.º 19
0
def iCingFetch(credentials, url, iCingUrl, zipFileName):
    """Fetch a CCPn project from an  job on iCing server associated with given credentials.
    """
     
    response = iCingProjectName(credentials, iCingUrl)
    if not response:
        msg = 'Fetch not possible'
        showWarning('Warning', msg)
        return
    
    entryId = response.get(RESPONSE_RESULT)
    baseUrl, resultUrl, logUrl, zipUrl = getResultUrls(credentials, entryId, url)
    
    #print "Base URL", baseUrl
    #print "Results URL:", resultUrl
    #print "Log URL:", logUrl
    #print "Zip URL:", zipUrl
    
    response = urlOpen(logUrl)
    if response:
      logText = response.read()
      
    response = urlOpen(zipUrl)
    if response:
      file = open(zipFileName, 'wb')
      file.write(response.read())
      file.close()

    return logText
Ejemplo n.º 20
0
  def selectRun(self, simRun):
  
    if self.run is not simRun:
      if simRun:
        if simRun.outputEnsemble:
          msg  = 'Selected run has already been used to generate a structure.'
          msg += 'A new run will be setup based on the selection.'
          showWarning('Warning',msg)
          simRun = self.makeSimRun(template=simRun)
 
        molSystem = simRun.molSystem
        constraintSet = simRun.inputConstraintStore
        shiftList = simRun.findFirstInputMeasurementList(className='ShiftList')
 
        if molSystem and (self.molSystem is not molSystem):
          self.molSystem = molSystem
          self.updateMolSystems()
 
        if constraintSet and (self.constraintSet is not constraintSet):
          self.constraintSet = constraintSet
          self.updateConstraintSets()
    
        if shiftList and (self.shiftList is not shiftList): 
          self.shiftList = shiftList
          self.updateShiftLists()
        
        firstPepPlane = simRun.findFirstrunParameter(code='FirstPepPlane')
        lastPepPlane = simRun.findFirstrunParameter(code='LastPepPlane')
        maxOptSteps = simRun.findFirstrunParameter(code='MaxOptSteps')
        numOptPlanes = simRun.findFirstrunParameter(code='NumOptPlanes')
        minOptHits = simRun.findFirstrunParameter(code='MinOptHits')
        chainCode = simRun.findFirstrunParameter(code='ChainCode')

        
        if firstPepPlane is not None:
          self.firstResEntry.set(firstPepPlane.intValue or 0)
        
        if lastPepPlane is not None:
          self.lastResEntry.set(lastPepPlane.intValue or 0)
          
        if maxOptSteps is not None:
          self.maxOptStepEntry.set(maxOptSteps.intValue or 0)
            
        if numOptPlanes is not None:
          self.numOptPlaneEntry.set(numOptPlanes.intValue or 0)
          
        if minOptHits is not None:
          self.numOptHitsEntry.set(minOptHits.intValue or 0)
           
        if chainCode is not None:
          chainCode = chainCode.textValue or 'A'
          if self.molSystem:
            chain = self.molSystem.findFirsChain(code=chainCode)
 
            if chain:
              self.selectChain(chain) 
                 
      self.run = simRun
Ejemplo n.º 21
0
def warnChempCompLabelFailure(ccpCode,molType,scheme):
  """Descrn: Display a general warning for not being able to find a chemComplLabel
     Inputs: Word, Word, ChemCompLabel.LabelingScheme, MolSystem.Atom
     Output: None
  """

  data = (ccpCode,molType,scheme.name)
  msg  = 'Could not find chemp comp labelling information for %s(%s) in scheme %s'
  showWarning('Failure',msg % data)
Ejemplo n.º 22
0
    def shouldChangeDir(self, directory):

        shouldNotChange = self.isProjectDirectory(directory)
        if shouldNotChange:
            showWarning('Warning',
                        'Cannot save project inside a project directory',
                        parent=self)

        return not shouldNotChange
Ejemplo n.º 23
0
    def wrapperFunction(self, *args, **kwargs):

        if self.guiParent.connector.results:

            function(self, *args, **kwargs)

        else:

            string = 'There are no results since the annealing did not run yet.'
            showWarning('Run Annealing first', string, parent=self.guiParent)
Ejemplo n.º 24
0
  def viewHtmlResults(self):

    resultsUrl = self.resultsUrl
    if not resultsUrl:
      msg = 'No current iCing results URL'
      showWarning('Failure', msg, parent=self)
      return

    webBrowser = WebBrowser(self.application, popup=self.application)
    webBrowser.open(self.resultsUrl)
Ejemplo n.º 25
0
    def __init__(self, parent, project):

        #
        # Info for writing file...
        #

        self.groupText = {}

        #
        # Set up molSystem information
        #

        self.project = project

        self.molSysList = list(project.sortedMolSystems())
        self.molSystems = None

        self.molSysLabelList = []
        self.molSysLabelDict = {}
        self.molSysRelationDict = {}

        molSysLabel = 'All molSystems'

        if self.setChainLabels(molSysLabel, self.molSysList):
            self.molSysLabelList.append(molSysLabel)
            self.molSysLabelDict[molSysLabel] = self.molSysList

        for molSys in self.molSysList:
            molSysLabel = '%s' % molSys.code

            if self.setChainLabels(molSysLabel, [molSys]):
                self.molSysLabelList.append(molSysLabel)
                self.molSysLabelDict[molSysLabel] = [molSys]

        if not self.molSysLabelList:
            showWarning('Warning',
                        'No chemical shift lists available! Exiting...')
            return

        #
        # Some initializing...
        #

        self.chains = None
        self.shiftList = None
        self.shiftListLabel = None
        self.results = None

        # modal = true means that it won't continue unless this one returns value
        BasePopup.__init__(self,
                           parent=parent,
                           title="Project '%s': " % project.name +
                           'Group chemical shift values',
                           modal=False,
                           transient=True)
Ejemplo n.º 26
0
    def addSymmetrySet(self):
            
        if not self.ccpnProject.molSystems:
            showWarning('Warning','No molecular systems present in CCPN project',parent=self)
            return

            molSystem = self.ccpnProject.findFirstMolSystem()
            partner = self.hProject.newHaddockPartner(code=molSystem.code, molSystem=molSystem)
            setPartnerChains(partner, molSystem.chains)

            self.updateAllAfter()
Ejemplo n.º 27
0
 def checkValue(self, value):
 
   if (self.minVal is not None) and (value < self.minVal):
     showWarning('Value is less than minimum value (%s)' % self.minVal)
     value = None
   
   elif (self.maxVal is not None) and (value > self.maxVal):
     showWarning('Value is greater than maximum value (%s)' % self.maxVal)
     value = None
   
   return value
Ejemplo n.º 28
0
    def toggleTab(self, index):

        if (index > 0) and not self.project:
            showWarning('Warning', 'No active project', parent=self)
            self.tabbedFrame.select(0)
            return

        frame = self.tabbedFrame.frames[index]
        if hasattr(frame, 'printOutDocString'):
            print frame.printOutDocString
            # only print it once
            del frame.printOutDocString
Ejemplo n.º 29
0
    def saveSchemes(self):

        schemes = [x for x in self.project.labelingSchemes if x.isModified]

        if schemes:
            for scheme in schemes:
                scheme.save()
            showInfo('Notice', 'Successfully saved %d schemes' % len(schemes))
            self.updateSchemes()

        else:
            showWarning('Notice', 'No modified schemes to save')
Ejemplo n.º 30
0
    def makeNewScheme(self):

        name = askString('Input text', 'New Scheme Code:', '', parent=self)

        if name:
            scheme = self.project.findFirstLabelingScheme(name=name)
            if scheme:
                showWarning('Failure', 'Scheme name already in use')
            else:
                scheme = self.project.newLabelingScheme(name=name)
                self.scheme = scheme

        else:
            showWarning('Failure', 'No name specified')
Ejemplo n.º 31
0
    def saveDataToPyc(self):
        """Save the data to the selected file."""

        if self.guiParent.connector.results:

            fileName = self.fileselectionBox.getFile()
            self.guiParent.connector.saveDataToPyc(fileName)
            self.fileselectionBox.updateFileList()

        else:

            string = """There are no results to save, """ """the algorithm has not run yet."""

            showWarning("No Results to Save", string, parent=self.guiParent)
Ejemplo n.º 32
0
  def toggleUseRestraints(self, constraintList):
 
    bool = constraintList.useForMeccano
    bool = not bool
 
    if bool and (not constraintList.conditionState) \
     and (constraintList.className == 'RdcConsraintList'):
      msg = 'Cannot use RDC restraint list for Meccano '
      msg += 'unless it is first associated with an amigment medium'
      showWarning('Warning', msg, parent=self)
    else:
      constraintList.useForMeccano = bool
      
    self.updateConstraintLists()
Ejemplo n.º 33
0
    def checkPoint2(self):
        '''Second of two checkpoints, is run before the annealing starts.
           It is checked whether the precalculations already ran and whether
           the list with acceptance constants is valid.
           Returns True if it is safe to proceed. Returns False otherwise.
        '''

        if self.ranPreCalculations:

            if self.GUI.annealingSettingsTab.updateAcceptanceConstantList():
                return True
        else:

            string = '''Without running the pre-calculations,
                        the annealing can not run.
                     '''

            showWarning('Run pre-calculations first', string, parent=self.GUI)

        return False
Ejemplo n.º 34
0
    def checkChain(self):
        '''Checks whether a chain is configured
           and whether this chain has residues.
        '''

        if not self.chain:

            string = 'Setup a molecular chain in Molecule --> Molecules'
            showWarning('No chain selected', string, parent=self.GUI)
            return False

        if not self.chain.residues:

            string = '''The selected chain does not have residues,
                        set up the residues in
                        Molecule --> Molecules --> Sequences
                     '''
            showWarning('No Residues', string, parent=self.GUI)
            return False

        return True
Ejemplo n.º 35
0
  def downloadResults(self):

    if not self.run:
      msg = 'No current iCing run'
      showWarning('Failure', msg, parent=self)
      return

    credentials = self.serverCredentials
    if not credentials:
      msg = 'No current iCing server job'
      showWarning('Failure', msg, parent=self)
      return

    fileName = self.resultFileEntry.get()
    if not fileName:
      msg = 'No save file specified'
      showWarning('Failure', msg, parent=self)
      return

    if os.path.exists(fileName):
      msg = 'File %s already exists. Overwite?' % fileName
      if not showOkCancel('Query', msg, parent=self):
        return

    url = self.iCingBaseUrl
    iCingUrl = self.getServerUrl(url)
    logText = iCingRobot.iCingFetch(credentials, url, iCingUrl, fileName)
    print logText

    msg = 'Results saved to file %s\n' % fileName
    msg += 'Purge results from iCing server?'
    if showYesNo('Query',msg, parent=self):
      self.purgeCingServer()
Ejemplo n.º 36
0
  def runCingServer(self):

    if not self.project:
      return

    run = self.run
    if not run:
      msg = 'No CING run setup'
      showWarning('Failure', msg, parent=self)
      return

    structure = self.structure
    if not structure:
      msg = 'No structure ensemble selected'
      showWarning('Failure', msg, parent=self)
      return

    ensembleText = getModelsString(run)
    if not ensembleText:
      msg = 'No structural models selected from ensemble'
      showWarning('Failure', msg, parent=self)
      return

    residueText = getResiduesString(structure)
    if not residueText:
      msg = 'No active residues selected in structure'
      showWarning('Failure', msg, parent=self)
      return

    url = self.iCingBaseUrlPulldown.getObject()
    url.strip()
    if not url:
      msg = 'No iCing server URL specified'
      showWarning('Failure', msg, parent=self)
      self.iCingBaseUrl = None
      return

    msg = 'Submit job now? You will be informed when the job is done.'
    if not showOkCancel('Confirm', msg, parent=self):
      return

    self.iCingBaseUrl = url
    iCingUrl = self.getServerUrl(url)
    self.serverCredentials, results, tarFileName = iCingRobot.iCingSetup(self.project, userId='ccpnAp', url=iCingUrl)

    if not results:
      # Message already issued on failure
      self.serverCredentials = None
      self.resultsUrl = None
      self.update()
      return

    else:
      credentials = self.serverCredentials
      os.unlink(tarFileName)

    entryId = iCingRobot.iCingProjectName(credentials, iCingUrl).get(iCingRobot.RESPONSE_RESULT)
    baseUrl, htmlUrl, logUrl, zipUrl = iCingRobot.getResultUrls(credentials, entryId, url)

    self.resultsUrl = htmlUrl

    # Save server data in this run for persistence

    setRunParameter(run, iCingRobot.FORM_USER_ID, self.serverCredentials[0][1])
    setRunParameter(run, iCingRobot.FORM_ACCESS_KEY, self.serverCredentials[1][1])
    setRunParameter(run, ICING_BASE_URL, url)
    setRunParameter(run, HTML_RESULTS_URL, htmlUrl)
    self.update()

    run.inputStructures = structure.sortedModels()

    # select residues from the structure's chain
    #iCingRobot.iCingResidueSelection(credentials, iCingUrl, residueText)

    # Select models from ensemble
    #iCingRobot.iCingEnsembleSelection(credentials, iCingUrl, ensembleText)

    # Start the actual run
    self.serverDone = False
    iCingRobot.iCingRun(credentials, iCingUrl)

    # Fetch server progress occasionally, report when done
    # this function will call itself again and again
    self.after(CHECK_INTERVAL, self.timedCheckStatus)

    self.update()
Ejemplo n.º 37
0
    def getGuiOptions(self):

        projectName = self.projEntry.get()

        index = self.projOptionsSelect.getIndex()

        if index > 0:
            makeNewProject = True
            projectImport  = None

            if index > 1:
                i = index-2
                format = ['PDB','CCPN','CYANA'][i]
                file   = [self.pdbEntry, self.ccpnEntry, self.cyanaEntry][i].get()

                if not file:
                    showWarning('Failure','No %s file selected' % format)
                    return
                # end if

                projectImport  = (format, file)
            # end if

        else:
            # Chould also check that any old project file exists

            makeNewProject = False
            projectImport  = None
        # end if

        doValidation = self.selectDoValidation.get()
        checks = []

        if doValidation:
            if self.selectCheckAssign.get():
                checks.append('assignments')
            # end if

            if self.selectCheckResraint.get():
                checks.append('restraints')
            # end if

            if self.selectCheckStructure.get():
                checks.append('structural')
            # end if

            if self.selectMakeHtml.get():
                checks.append('HTML')
            # end if

            if self.selectCheckScript.get():
                script = self.validScriptEntry.get()

                if script:
                    checks.append( ('script',script) )
                # end if
            # end if

            if self.selectCheckQueen.get():
                checks.append('queen')
            # end if
        # end if

        exports = []

        if self.selectExportXeasy.get():
            exports.append('Xeasy')
        # end if

        if self.selectExportCcpn.get():
            exports.append('CCPN')
        # end if

        if self.selectExportQueen.get():
            exports.append('QUEEN')
        # end if

        if self.selectExportRefine.get():
            exports.append('refine')
        # end if

        miscScript = None

        if self.selectMiscScript.get():
            script = self.miscScriptEntry.get()

            if script:
                miscScript = script
            # end if
        # end if

        return projectName, makeNewProject, projectImport, doValidation, checks, exports, miscScript
Ejemplo n.º 38
0
    def loadDataFromPyc(self, fileName):
        '''Load previously pickled data.
               args: fileName: name of the file
        '''

        self.updateInfoText('Loading file...')

        # TODO : fix this, getting these values from the GUI is ridiculous
        self.project = self.GUI.project
        self.nmrProject = self.GUI.nmrProject

        results = None

        fileExists = False

        if os.path.exists(fileName):

            fileExists = True

        elif os.path.exists(fileName + '.pyc'):

            fileName = fileName + '.pyc'

            fileExists = True

        if fileExists:

            try:
                with open(fileName, 'rb') as readFile:

                    results = cPickle.load(readFile)

            except:

                string = ('''Something went wrong when trying to '''
                          '''load the previously produced results. '''
                          '''Probably the file you try to '''
                          '''open is not of the correct type.''')

                print string

                showWarning('Can not open file', string, parent=self.GUI)
                raise

            if results:

                if isinstance(results, DataModel):

                    self.results = results
                    self.updateInfoText('File loaded succesfully.')
                    self.updateInfoText(('''Re-connecting to object in '''
                                         '''the ccpn analysis project...'''))
                    self.results.connectToProject(self.project,
                                                  self.nmrProject)
                    # TODO: this is not very nice
                    self.GUI.resultsTab.dataModel = self.results
                    self.updateInfoText('Done')
                    return

                else:

                    string = (('''You are trying to open a file that '''
                               '''was not created using this macro.'''))

                    showWarning('Can not open file', string, parent=self.GUI)

        else:

            string = 'The file you selected does not exist.'

            showWarning('No Such File', string, parent=self.GUI)

        self.updateInfoText(' ')
Ejemplo n.º 39
0
    def checkSpectraAndLabelling(self):
        '''Check whether some spectra are selected by the user
           and whether a reference experiment has been set
           for this experiment (needed to simulate the spectra)
           and if the user said the labelling scheme should
           come automatically from the labelled sample,
           the labelled mixture should be set.
        '''

        if not self.selectedSpectra:

            string = 'Select one or more spectra.'

            showWarning('No Spectra Selected', string, parent=self.GUI)

            return False

        for spec in self.selectedSpectra:

            name = spec.ccpnSpectrum.experiment.name

            if not spec.ccpnSpectrum.experiment.refExperiment:

                string = name + (''' has no reference experiment, '''
                                 '''go to Experiment --> Experiments --> '''
                                 '''Experiment Types and select '''
                                 '''a experiment type.''')

                showWarning('No Reference Experiment',
                            string, parent=self.GUI)

                return False

            mixtures = spec.ccpnSpectrum.experiment.labeledMixtures

            if spec.labellingScheme is True and not mixtures:

                string = name + (''' is not connected to any labelled'''
                                 ''' sample.In order to determine the'''
                                 ''' labelling scheme automatically'''
                                 ''' from the experiment, this has to'''
                                 ''' be set. Go to'''
                                 ''' Menu-Modecule-Isotope Labelling'''
                                 ''' to do so.''')

                showWarning('No Labelled Sample', string, parent=self.GUI)

                return False

            elif len(mixtures) > 1:

                string = name + (''' is connected to more than one labelled'''
                                 ''' sample. This is physically impossible.'''
                                 ''' Go to Menu-Modecule-Isotope Labelling'''
                                 ''' if you want to change this.''')

                showWarning('Multiple Labelled Samples for Spectrum',
                            string, parent=self.GUI)

                return False

        return True