def __init__(self, parent, serverLocation=UPDATE_SERVER_LOCATION, serverDirectory=UPDATE_DIRECTORY, dataFile=UPDATE_DATABASE_FILE, exitOnClose=False, helpUrl=None): self.exitOnClose = exitOnClose self.helpUrl = helpUrl UpdateAgent.__init__(self, serverLocation, serverDirectory, dataFile, isStandAlone=exitOnClose) self.fileUpdate = None if exitOnClose: quitFunc = sys.exit else: quitFunc = None BasePopup.__init__(self, parent=parent, title='CcpNmr Software Updates', quitFunc=quitFunc)
def startBasePopup(self, parent, title, modal, True): BasePopup.__init__(self, parent=parent, title=title, modal=modal, transient=True)
def __init__(self, parent, project): self.project = project self.guiParent = parent self.selectedFormats = [] self.defaultText = 'Select file' self.chainDict = {} self.chainList = [] self.shiftListDict = {} self.shiftLists = [] for shiftList in self.project.currentNmrProject.findAllMeasurementLists( className='ShiftList'): if shiftList.measurements != (): label = str(shiftList.serial) + ':' + str(shiftList.name) self.shiftListDict[label] = shiftList self.shiftLists.append(label) if not self.shiftLists: showError('Error', 'No shift lists available!') return BasePopup.__init__(self, parent=parent, title="Project '%s': " % project.name + 'Write BMRB chemical shift deposition file', modal=False, transient=True)
def __init__(self, parent, project, molName, createMoleculeDict, localCreateMoleculeDict): self.molName = molName self.project = project self.createMoleculeDict = createMoleculeDict self.localCreateMoleculeDict = localCreateMoleculeDict self.hasChanged = False self.molecule = self.localCreateMoleculeDict[self.molName][0] self.deleteText = 'Delete' self.okText = 'OK' self.startText = 'Insert at start' self.endText = 'Append to end' self.newMoleculeList = [] for molName in self.localCreateMoleculeDict.keys(): if molName != self.molName and not self.localCreateMoleculeDict[ molName][0]: self.newMoleculeList.append(molName) # modal = true means that it won't continue unless this one returns value BasePopup.__init__(self, parent=parent, title="Project '%s': " % project.name + 'Set chemComps for sequence', modal=True, transient=True)
def __init__(self, parent, project): self.project = project self.guiParent = parent self.autoAssignFormat = AutoAssignFormat(project, guiParent=parent) self.format = 'autoAssign' self.chainStampSep = '-' self.dateTimeFlag = time.strftime("%Y%m%d.%H:%M") self.getPreviousDateTimeStamps() self.getChainsAndChainStamps() self.importFileName = self.exportFileName = None BasePopup.__init__(self, parent=parent, title="Project '%s': " % project.name + 'AutoAssign export/import cycle.', modal=True, transient=True)
def __init__(self, parent, headings, entries, title='', file='', *args, **kw): headings = [heading.replace('\n', ' ') for heading in headings] if (headings[0].lower() == 'number'): self.addNumber = False else: self.addNumber = True headings.insert(0, 'Number') if (not title): title = 'Export data' self.exportSelection = parent.tableExportSelection self.headings = headings self.entries = entries self.file = file kw['title'] = title kw['transient'] = True kw['modal'] = True BasePopup.__init__(self, parent=parent, *args, **kw)
def __init__(self, parent, message, nmrRes, optionList, title, urlFile=None): # Constructor doesn't do much except call body # The parent is self.parent (parent of the popup) self.singleResonanceStatus = None self.message = message self.optionList = optionList self.nmrRes = nmrRes if urlFile: self.help_url = joinPath(getHelpUrlDir(), urlFile + '.html') else: self.help_url = None # modal = true means that it won't continue unless this one returns value BasePopup.__init__(self, parent=parent, title=title, modal=True, transient=True)
def __init__(self, guiParent, run, protocolInterface, *args, **kw): self.run = run self.protocolInterface = protocolInterface self.widgetDict = {} # maps interfaceParameter --> widget BasePopup.__init__(self, guiParent, *args, **kw)
def __init__(self, parent, peakList, *args, **kw): self.peakList = peakList self.colours = ['red', 'green'] self.dataSets = [] BasePopup.__init__(self, parent=parent, title='Test Popup', **kw)
def __init__(self, parent, project, autoAssignProjectFile): self.project = project self.guiParent = parent self.autoAssignProjectFile = autoAssignProjectFile self.validSelection = False self.peakLists = [] for nmrExp in self.project.currentNmrProject.sortedExperiments(): for ds in nmrExp.sortedDataSources(): for pl in ds.sortedPeakLists(): self.peakLists.append(pl) if not self.peakLists: raise ('No peak lists available!') (self.peakNameList, self.peakNameDict) = createSelection(self.peakLists) self.peakNameList.insert(0, 'None') self.peakNameDict['None'] = None BasePopup.__init__(self, parent=parent, title="Project '%s': " % project.name + 'Write AutoAssign project file', modal=True, transient=True)
def __init__(self, parent, resonanceList, resonanceDict, code3Letter, resName, helpText, multi, title='Select resonances'): # Constructor doesn't do much except call body # The parent is self.parent (parent of the popup) self.selectedResonances = None self.resonanceList = resonanceList self.resonanceDict = resonanceDict self.code3Letter = code3Letter self.resName = resName self.helpText = helpText if multi: self.selectmode = Tkinter.MULTIPLE else: self.selectmode = Tkinter.SINGLE # modal = true means that it won't continue unless this one returns value BasePopup.__init__(self, parent=parent, title=title, modal=True, transient=True)
def __init__(self, parent, file_types=None, directory=None, multiSelect=False, title='Browse files', prompt=None, show_file=True, file='', dismiss_text='Close', extra_dismiss_text='', selected_file_must_exist=False, default_dir=None, *args, **kw): self.file_types = file_types self.directory = directory self.prompt = prompt self.show_file = show_file self.dismiss_text = dismiss_text self.extra_dismiss_text = extra_dismiss_text self.initial_file = file self.selected_file_must_exist = selected_file_must_exist self.default_dir = default_dir self.multiSelect = multiSelect kw['title'] = title kw['transient'] = True kw['modal'] = True BasePopup.__init__(self, parent=parent, *args, **kw)
def __init__(self, parent, title='Text output'): BasePopup.__init__(self, parent=parent, title=title, modal=False, transient=False)
def __init__(self, parent, project): self.project = project self.selectedFormats = [] self.defaultText = 'Select file' self.formats = allFormatsDict.keys() self.formats.sort() BasePopup.__init__(self, parent=parent, title= "Project '%s': " % project.name + 'Write ccpNmr mapping file', modal=False, transient=True)
def __init__(self, parent, project=None, *args, **kw): self.project = project self.parent = parent self.objects = self.getObjects() self.object = None BasePopup.__init__(self, parent=parent, title='Popup Template', **kw) self.updateObjects()
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)
def __init__(self, parent, project): self.project = project self.peakLists = [] BasePopup.__init__(self, parent=parent, title="Project '%s': " % project.name + 'Create shift list from peak lists', modal=False, transient=True)
def __init__(self, parent, text = '', progress = 0, total = 100, title=None, width = 200, height = 15, transient = True, *args, **kw): self.progress = float(progress) self.cWidth = width self.cHeight = height self.total = float(total) or 1.0 self.text = text BasePopup.__init__(self, parent=parent, title=title or 'Progress Bar', transient=transient, *args, **kw)
def __init__(self, parent, objects, key=None, labels=None, objectName=None, refClassName=None, **kw): self.parent = parent self.resetObjectType(objects, key, labels, objectName, refClassName) self.doRegisters() BasePopup.__init__(self, parent, title= "Object Selection", borderwidth=5, **kw)
def __init__(self, parent, file=None, files=None, component=None, selectionText='Select', title=None, format=None, multiSelect=False): # # Also get format (from self?) # self.file = None # Use this to return single file info, for backward compat if not multiSelect and file: self.files = [file] elif files: self.files = files else: self.files = [] if self.files: for i in range(len(self.files)): self.files[i] = normalisePath(self.files[i]) self.component = component self.fileSelected = False self.selectionText = selectionText self.format = format self.multiSelect = multiSelect if not title: title = 'Select %s file' % component BasePopup.__init__(self, parent=parent, title=title, modal=True, transient=True)
def __init__(self, parent, resonanceNameList, resonanceLineDict, ccpCode, title='Group resonances'): self.resNameGroups = None self.resonanceNameList = resonanceNameList self.resonanceLineDict = resonanceLineDict self.checkButtons = [] self.ccpCode = ccpCode BasePopup.__init__(self, parent=parent, title=title, modal=True, transient=True)
def __init__(self, parent, entries, label='', message='', select_text='Select', *args, **kw): self.entries = entries self.label = label self.message = message self.select_text = select_text self.item = None kw['title'] = 'Select item' kw['transient'] = True kw['modal'] = True BasePopup.__init__(self, parent=parent, *args, **kw)
def __init__(self, parent, serverLocation=UPDATE_SERVER_LOCATION, serverDirectory=UPDATE_DIRECTORY, dataFile=UPDATE_DATABASE_FILE): UpdateAgent.__init__(self, serverLocation, serverDirectory, dataFile, admin=1) self.fileTypes = [ FileType('Python', ['*.py']), FileType('C', ['*.c']), FileType('All', ['*']) ] self.fileUpdate = None BasePopup.__init__(self, parent=parent, title='CcpNmr Update Administrator', quitFunc=self.quit)
def __init__(self, parent, acqProcPars, format): self.rawData = acqProcPars.experiment.rawData self.freqData = acqProcPars.freqDataDims[format][0].dataSource self.expDimRefs = acqProcPars.expDimRefs self.format = format self.updateAcqProcPars = acqProcPars.parameterUpdate self.updateAcqProcParsWidget = acqProcPars.updateFromWidget self.getDataDimRefs = acqProcPars.getDataDimRefs self.formatObjectDict = parent.formatObjectDict self.guiParent = parent self.project = self.rawData.root # # Dict for setup # # TODO: really need two datasources for nmrPipe... one fid, one processed!?!? # for writeFormatName in acqProcPars.writeFormats: setattr(self,writeFormatName,writeFormatName) value = 0 self.fileSetup = {} self.writeSetup = {} # # nmrPipe definitions # self.fileSetup[self.nmrPipe] = [ ['Conversion script file\n (outputs to...)', lambda: self.rawData.findFirstApplicationData(application = self.nmrPipe,keyword = 'conversion script'), lambda x = value: self.setApplData(self.rawData,self.nmrPipe,'conversion script',x), ['autoconv.com'], 'conversion script'], [' nmrPipe FIDs\n(inputs to...)', lambda: self.rawData.findFirstApplicationData(application = self.nmrPipe,keyword = 'FID'), lambda x = value: self.setApplData(self.rawData,self.nmrPipe,'FID',x), ['auto.fid','auto%03d.fid'], 'FID'], ['Processing script file\n (outputs to...)', lambda: self.freqData.findFirstApplicationData(application = self.nmrPipe,keyword = 'processing script'), lambda x = value: self.setApplData(self.freqData,self.nmrPipe,'processing script',x), ['autoproc.com'], 'processing script'], ['Processed data', lambda: self.getDataSourceFileName(self.freqData), lambda x = value: self.doDataStoreFileName(self.freqData,x), ['auto.ft','auto%03d.ft'], 'processed data'] ] # TODO: can add execute nmrPipe program buttons... see dataNavigator self.writeSetup[self.nmrPipe] = [ ['Write conversion file', lambda : self.writeFile(self.nmrPipe,['conversion'])], ['Write processing file', lambda : self.writeFile(self.nmrPipe,['processing'])], ['Write all', lambda : self.writeFile(self.nmrPipe,['conversion','processing'])] ] # # azara definitions # self.fileSetup[self.azara] = [ ['Processing parameters file\n (inputs to...)', lambda: self.rawData.findFirstApplicationData(application = self.azara,keyword = 'processing parameters'), lambda x = value: self.setApplData(self.rawData,self.azara,'processing parameters',x), ['autoproc.par'], 'processing parameters'], ['Processing script file\n (outputs to both...)', lambda: self.freqData.findFirstApplicationData(application = self.azara,keyword = 'processing script'), lambda x = value: self.setApplData(self.freqData,self.azara,'processing script',x), ['autoproc.scr'], 'processing script'], ['Processed data', lambda: self.getDataSourceFileName(self.freqData), lambda x = value: self.doDataStoreFileName(self.freqData,x), ['spectrum.ft'], 'spectrum'], ['Processed data parameter file\n', lambda: self.freqData.findFirstApplicationData(application = self.azara,keyword = 'spectrum parameters'), lambda x = value: self.setApplData(self.freqData,self.azara,'spectrum parameters',x), ['spectrum.par'], 'spectrum parameters'] ] # TODO: can add execute process program buttons... see dataNavigator self.writeSetup[self.azara] = [ ['Write processing parameters file', lambda : self.writeFile(self.azara,['processingPars'])], ['Write processing script file', lambda : self.writeFile(self.azara,['processingScript'])], ['Write all', lambda : self.writeFile(self.azara,['processingPars','processingScript'])] ] BasePopup.__init__(self,parent = parent, title = "Project '%s': " % self.project.name + '%s processing write' % format, modal = False, transient=False)
def __init__(self, parent, format, dim, getValue): # # General setup # self.maxArgs = 4 self.nmrPipe = 'nmrPipe' self.azara = 'azara' self.format = format self.freqDataDim = parent.freqDataDims[format][dim] self.expDimRef = parent.expDimRefs[dim] # # Window function settings (different per program) # self.windowFunctions = {} specWidth = self.freqDataDim.spectralWidthOrig # TODO: these for azara still have to change a bit... self.windowFunctions[self.azara] = [ ['sine', 'sinebell', [['Angle (deg)', 0, 'deg']]], ['sine^2', 'sinebell2', [['Angle (deg)', 0, 'deg']]], ['exponential (fixed)', 'decay', [['End value', 0.5, 'end']]], [ 'exponential', 'decay_sw', [['Line broadening (Hz)', 10, 'lb'], ['Spectral width (Hz)', specWidth, 'sw']] ], [ 'gaussian (fixed)', 'gaussian', [['Total points fraction for max', 0.25, 'frac'], ['End value', 1, 'end']] ], [ 'gaussian', 'gaussian_sw', [['Line broadening (Hz)', 10, 'lb'], ['Sharpening factor', 0.7, 'shrp'], ['Spectral width (Hz)', specWidth, 'sw']] ], [ 'inverse cosine', 'inv_cosine', [['Frequency (Hz)', 0, 'freq'], ['Spectral width (Hz)', specWidth, 'sw']] ] ] self.windowFunctions[self.nmrPipe] = [ [ 'sine', 'SP', [['Start sine at (pi)', 0, 'off'], ['End sine at (pi)', 1, 'end'], ['Sine to power', 1, 'pow']] ], ['exponential', 'EM', [['Line broadening (Hz)', 10, 'lb']]], [ 'lorentz-gauss', 'GM', [['Inverse exp width (Hz)', 0, 'g1'], ['Gaussian width (Hz)', 0, 'g2'], ['Center (0-1)', 0, 'g3']] ], [ 'gaussian', 'GMB', [['Exponential term', 0, 'lb'], ['Gaussian term', 0, 'gb']] ], [ 'trapezoid', 'TM', [['Ramp length left', 0, 't1'], ['Ramp length right', 0, 't2']] ], [ 'triangle', 'TRI', [['Point loc of apex', 0, 'loc'], ['Left edge height', 0, 'lHi'], ['Right edge height', 0, 'rHi']] ] ] # # Make list of names for pulldown menu # self.windowFuncList = [] for (winFunc, winFuncAppl, winFuncArgs) in self.windowFunctions[format]: self.windowFuncList.append(winFunc) # # Get the right window function from appldata (if there) # self.windowFunctionKeyword = 'windowFunction' self.winFuncIndex = self.getWindowFunctionIndex() # # Set defaults depending on nucleus type if no window function set # if self.winFuncIndex == -1: if format == self.nmrPipe: self.winFuncIndex = 0 if self.expDimRef.isotopeCodes[0] == '1H': # use SP '-off 0.3333 -pow 2.0' self.windowFunctions[self.nmrPipe][ self.winFuncIndex][2][0][1] = 0.3333 self.windowFunctions[self.nmrPipe][ self.winFuncIndex][2][2][1] = 2.0 else: # for non-H, use SP '-off 0.5 -pow 2.0' self.windowFunctions[self.nmrPipe][ self.winFuncIndex][2][0][1] = 0.5 self.windowFunctions[self.nmrPipe][ self.winFuncIndex][2][2][1] = 2.0 elif format == self.azara: self.winFuncIndex = 1 if self.expDimRef.isotopeCodes[0] == '1H': # use sinebell2 60 self.windowFunctions[self.azara][ self.winFuncIndex][2][0][1] = 60 else: # for non-H, use sinebell2 90 self.windowFunctions[self.azara][ self.winFuncIndex][2][0][1] = 90 # Get actual values for arguments from appldata if they exists! self.updateWindowFunctions() # Also using this to return the current window function 'string value' if not getValue: # modal = true means that it won't continue unless this one returns value BasePopup.__init__( self, parent=parent, title='Select window function', modal=False, transient=True, )
def __init__(self, parent, format, component = None, threading = True): self.project = parent.project self.guiParent = parent self.format = format self.formatObjectDict = parent.formatObjectDict self.component = component self.threading = threading self.setImportExportFlag() self.files = {} self.function = {} self.components = [] self.widgetSetup = {} self.toggleInfoIndex = {} # # Do the import of the relevant format class and the IOkeywords dictionary # self.formatLabel = allFormatsDict[self.format] self.formatModule = __import__('ccpnmr.format.converters.%sFormat' % self.formatLabel,{},{},['%sFormat' % self.formatLabel,'IOkeywords']) # # Definitions for import/export windows, files and functions (come from IoDefinitions) # self.exportFunc = {} self.importFunc = {} self.IOkeywords = {} for (component,readFunc,writeFunc,fileDict,importSetup,exportSetup,exportFunc,importFunc) in IoSetupList: # # If component passed in, only do that one. # if self.component and self.component != component: continue # # Set import or export info # self.toggleInfoIndex[component] = 0 if self.importExportFlag == 'import': self.widgetSetup[component] = importSetup[:] self.function[component] = readFunc componentAction = 'read' # # For multiple file import, don't bother with project files # if not self.component and component == 'project': continue else: self.widgetSetup[component] = exportSetup[:] self.function[component] = writeFunc componentAction = 'write' # # Set some variables and functions... # componentKeyWord = writeFunc[5:] # This is also OK for import... self.exportFunc[component] = exportFunc self.importFunc[component] = importFunc # # Now set format specific information # if fileDict.has_key(format): (fileName,importFlag,exportFlag,addImport,addExport) = fileDict[format] if self.importExportFlag == 'import': validFlag = importFlag addInfo = addImport else: validFlag = exportFlag addInfo = addExport if validFlag: self.files[component] = fileName self.components.append(component) self.IOkeywords[component] = {} # # Normal import/export flag # if validFlag == 1: # # Set fileName(s) info if available (is not in IOkeywords from Format files!!) # for widgetInfo in self.widgetSetup[component]: if widgetInfo[1] == 'fileName': self.IOkeywords[component]['fileName'] = (None,True,'The file name to be %sed.' % self.importExportFlag) break elif widgetInfo[1] == 'fileNames': self.IOkeywords[component]['fileNames'] = (None,True,'The file names to be %sed.' % self.importExportFlag) break # # Get IOkeywords info from Format files... # if self.formatModule.IOkeywords.has_key(self.function[component]): self.IOkeywords[component].update(self.formatModule.IOkeywords[self.function[component]]) for superClass in self.formatModule.IOkeywords['subClasses']: if componentKeyWord in self.formatModule.IOkeywords['subClasses'][superClass]: superClassFunc = componentAction + superClass self.IOkeywords[component].update(self.formatModule.IOkeywords[superClassFunc]) else: print " Warning: no IOkeywords information for %s!" % self.function[component] self.IOkeywords[component] = {} # # Also add to self.toggleInfoIndex[component] if required keywords... # for IoKeyword in self.IOkeywords[component].keys(): if self.IOkeywords[component][IoKeyword][1]: for widgetInfo in self.widgetSetup[component]: if widgetInfo[1] == IoKeyword: self.toggleInfoIndex[component] += 1 # # Display text for import that refers to other mechanism... # else: self.IOkeywords[component]['showText'] = "Please use %s to %s %s." % (validFlag,self.importExportFlag,component) addInfo = None if addInfo: # # Now add format specific widget info and make sure it's all valid... # for addItem in addInfo: inputKeyWord = addItem[1] if inputKeyWord not in self.IOkeywords[component]: print " Error: invalid %s keyword '%s' for %s!" % (self.importExportFlag,inputKeyWord,component) continue # Check whether keyword already exists! If so, replace... for widgetIndex in range(0,len(self.widgetSetup[component])): widgetInfo = self.widgetSetup[component][widgetIndex] if inputKeyWord == widgetInfo[1]: self.widgetSetup[component][widgetIndex] = addItem inputKeyWord = None # If the keyword wasn't found, then append to the full list. if inputKeyWord: self.widgetSetup[component].insert(self.toggleInfoIndex[component],addItem) self.toggleInfoIndex[component] += 1 # TODO: use labels here instead of name BasePopup.__init__(self,parent = parent, title = self.titleText, modal = False, transient=False)