def setShiftList(self, index, name=None): print "setShiftList", index, name if not name: index = self.shiftListPulldown.getSelectedIndex() shiftList = getShiftLists(self.project.currentNmrProject)[index] self.tableObj.setupStructureCalcFrameDict['shiftList'] = shiftList self.updateAfter()
def updateShiftLists(self, *opt): shiftLists = getShiftLists(self.nmrProject) names = ['Shift List %d' % x.serial for x in shiftLists] index = 0 if shiftLists: if self.shiftList not in shiftLists: self.shiftList = shiftLists[0] index = shiftLists.index(self.shiftList) self.shiftListPulldown.setup(names, shiftLists, index)
def updateShiftListPulldown(self, obj=None): index = 0 names = [] shiftLists = getShiftLists(self.nmrProject) if shiftLists: if self.shiftList not in shiftLists: self.shiftList = shiftLists[0] index = shiftLists.index(self.shiftList) names = ['%s:%d' % (sl.name, sl.serial) for sl in shiftLists] else: self.shiftList = None self.shiftListPulldown.setup(names, shiftLists, index)
def updateShiftLists(self, *opt): shiftLists = getShiftLists(self.nmrProject) shiftList = self.shiftList names = ['%s [%d]' % (x.name or '<No name>', x.serial) for x in shiftLists] index = 0 if names: if shiftList not in shiftLists: shiftList = shiftLists[0] index = shiftLists.index(shiftList) if shiftList is not self.shiftList: self.shiftList = shiftList self.updateAfter() self.shiftListPulldown.setup(names, shiftLists, index)
def getShiftList(self, peakList): names = [] index = -1 shiftLists = getShiftLists(self.project.currentNmrProject) if shiftLists: shiftList = peakList.dataSource.experiment.shiftList if shiftList not in shiftLists: shiftList = shiftLists[0] names = [sl.name or str(sl.serial) for sl in shiftLists] index = shiftLists.index(shiftList) print "getShiftList", names, index self.shiftListPulldown.setup(names, index)
def updateShiftLists(self, *opt): index = 0 names = [] shiftLists = getShiftLists(self.nmrProject) shiftList = self.shiftList if shiftLists: if shiftList not in shiftLists: shiftList = shiftLists[0] names = ['%d:%s' % (sl.serial, sl.name) for sl in shiftLists] index = shiftLists.index(shiftList) else: shiftList = None if shiftList is not self.shiftList: self.changeShiftList(shiftList) self.shiftListPulldown.setup(names, shiftLists, index)
def getShiftLists(self): if self.project: names = [] objects = getShiftLists(self.nmrProject) for shiftList in objects: if not shiftList.name: shiftList.name = 'ShiftList %d' % shiftList.serial names.append(shiftList.name) objects.append(None) names.append('<New>') else: objects = [ None, ] names = [ 'ShiftList 1', ] return names, objects
def updateShiftLists(self, *opt): names = [] index = 0 shiftLists = getShiftLists(self.nmrProject) shiftList = self.shiftList if shiftLists: names = [ '%s [%d]' % (sl.name or '<No name>', sl.serial) for sl in shiftLists ] if shiftList not in shiftLists: shiftList = shiftLists[0] index = shiftLists.index(shiftList) if self.shiftList is not shiftList: self.shiftList = shiftList self.shiftListPulldown.setup(names, shiftLists, index)
def body(self, guiFrame): '''This method describes the outline of the body of the application. args: guiFrame: frame the body should live in. ''' self.geometry('800x530') guiFrame.grid_columnconfigure(0, weight=1) guiFrame.grid_rowconfigure(0, weight=0) guiFrame.grid_rowconfigure(1, weight=2) guiFrame.grid_rowconfigure(2, weight=1) isotopeFrame = LabelFrame(guiFrame, text='Isotope Shift Correction CA and CB') isotopeFrame.grid(row=0, column=0, sticky='nsew') frameA = LabelFrame(guiFrame, text='Spin Systems') frameA.grid(row=1, column=0, sticky='nsew') frameA.grid_rowconfigure(0, weight=1) frameA.grid_columnconfigure(0, weight=1) frameA.grid_columnconfigure(1, weight=1) frameA1 = LabelFrame(frameA, text='Spin System 1') frameA1.grid(row=0, column=0, sticky='nsew') frameA1.grid_columnconfigure(0, weight=1) frameA1.grid_rowconfigure(0, weight=1) frameA2 = LabelFrame(frameA, text='Spin System 2') frameA2.grid(row=0, column=1, sticky='nsew') frameA2.grid_columnconfigure(0, weight=1) frameA2.grid_rowconfigure(0, weight=1) frameB = LabelFrame(guiFrame, text='Comparison') frameB.grid(row=2, column=0, sticky='nsew') frameB.grid_rowconfigure(0, weight=1) frameB.grid_columnconfigure(0, weight=1) frameB.grid_columnconfigure(1, weight=2) frameB.grid_columnconfigure(2, weight=1) frameB1 = LabelFrame(frameB, text='Unique to Spin System 1') frameB1.grid(row=0, column=0, sticky='nsew') frameB1.expandGrid(0, 0) frameB2 = LabelFrame(frameB, text='Intersection') frameB2.grid(row=0, column=1, sticky='nsew') frameB2.expandGrid(0, 0) frameB3 = LabelFrame(frameB, text='Unique to Spin System 2') frameB3.grid(row=0, column=2, sticky='nsew') frameB3.expandGrid(0, 0) # Settings for isotope shift correction shiftLists = getShiftLists(self.nmrProject) self.protonatedShiftList = shiftLists[0] self.deuteratedShiftList = shiftLists[1] shiftListNames = ['{}: {}'.format(shiftList.serial, shiftList.name) for shiftList in shiftLists] Label(isotopeFrame, text='Correct for isotope shift:', grid=(0, 0)) self.correctCheck = CheckButton(isotopeFrame, selected=True, callback=self.setCorrection, grid=(0, 1)) Label(isotopeFrame, text='Protonated shift list:', grid=(1, 0)) self.protonatedPulldown = PulldownList(isotopeFrame, callback=self.setProtonatedShiftList, texts=shiftListNames, objects=shiftLists, grid=(1, 1), index=0) Label(isotopeFrame, text='Deuterated shift list:', grid=(2, 0)) self.deuteratedPulldown = PulldownList(isotopeFrame, callback=self.setDeuteratedShiftList, texts=shiftListNames, objects=shiftLists, grid=(2, 1), index=1) # Table A1 headingList = ['#', 'shift lists', 'Assignment'] tipTexts = ['Spin System Serial', 'shift lists', 'The residue (tentatively) assigned to this spin system', 'The amount of spin systems that overlap with this spin system and have no violations'] editGetCallbacks = [self.setSpinSystem1]*3 editSetCallbacks = [None]*3 self.tableA1 = ScrolledMatrix(frameA1, headingList=headingList, multiSelect=False, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, tipTexts=tipTexts) self.tableA1.grid(row=0, column=0, sticky='nsew') # Table A2 headingList = ['#', 'shift lists', 'Assignment', 'offset'] tipTexts = ['Spin System Serial', 'The residue (tentatively) assigned to this spin system', 'Root mean squared deviation of this spin system to the spin system selected in the table on the left.'] editGetCallbacks = [self.setSpinSystem2]*4 editSetCallbacks = [None]*4 self.tableA2 = ScrolledMatrix(frameA2, headingList=headingList, #editWidgets=editWidgets, multiSelect=False, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, tipTexts=tipTexts) self.tableA2.grid(row=0, column=0, sticky='nsew') # Table B1 headingList = ['atom', 'c.s.'] tipTexts = ['atom', 'chemical shift'] self.tableB1 = ScrolledMatrix(frameB1, headingList=headingList, multiSelect=False, tipTexts=tipTexts) self.tableB1.grid(row=0, column=0, sticky='nsew') # Table B 2 headingList = ['atom', 'c.s. 1', 'c.s. 2', 'delta c.s.'] tipTexts = ['name of the atom', 'chemical shift of atom with this name in spin system 1', 'chemical shift of atom with this name in spin system 2', 'difference between the chemical shift of spin systems 1 and 2'] self.tableB2 = ScrolledMatrix(frameB2, headingList=headingList, tipTexts=tipTexts) self.tableB2.grid(row=0, column=0, sticky='nsew') # Table B 3 headingList = ['atom', 'c.s.'] tipTexts = ['atom', 'chemical shift.'] self.tableB3 = ScrolledMatrix(frameB3, headingList=headingList, multiSelect=False, tipTexts=tipTexts) self.tableB3.grid(row=0, column=0, sticky='nsew') self.matchMatrix = {} self.amountOfMatchesPerSpinSystem = {} self.updateTableA1()
def body(self, guiFrame): '''This method describes the outline of the body of the application. args: guiFrame: frame the body should live in. ''' self.geometry('800x530') guiFrame.grid_columnconfigure(0, weight=1) guiFrame.grid_rowconfigure(0, weight=0) guiFrame.grid_rowconfigure(1, weight=2) guiFrame.grid_rowconfigure(2, weight=1) isotopeFrame = LabelFrame(guiFrame, text='Isotope Shift Correction CA and CB') isotopeFrame.grid(row=0, column=0, sticky='nsew') frameA = LabelFrame(guiFrame, text='Spin Systems') frameA.grid(row=1, column=0, sticky='nsew') frameA.grid_rowconfigure(0, weight=1) frameA.grid_columnconfigure(0, weight=1) frameA.grid_columnconfigure(1, weight=1) frameA1 = LabelFrame(frameA, text='Spin System 1') frameA1.grid(row=0, column=0, sticky='nsew') frameA1.grid_columnconfigure(0, weight=1) frameA1.grid_rowconfigure(0, weight=1) frameA2 = LabelFrame(frameA, text='Spin System 2') frameA2.grid(row=0, column=1, sticky='nsew') frameA2.grid_columnconfigure(0, weight=1) frameA2.grid_rowconfigure(0, weight=1) frameB = LabelFrame(guiFrame, text='Comparison') frameB.grid(row=2, column=0, sticky='nsew') frameB.grid_rowconfigure(0, weight=1) frameB.grid_columnconfigure(0, weight=1) frameB.grid_columnconfigure(1, weight=2) frameB.grid_columnconfigure(2, weight=1) frameB1 = LabelFrame(frameB, text='Unique to Spin System 1') frameB1.grid(row=0, column=0, sticky='nsew') frameB1.expandGrid(0, 0) frameB2 = LabelFrame(frameB, text='Intersection') frameB2.grid(row=0, column=1, sticky='nsew') frameB2.expandGrid(0, 0) frameB3 = LabelFrame(frameB, text='Unique to Spin System 2') frameB3.grid(row=0, column=2, sticky='nsew') frameB3.expandGrid(0, 0) # Settings for isotope shift correction shiftLists = getShiftLists(self.nmrProject) self.protonatedShiftList = shiftLists[0] self.deuteratedShiftList = shiftLists[1] shiftListNames = [ '{}: {}'.format(shiftList.serial, shiftList.name) for shiftList in shiftLists ] Label(isotopeFrame, text='Correct for isotope shift:', grid=(0, 0)) self.correctCheck = CheckButton(isotopeFrame, selected=True, callback=self.setCorrection, grid=(0, 1)) Label(isotopeFrame, text='Protonated shift list:', grid=(1, 0)) self.protonatedPulldown = PulldownList( isotopeFrame, callback=self.setProtonatedShiftList, texts=shiftListNames, objects=shiftLists, grid=(1, 1), index=0) Label(isotopeFrame, text='Deuterated shift list:', grid=(2, 0)) self.deuteratedPulldown = PulldownList( isotopeFrame, callback=self.setDeuteratedShiftList, texts=shiftListNames, objects=shiftLists, grid=(2, 1), index=1) # Table A1 headingList = ['#', 'shift lists', 'Assignment'] tipTexts = [ 'Spin System Serial', 'shift lists', 'The residue (tentatively) assigned to this spin system', 'The amount of spin systems that overlap with this spin system and have no violations' ] editGetCallbacks = [self.setSpinSystem1] * 3 editSetCallbacks = [None] * 3 self.tableA1 = ScrolledMatrix(frameA1, headingList=headingList, multiSelect=False, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, tipTexts=tipTexts) self.tableA1.grid(row=0, column=0, sticky='nsew') # Table A2 headingList = ['#', 'shift lists', 'Assignment', 'offset'] tipTexts = [ 'Spin System Serial', 'The residue (tentatively) assigned to this spin system', 'Root mean squared deviation of this spin system to the spin system selected in the table on the left.' ] editGetCallbacks = [self.setSpinSystem2] * 4 editSetCallbacks = [None] * 4 self.tableA2 = ScrolledMatrix( frameA2, headingList=headingList, #editWidgets=editWidgets, multiSelect=False, editGetCallbacks=editGetCallbacks, editSetCallbacks=editSetCallbacks, tipTexts=tipTexts) self.tableA2.grid(row=0, column=0, sticky='nsew') # Table B1 headingList = ['atom', 'c.s.'] tipTexts = ['atom', 'chemical shift'] self.tableB1 = ScrolledMatrix(frameB1, headingList=headingList, multiSelect=False, tipTexts=tipTexts) self.tableB1.grid(row=0, column=0, sticky='nsew') # Table B 2 headingList = ['atom', 'c.s. 1', 'c.s. 2', 'delta c.s.'] tipTexts = [ 'name of the atom', 'chemical shift of atom with this name in spin system 1', 'chemical shift of atom with this name in spin system 2', 'difference between the chemical shift of spin systems 1 and 2' ] self.tableB2 = ScrolledMatrix(frameB2, headingList=headingList, tipTexts=tipTexts) self.tableB2.grid(row=0, column=0, sticky='nsew') # Table B 3 headingList = ['atom', 'c.s.'] tipTexts = ['atom', 'chemical shift.'] self.tableB3 = ScrolledMatrix(frameB3, headingList=headingList, multiSelect=False, tipTexts=tipTexts) self.tableB3.grid(row=0, column=0, sticky='nsew') self.matchMatrix = {} self.amountOfMatchesPerSpinSystem = {} self.updateTableA1()