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

    self.geometry('700x700')
   
    guiFrame.expandGrid(0,0)
    
    options = ['Peak Lists & Settings','Peak Intensity Comparison']
    tabbedFrame = TabbedFrame(guiFrame, options=options, callback=self.changeTab)
    tabbedFrame.grid(row=0, column=0, sticky='nsew')
    self.tabbedFrame = tabbedFrame
    frameA, frameB = tabbedFrame.frames

    row = 0
    frameA.grid_columnconfigure(1, weight=1)
    frameA.grid_columnconfigure(3, weight=1)
    frameA.grid_columnconfigure(5, weight=1)
    frameA.grid_rowconfigure(5, weight=1)

    tipText = 'Number of reference peaks (no saturation)'
    self.peaksALabel = Label(frameA, text='Number of Ref Peaks: ', tipText=tipText)
    self.peaksALabel.grid(row=1,column=0,columnspan=2,sticky='w')

    tipText = 'Number of NOE saturation peaks'
    self.peaksBLabel = Label(frameA, text='Number of Sat Peaks: ', tipText=tipText)
    self.peaksBLabel.grid(row=1,column=2,columnspan=2,sticky='w')

    tipText = 'Number of peaks in assigned list'
    self.peaksCLabel = Label(frameA, text='Number of Assign Peaks: ', tipText=tipText)
    self.peaksCLabel.grid(row=1,column=4,columnspan=2,sticky='w')
    
    tipText = 'Selects which peak list is considered the NOE intensity reference (no saturation)'
    specALabel = Label(frameA, text='Ref Peak List: ')
    specALabel.grid(row=0,column=0,sticky='w')
    self.specAPulldown = PulldownList(frameA, callback=self.setRefPeakList, tipText=tipText)
    self.specAPulldown.grid(row=0,column=1,sticky='w')

    tipText = 'Selects which peak list is considered as NOE saturated.'
    specBLabel = Label(frameA, text='Sat Peak List: ')
    specBLabel.grid(row=0,column=2,sticky='w')
    self.specBPulldown = PulldownList(frameA, callback=self.setSatPeakList, tipText=tipText)
    self.specBPulldown.grid(row=0,column=3,sticky='w')

    tipText = 'Selects a peak list with assignments to use as a positional reference'
    specCLabel = Label(frameA, text='Assignment Peak List: ')
    specCLabel.grid(row=0,column=4,sticky='w')
    self.specCPulldown = PulldownList(frameA, callback=self.setAssignPeakList, tipText=tipText)
    self.specCPulldown.grid(row=0,column=5,sticky='w')

    frame0a = Frame(frameA)
    frame0a.grid(row=2,column=0,columnspan=6,sticky='nsew')
    frame0a.grid_columnconfigure(9, weight=1)
    
    tipText = '1H ppm tolerance for matching assigned peaks to reference & NOE saturation peaks'
    tolHLabel   = Label(frame0a, text='Tolerances: 1H')
    tolHLabel.grid(row=0,column=0,sticky='w')
    self.tolHEntry = FloatEntry(frame0a,text='0.02', width=6, tipText=tipText)
    self.tolHEntry .grid(row=0,column=1,sticky='w')  

    tipText = '15N ppm tolerance for matching assigned peaks to reference & NOE saturation peaks'
    tolNLabel   = Label(frame0a, text=' 15N')
    tolNLabel .grid(row=0,column=2,sticky='w')   
    self.tolNEntry = FloatEntry(frame0a,text='0.1', width=6, tipText=tipText)
    self.tolNEntry .grid(row=0,column=3,sticky='w')   

    tipText = 'Whether to peak new peaks in reference & NOE saturated lists (at assignment locations)'
    label = Label(frame0a, text=' Pick new peaks?', grid=(0,4)) 
    self.pickPeaksSelect = CheckButton(frame0a, tipText=tipText,
                                       grid=(0,5), selected=True)

    tipText = 'Whether to assign peaks in the peaks in the reference & NOE saturation lists, if not already assigned'
    label = Label(frame0a, text=' Assign peaks?')
    label.grid(row=0,column=6,sticky='w')   
    self.assignSelect = CheckButton(frame0a, tipText=tipText)
    self.assignSelect.set(1)
    self.assignSelect.grid(row=0,column=7,sticky='w')    

    tipText = 'Whether to consider peak height or volume in the heteronuclear NOE calculation'
    intensLabel = Label(frame0a, text=' Intensity Type:')
    intensLabel .grid(row=0,column=8,sticky='w')   
    self.intensPulldown = PulldownList(frame0a, texts=['height','volume'],
                                       callback=self.setIntensityType,
                                       tipText=tipText)
    self.intensPulldown.grid(row=0,column=9,sticky='w')    

    divider = LabelDivider(frameA, text='Peaks', grid=(3,0),
                           gridSpan=(1,6))

    tipTexts = ['Show the selected intensity reference peaks in the below table',
                'Show the selected NOE saturation peaks in the below table',
                'Show the selected assigned peak list in the below table',
                'Show the displayed peaks in a separate peak table, where assignments etc. may be adjusted']
    texts    = ['Show Ref Peaks','Show Sat Peaks',
                'Show Assign Peaks', 'Separate Peak Table']
    commands = [self.viewRefPeakList, self.viewSatPeakList,
                self.viewAssignPeakList, self.viewSeparatePeakTable]
    self.viewPeaksButtons = ButtonList(frameA, expands=True, tipTexts=tipTexts,
                                       texts=texts, commands=commands)
    self.viewPeaksButtons.grid(row=4,column=0,columnspan=6,sticky='nsew')

    self.peakTable = PeakTableFrame(frameA, self.guiParent, grid=(5,0),
                                    gridSpan=(1,6))
    self.peakTable.bottomButtons1.grid_forget()
    self.peakTable.bottomButtons2.grid_forget()
    #self.peakTable.topFrame.grid_forget()
    self.peakTable.topFrame.grid(row=2, column=0, sticky='ew')
    # Next tab

    frameB.expandGrid(0,0)
    
    tipTexts = ['Row number',
                'Assignment annotation for NOE saturation peak',
                'Assignment annotation for reference peak (no saturation)',
                '1H chemical shift of NOE saturation peak',
                '1H chemical shift of reference peak',
                '15N chemical shift of NOE saturation peak',
                '15N chemical shift of reference peak',
                'The separation between compared peaks: square root of the sum of ppm differences squared',
                'The intensity if the NOE saturation peak',
                'The intensity of the reference peak (no saturation)',
                'Ratio of peak intensities: saturated over reference',
                'Residue(s) for reference peak']
    colHeadings      = ['#','Sat Peak','Ref Peak','1H shift A',
                        '1H shift B','15N shift A','15N shift B',
                        'Closeness\nScore','Intensity A','Intensity B',
                        'Intensity\nRatio','Residue']
    self.scrolledMatrix = ScrolledMatrix(frameB, multiSelect=True, 
                                         headingList=colHeadings,
                                         callback=self.selectCell,
                                         tipTexts=tipTexts,
                                         grid=(0,0),
                                         deleteFunc=self.removePair)

    tipTexts = ['Force a manual update of the table; pair-up NOE saturation and reference peaks according to assigned peak positions',
                'Remove the selected rows of peak pairs',
                'Show peaks corresponding to the selected row in a table',
                'Save the Heteronuclear NOE values in the CCPN project as a data list']
    texts    = ['Refresh Table','Remove Pairs',
                'Show Peak Pair','Create Hetero NOE List']
    commands = [self.matchPeaks,self.removePair,
                self.showPeakPair,self.makeNoeList]
    self.pairButtons = ButtonList(frameB, tipTexts=tipTexts, grid=(1,0),
                                  texts=texts, commands=commands)


    bottomButtons = UtilityButtonList(tabbedFrame.sideFrame, helpUrl=self.help_url)
    bottomButtons.grid(row=0, column=0, sticky='e')
    
    self.updatePulldowns()
    self.updateAfter()

    self.administerNotifiers(self.registerNotify)
Exemple #2
0
class ExtendNmrFrame(Frame):
    def __init__(self, guiParent, basePopup, project=None):
        # Base popup required to handle notification of data model changes
        # e.g. new peak lists, so that the GUI can update to the latest
        # state
        self.basePopup = basePopup
        self.guiParent = guiParent

        # FIXME JMCI
        # need to work through this far more carefully
        self.project = project

        # shortcuts to this layer
        self.basePopup.frameShortcuts['Task'] = self

        # shortcuts to layer below. We should set these in the
        # initMethod methods
        self.frameShortcuts = {}

        # TODO understand what these are doing
        self.registerNotify = basePopup.registerNotify
        self.unregisterNotify = basePopup.unregisterNotify

        Frame.__init__(self, guiParent)

        self.grid_rowconfigure(1, weight=1)
        self.grid_columnconfigure(0, weight=1)

        # Logos. Code nicked from ExtendNMR GUI
        ccpnDir = getTopDirectory()

        imageDir = os.path.join(ccpnDir, 'python', 'extendNmr', 'images')

        # basically nicked from Extend-NMR
        softwareOpts = [
            'Test1Task', 'ARIA 2', 'Auremol', 'CING', ' ECI ', 'HADDOCK',
            ' ISD ', 'PRODECOMP'
        ]

        self.tabbedFrame = TabbedFrame(guiParent,
                                       options=softwareOpts,
                                       toggleOff=False,
                                       selected=0)
        self.tabbedFrame.grid(row=1, column=0, sticky='nsew')

        frames = self.tabbedFrame.frames

        # Logos
        ccpnDir = getTopDirectory()

        imageDir = os.path.join(ccpnDir, 'python', 'extendNmr', 'images')

        imageFile = os.path.join(imageDir, 'Fp6Logo.gif')
        self.fp6Logo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'CingLogo.gif')
        self.cingLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'AriaLogo.gif')
        self.ariaLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'IsdLogo.gif')
        self.isdLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'HaddockLogo.gif')
        self.haddockLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'AuremolLogo.gif')
        self.auremolLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'CcpnLogo.gif')
        self.ccpnLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'ProdecompLogo.gif')
        self.prodecompLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'MddLogo.gif')
        self.mddLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'BrukerLogo.gif')
        self.brukerLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'MsdLogo.gif')
        self.msdLogo = Tkinter.PhotoImage(file=imageFile)

        # don't know what this does
        self.updateFuncs = []
        self.projButtons = []

        # basically nicked from Extend-NMR
        self.initTest1(frames[0])
        self.initAria(frames[1])
        self.initAuremol(frames[2])
        self.initCing(frames[3])
        #self.initEci(frames[4])
        #self.initHaddock(frames[5])
        self.initIsd(frames[6])
        self.initProdecomp(frames[7])

    def initTest1(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        # FIXME JMCI

        # Provide the basePopup for navigation purposes right now However,
        # there is a strong case for not making the method-specific Frames
        # dependent on the master. It might therefore be better to pass
        # the critical information directly, rather than passing a
        # reference to the basePopup which can then be used to extract it
        # indirectly

        test1Frame = Test1Frame(frame, self.basePopup)
        test1Frame.grid(row=1, column=0, sticky='nsew')

        self.frameShortcuts['Test1'] = test1Frame
        #self.projButtons.extend(cingFrame.buttonBar.buttons)
        self.updateFuncs.append(test1Frame.updateAll)

    def initAria(self, frame):

        welcomeMessage = \
        """ARIA Version 2.2. Authors: Benjamin Bardiaux, Michael Habeck,
Jens Linge, Therese Malliavin, Sean O'Donoghue, Wolfgang Rieping,
and Michael Nilges.

Rieping W., Habeck M., Bardiaux B., Bernard A., Malliavin T.E.,
Nilges M.(2007) ARIA2: automated NOE assignment and data
integration in NMR structure calculation. Bioinformatics 23:381-382"""

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        canvas = Tkinter.Canvas(frame, width=700, height=114, bg='#FFFFFF')
        canvas.grid(row=0, column=0, sticky='ew')
        canvas.create_image(0, 0, anchor='nw', image=self.ariaLogo)
        canvas.create_text(250, 10, anchor='nw', text=welcomeMessage)

        ariaFrame = AriaFrame(frame, self)
        ariaFrame.grid(row=1, column=0, sticky='nsew')

        self.frameShortcuts['ARIA'] = ariaFrame
        #self.projButtons.extend(ariaFrame.buttons)
        self.updateFuncs.append(ariaFrame.updateAll)

    def initAuremol(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(0, weight=1)

        auremolFrame = AuremolFrame(frame, self.project)
        auremolFrame.grid(row=0, column=0, sticky='nsew')

        self.frameShortcuts['AUREMOL'] = auremolFrame
        #self.projButtons.extend(isdFrame.buttons)
        self.updateFuncs.append(auremolFrame.updateAll)

    def initCing(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        canvas = Tkinter.Canvas(frame, width=702, height=77)
        canvas.grid(row=0, column=0)
        canvas.create_image(0, 0, anchor='nw', image=self.cingLogo)

        cingFrame = CingFrame(frame, self.project)
        cingFrame.grid(row=1, column=0, sticky='nsew')

        self.frameShortcuts['CING'] = cingFrame
        #self.projButtons.extend(cingFrame.buttonBar.buttons)
        self.updateFuncs.append(cingFrame.updateAll)

    def initEci(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)
        frame.parent = self  # For notifiers

        canvas = Tkinter.Canvas(frame, width=753, height=73, bg='#FFFFFF')
        canvas.grid(row=0, column=0)
        canvas.create_image(10, 10, anchor='nw', image=self.msdLogo)

        eciFrame = EntryCompletionFrame(frame, basePopup=self)
        eciFrame.grid(row=1, column=0, sticky='nsew')

        self.frameShortcuts['ECI'] = eciFrame
        #self.projButtons.extend(isdFrame.buttons)
        self.updateFuncs.append(eciFrame.updateAll)

    def initHaddock(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)
        frame.parent = self  # For notifiers

        canvas = Tkinter.Canvas(frame, width=753, height=92)
        canvas.grid(row=0, column=0)
        canvas.create_image(0, 0, anchor='nw', image=self.haddockLogo)

        haddockFrame = HaddockFrame(frame, self.project)
        haddockFrame.grid(row=1, column=0, sticky='nsew')

        self.frameShortcuts['HADDOCK'] = haddockFrame
        #self.projButtons.extend(isdFrame.buttons)
        self.updateFuncs.append(haddockFrame.updateAll)

    def initIsd(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        canvas = Tkinter.Canvas(frame, width=700, height=91, bg='#FFFFFF')
        canvas.grid(row=0, column=0, sticky='ew')
        canvas.create_image(0, 0, anchor='nw', image=self.isdLogo)

        isdFrame = IsdFrame(frame, self.project)
        isdFrame.grid(row=1, column=0, sticky='nsew')

        self.frameShortcuts['ISD'] = isdFrame
        #self.projButtons.extend(isdFrame.buttons)
        self.updateFuncs.append(isdFrame.updateAll)

    def initProdecomp(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        canvas = Tkinter.Canvas(frame, width=700, height=90, bg='#FFFFFF')
        canvas.grid(row=0, column=0)
        canvas.create_image(0, 0, anchor='nw', image=self.prodecompLogo)

        prodecompFrame = ProdecompFrame(frame,
                                        basePopup=self,
                                        ccpnProject=self.project)
        prodecompFrame.grid(row=1, column=0, sticky='nsew')

        self.frameShortcuts['PRODECOMP'] = prodecompFrame
        #self.projButtons.extend(isdFrame.buttons)
        self.updateFuncs.append(prodecompFrame.updateAll)

    # need to understand this method a little bit better
    def administerNotifiers(self, notifyFunc):

        for func in ('__init__', 'delete', 'setName'):
            notifyFunc(self.updateAllAfter, 'ccp.nmr.Nmr.Experiment', func)
            notifyFunc(self.updateAllAfter, 'ccp.nmr.Nmr.DataSource', func)

    def updateAllAfter(self, obj):

        self.after_idle(self.updateAll)

    def updateAll(self, project=None):

        if project:
            self.project = project
            self.nmrProject = project.currentNmrProject

            if not self.nmrProject:
                self.nmrProject = project.newNmrProject(name=project.name)

        if not self.project:
            return

    def quit(self):

        self.guiParent.parent.destroy()

    def destroy(self):

        self.administerNotifiers(self.basePopup.unregisterNotify)
        Frame.destroy(self)
Exemple #3
0
  def body(self, guiFrame):

    self.geometry('600x350')

    project = self.project
    analysisProject = self.analysisProject

    guiFrame.grid_columnconfigure(1, weight=1)

    row = 0
    frame = Frame(guiFrame, grid=(0,0))
    label = Label(frame, text=' Window:', grid=(0,0))
    self.windowPulldown = PulldownList(frame, grid=(0,1),
                                      tipText='The window that will be printed out',
                                      callback=self.selectWindow)
                                      
    tipTexts = ['For the window pulldown, show all of the spectrum windows in the current project, irrespective of the active group',
                'For the window pulldown, show only spectrum windows that are in the currently active window group']
    self.whichWindows = RadioButtons(frame, grid=(0,2),
                                     entries=ACTIVE_OPTIONS, tipTexts=tipTexts,
                                     select_callback=self.updateWindows)
    
    texts = [ 'Save Print File' ]
    tipTexts = [ 'Save the printout to the specified file' ]
    commands = [ self.saveFile ]
    buttons = UtilityButtonList(guiFrame, helpUrl=self.help_url, grid=(row,2),
                                commands=commands, texts=texts, tipTexts=tipTexts)
    self.buttons = buttons
    buttons.buttons[0].config(bg='#B0FFB0')
    
    row += 1
    guiFrame.grid_rowconfigure(row, weight=1)
    options = ['Options', 'Spectra', 'Peak Lists', 'Region']
    tipTexts = ['Optional settings for spectra', 'Optional settings for peak lists', 'Optional settings for the region']
    tabbedFrame = TabbedFrame(guiFrame, options=options, tipTexts=tipTexts)
    tabbedFrame.grid(row=row, column=0, columnspan=3, sticky='nsew')
    self.tabbedFrame = tabbedFrame

    optionFrame, spectrumFrame, peakListFrame, regionFrame = tabbedFrame.frames

    optionFrame.expandGrid(0, 0)
    getOption = lambda key, defaultValue: PrintBasic.getPrintOption(analysisProject, key, defaultValue)
    setOption = lambda key, value: PrintBasic.setPrintOption(analysisProject, key, value)
    self.printFrame = PrintFrame(optionFrame, getOption=getOption,
                                 grid=(0,0), gridSpan=(1,1),
                                 setOption=setOption, haveTicks=True,
                                 doOutlineBox=False)

    spectrumFrame.expandGrid(0, 0)
    frame = Frame(spectrumFrame, grid=(0,0), gridSpan=(1,1))
    frame.expandGrid(1,0)

    self.overrideSpectrum = CheckButton(frame,
       text='Use below settings when printing',
       tipText='Use below settings when printing instead of the window values',
       grid=(0,0), sticky='w')

    tipText = 'Change the settings of the selected spectra back to their window values'
    button = Button(frame, text='Reset Selected', tipText=tipText,
                    command=self.resetSelected, grid=(0,1), sticky='e')

    self.posColorPulldown = PulldownList(self, callback=self.setPosColor)
    self.negColorPulldown = PulldownList(self, callback=self.setNegColor)
    headings = ['Spectrum', 'Pos. Contours\nDrawn', 'Neg. Contours\nDrawn', 'Positive\nColours', 'Negative\nColours']
    tipTexts = ['Spectrum in window', 'Whether the positive contours should be drawn', 'Whether the negative contours should be drawn',
      'Colour scheme for positive contours (can be a single colour)', 'Colour scheme for negative contours (can be a single colour)']

    editWidgets      = [ None, None, None, self.posColorPulldown, self.negColorPulldown]
    editGetCallbacks = [ None, self.togglePos, self.toggleNeg, self.getPosColor, self.getNegColor]
    editSetCallbacks = [ None, None, None, self.setPosColor, self.setNegColor]
    self.spectrumTable = ScrolledMatrix(frame, headingList=headings,
                                        tipTexts=tipTexts,
                                        multiSelect=True,
                                        editWidgets=editWidgets,
                                        editGetCallbacks=editGetCallbacks,
                                        editSetCallbacks=editSetCallbacks,
                                        grid=(1,0), gridSpan=(1,2))

    peakListFrame.expandGrid(0, 0)
    frame = Frame(peakListFrame, grid=(0,0), gridSpan=(1,3))
    frame.expandGrid(1,0)

    self.overridePeakList = CheckButton(frame,
       text='Use below settings when printing',
       tipText='Use below settings when printing instead of the window values',
       grid=(0,0))

    tipText = 'Change the settings of the selected peak lists back to their window values'
    button = Button(frame, text='Reset Selected', tipText=tipText,
                    command=self.resetSelected, grid=(0,1), sticky='e')

    colors = Color.standardColors
    self.peakColorPulldown = PulldownList(self, callback=self.setPeakColor,
                                        texts=[c.name for c in colors],
                                        objects=[c.hex for c in colors],
                                        colors=[c.hex for c in colors])
    headings = [ 'Peak List', 'Symbols Drawn', 'Peak Font', 'Peak Colour']
    self.fontMenu = FontList(self, mode='Print', extraTexts=[no_peak_text])
    editWidgets      = [ None, None, self.fontMenu, self.peakColorPulldown]
    editGetCallbacks = [ None, self.togglePeaks, self.getPeakFont, self.getPeakColor ]
    editSetCallbacks = [ None, None, self.setPeakFont, self.setPeakColor ]
    self.peakListTable = ScrolledMatrix(frame, headingList=headings,
                                        multiSelect=True,
                                        editWidgets=editWidgets,
                                        editGetCallbacks=editGetCallbacks,
                                        editSetCallbacks=editSetCallbacks,
                                        grid=(1,0), gridSpan=(1,2))

    regionFrame.expandGrid(0, 0)
    frame = Frame(regionFrame, grid=(0,0), gridSpan=(1,3))
    frame.expandGrid(3,0)
    tipText = 'Use the specified override region when printing rather than the window values'
    self.overrideButton = CheckButton(frame, text='Use override region when printing',
                                      tipText=tipText,
                                      callback=self.toggledOverride, grid=(0,0))

    tipTexts = ('Use min and max to specify override region', 'Use center and width to specify override region')
    self.use_entry = USE_ENTRIES[0]
    self.useButtons = RadioButtons(frame, entries=USE_ENTRIES,
                                      tipTexts=tipTexts,
                                      select_callback=self.changedUseEntry,
                                      grid=(1,0))

    texts = ('Set Region from Window', 'Set Center from Window', 'Set Width from Window')
    tipTexts = ('Set the override region to be the current window region',
                'Set the center of the override region to be the center of the current window region',
                'Set the width of the override region to be the width of the current window region')
    commands = (self.setRegionFromWindow, self.setCenterFromWindow, self.setWidthFromWindow)
    self.setRegionButton = ButtonList(frame, texts=texts,
                                      tipTexts=tipTexts,
                                      commands=commands, grid=(2,0))

    self.minRegionWidget = FloatEntry(self, returnCallback=self.setMinRegion, width=10)
    self.maxRegionWidget = FloatEntry(self, returnCallback=self.setMaxRegion, width=10)
    headings = MIN_MAX_HEADINGS
    editWidgets      = [ None, None, self.minRegionWidget, self.maxRegionWidget ]
    editGetCallbacks = [ None, None, self.getMinRegion,    self.getMaxRegion ]
    editSetCallbacks = [ None, None, self.setMinRegion,    self.setMaxRegion ]
    self.regionTable = RegionScrolledMatrix(frame, headingList=headings,
                                            editWidgets=editWidgets,
                                            editGetCallbacks=editGetCallbacks,
                                            editSetCallbacks=editSetCallbacks,
                                            grid=(3,0))

    self.updateWindows()
    self.updateAfter()
    
    self.administerNotifiers(self.registerNotify)
Exemple #4
0
class AuremolFrame(Frame):

  def __init__(self, guiParent, ccpnProject=None, **kw):

    self.guiParent = guiParent
    self.project = ccpnProject
    self.spectrum = None
    self.peakMode = 0
    
    if ccpnProject:
      self.nmrProject = ccpnProject.currentNmrProject
    else:
      self.nmrProject = None
    
    Frame.__init__(self, guiParent, **kw)
  
    self.expandGrid(0,0)

    options = ['Peak Picking',] #,'About Auremol' 'NOE assignment','Homology Modelling',]
    self.tabbedFrame = TabbedFrame(self, options=options)
    self.tabbedFrame.grid(row=0,column=0,sticky='nsew')
    frameA = self.tabbedFrame.frames[0]
    
    #frameC.grid_columnconfigure(0, weight=1)
    #frameC.grid_rowconfigure(0, weight=1)
    #frameD.grid_columnconfigure(0, weight=1)
    #frameD.grid_rowconfigure(0, weight=1)
    
    #
    # Frame A
    #
    frameA.expandGrid(2,0)
    frameA.expandGrid(3,0)
    frameA.expandGrid(4,0)
    frameA.expandGrid(5,0)
    
    
    frame = Frame(frameA, grid=(0,0))
    frame.expandGrid(0,4)
    
    label = Label(frame, text='Spectrum:', grid=(0,0))
    self.spectrumPulldown = PulldownList(frame, self.changeSpectrum, grid=(0,1))
    
    label = Label(frame, text='  Use Peak Sign:', grid=(0,2))
    self.peakModePulldown = PulldownList(frame, self.changePeakMode, texts=PEAK_MODES,
                                         objects=[0,1,2], grid=(0,3))
    
    
    frame = Frame(frameA, grid=(1,0))
    frame.expandGrid(0,4)
    
    label = Label(frame, text='Integration Depth (Relative to max):', grid=(1,0))
    self.segLevelEntry = FloatEntry(frame, text=0.1, grid=(1,1), width=8)
    
    label = Label(frame, text='Threshold (Threshold only):', grid=(1,3))
    self.thresholdEntry = IntEntry(frame, text=100000, grid=(1,4), width=8)
    
    label = Label(frame, text='Keep Peaks (Adaptive only):', grid=(1,5))
    self.keepPeakEntry = IntEntry(frame, text=4000, grid=(1,6), width=8)
    
    texts = ['Threshold\nPeak Pick','Adaptive\nPeak Pick']
    commands = [self.pickThreshold, self.pickAdaptive]
    self.buttons = ButtonList(frameA, texts=texts, commands=commands,
                              grid=(2,0),  sticky='NSEW')
    
    frame = Frame(frameA, grid=(3,0))
    frame.expandGrid(0,0)
    frame = Frame(frameA, grid=(4,0))
    frame.expandGrid(0,0)
    frame = Frame(frameA, grid=(5,0))
    frame.expandGrid(0,0)
     
    #
    # About
    """
    frameB.expandGrid(4,0)

    label = Label(frameB, text='References', font='Helvetica 12 bold')
    label.grid(row=0, column=0, sticky='w')
    
    text = 
    * Gronwald W, Brunner K, Kirchhofer R, Nasser A, Trenner J, Ganslmeier B,
    Riepl H, Ried A, Scheiber J, Elsner R, Neidig K-P, Kalbitzer HR
    AUREMOL, a New Program for the Automated Structure Elucidation of Biological Macromolecules
    Bruker Reports 2004; 154/155: 11-14

    * Ried A, Gronwald W, Trenner JM, Brunner K, Neidig KP, Kalbitzer HR
    Improved simulation of NOESY spectra by RELAX-JT2 including effects of J-coupling,
    transverse relaxation and chemical shift anisotrophy
    J Biomol NMR. 2004 Oct;30(2):121-31

    * Gronwald W, Moussa S, Elsner R, Jung A, Ganslmeier B, Trenner J, Kremer W, Neidig KP, Kalbitzer HR
    Automated assignment of NOESY NMR spectra using a knowledge based method (KNOWNOE)
    J Biomol NMR. 2002 Aug;23(4):271-87

    * Gronwald W, Kirchhofer R, Gorler A, Kremer W, Ganslmeier B, Neidig KP, Kalbitzer HR
    RFAC, a program for automated NMR R-factor estimation
    J Biomol NMR. 2000 Jun;17(2):137-51
    
    label = Label(frameB, text=text)
    label.grid(row=1, column=0, sticky='w')
    """
   
    #
    # Frame C
    #

    
    #
    # Frame D
    #

  
    self.updateAll()
  
  def getEntryData(self):
  
    segLevel = self.segLevelEntry.get() or 0.001
    threshold = self.thresholdEntry.get() or 100000
    maxPeaks = self.keepPeakEntry.get() or 1
  
    segLevel = min(1.0, segLevel)
  
    self.segLevelEntry.set(segLevel)
    self.thresholdEntry.set(threshold)
    self.keepPeakEntry.set(maxPeaks)
  
    return segLevel, threshold, maxPeaks
  
  def pickThreshold(self):
  
    if self.spectrum:
      segLevel, threshold, maxPeaks = self.getEntryData()
      try:
        findAuremolPeaksThreshold(spectrum=self.spectrum, mode=self.peakMode,
                                  useAutoThreshold=0, threshold=threshold, seglevel=segLevel)
      except Exception, e:
        showError('pickThreshold', str(e), parent=self)
Exemple #5
0
  def body(self, guiFrame):
  
    guiFrame.grid_columnconfigure(0, weight=1)
    guiFrame.grid_rowconfigure(0, weight=1)

    options = ['Parameters','Restraints','Alignment Media & Tensors','About Meccano']
    tabbedFrame = TabbedFrame(guiFrame, options=options)
    tabbedFrame.grid(row=0, column=0, sticky='nsew')
    
    frameA, frameB, frameC, frameD = tabbedFrame.frames
    frameA.grid_columnconfigure(1, weight=1)
    frameA.grid_rowconfigure(13, weight=1)
    frameB.grid_columnconfigure(1, weight=1)
    frameB.grid_rowconfigure(1, weight=1)
    frameC.grid_columnconfigure(0, weight=1)
    frameC.grid_rowconfigure(1, weight=1)
    frameD.grid_columnconfigure(0, weight=1)
    frameD.grid_rowconfigure(0, weight=1)
    
    texts = ['Run MECCANO!']
    commands = [self.runMeccano]
    bottomButtons = createDismissHelpButtonList(guiFrame, texts=texts,
                                                commands=commands, expands=True)
    bottomButtons.grid(row=1, column=0, sticky='ew')

    if not Meccano:
      bottomButtons.buttons[0].disable()
  
    # Parameters
        
    row = 0
    label = Label(frameA, text='Calculation Run:')
    label.grid(row=row,column=0,sticky='w')
    self.runPulldown = PulldownList(frameA, callback=self.selectRun)
    self.runPulldown.grid(row=row,column=1,sticky='w')
    
    row += 1    
    label = Label(frameA, text='Shift List (for CO):')
    label.grid(row=row,column=0,sticky='w')
    self.shiftListPulldown = PulldownList(frameA, callback=self.selectShiftList)
    self.shiftListPulldown.grid(row=row,column=1,sticky='w')
           
    row += 1    
    label = Label(frameA, text='Keep Copy of Used Shifts:')
    label.grid(row=row,column=0,sticky='w')
    self.toggleCopyShifts = CheckButton(frameA)
    self.toggleCopyShifts.grid(row=row,column=1,sticky='w')
    self.toggleCopyShifts.set(True)
        
    row += 1    
    label = Label(frameA, text='Molecular System:')
    label.grid(row=row,column=0,sticky='w')
    self.molSystemPulldown = PulldownList(frameA, callback=self.selectMolSystem)
    self.molSystemPulldown.grid(row=row,column=1,sticky='w')
        
    row += 1    
    label = Label(frameA, text='Chain:')
    label.grid(row=row,column=0,sticky='w')
    self.chainPulldown = PulldownList(frameA, callback=self.selectChain)
    self.chainPulldown.grid(row=row,column=1,sticky='w')
    self.chainPulldown.bind('<Leave>', self.updateRunParams) 
        
    row += 1    
    label = Label(frameA, text='First Peptide Plane:')
    label.grid(row=row,column=0,sticky='w')
    self.firstResEntry = IntEntry(frameA, text=None, width=8)
    self.firstResEntry.grid(row=row,column=1,sticky='w')
    self.firstResEntry.bind('<Leave>', self.updateRunParams) 
        
    row += 1    
    label = Label(frameA, text='Last Peptide Plane:')
    label.grid(row=row,column=0,sticky='w')
    self.lastResEntry = IntEntry(frameA, text=None, width=8)
    self.lastResEntry.grid(row=row,column=1,sticky='w')
    self.lastResEntry.bind('<Leave>', self.updateRunParams) 
        
    row += 1    
    label = Label(frameA, text='Max Num Optimisation Steps:')
    label.grid(row=row,column=0,sticky='w')
    self.maxOptStepEntry = IntEntry(frameA, text=500, width=8)
    self.maxOptStepEntry.grid(row=row,column=1,sticky='w')
    self.maxOptStepEntry.bind('<Leave>', self.updateRunParams) 
        
    row += 1    
    label = Label(frameA, text='Num Optimisation Peptide Planes:')
    label.grid(row=row,column=0,sticky='w')
    self.numOptPlaneEntry = IntEntry(frameA, text=2, width=8)
    self.numOptPlaneEntry.grid(row=row,column=1,sticky='w')
    self.numOptPlaneEntry.bind('<Leave>', self.updateRunParams) 
        
    row += 1    
    label = Label(frameA, text='Min Num Optimisation Hits:')
    label.grid(row=row,column=0,sticky='w')
    self.numOptHitsEntry = IntEntry(frameA, text=5, width=8)
    self.numOptHitsEntry.grid(row=row,column=1,sticky='w')
    self.numOptHitsEntry.bind('<Leave>', self.updateRunParams) 

    row += 1    
    label = Label(frameA, text='File Name Prefix:')
    label.grid(row=row,column=0,sticky='w')
    self.pdbFileEntry = Entry(frameA, text='Meccano', width=8)
    self.pdbFileEntry.grid(row=row,column=1,sticky='w')
    self.pdbFileEntry.bind('<Leave>', self.updateRunParams) 
           
    row += 1    
    label = Label(frameA, text='Write Output File (.out):')
    label.grid(row=row,column=0,sticky='w')
    self.toggleWriteOutFile = CheckButton(frameA)
    self.toggleWriteOutFile.grid(row=row,column=1,sticky='w')
    self.toggleWriteOutFile.set(False)
    self.toggleWriteOutFile.bind('<Leave>', self.updateRunParams) 
           
    row += 1    
    label = Label(frameA, text='Write PDB File (.pdb):')
    label.grid(row=row,column=0,sticky='w')
    self.toggleWritePdbFile = CheckButton(frameA)
    self.toggleWritePdbFile.grid(row=row,column=1,sticky='w')
    self.toggleWritePdbFile.set(True)
    self.toggleWritePdbFile.bind('<Leave>', self.updateRunParams) 
    
    if not Meccano:
      row += 1    
      label = Label(frameA, text='The Meccano executable is not available (it needs to be compiled)', fg='red')
      label.grid(row=row,column=0,columnspan=2,sticky='w')

    # Restraints
    
    label = Label(frameB, text='Constraint Set:')
    label.grid(row=0,column=0,sticky='w')
    
    self.constraintSetPulldown = PulldownList(frameB, callback=self.selectConstraintSet)
    self.constraintSetPulldown.grid(row=0,column=1,sticky='w')
    
    self.alignMediumPulldown= PulldownList(self, callback=self.setAlignMedium)
    
    headingList = ['#','List Type','Use?','Alignment\nMedium','Num\nRestraints']
    editWidgets      = [None,None,None,self.alignMediumPulldown,None]
    editGetCallbacks = [None,None,self.toggleUseRestraints,self.getAlignMedium,None]
    editSetCallbacks = [None,None,None,self.setAlignMedium,None]
    self.restraintMatrix = ScrolledMatrix(frameB,
                                          headingList=headingList,
                                          editSetCallbacks=editSetCallbacks,
                                          editGetCallbacks=editGetCallbacks, 
                                          editWidgets=editWidgets,
                                          callback=None,
                                          multiSelect=True)
    self.restraintMatrix.grid(row=1,column=0,columnspan=2,sticky='nsew')
    
    
    # Alignment Media
    
    div = LabelDivider(frameC,text='Alignment Media')
    div.grid(row=0,column=0,sticky='ew')
    
    self.mediumNameEntry = Entry(self, returnCallback=self.setMediumName)
    self.mediumDetailsEntry = Entry(self, returnCallback=self.setMediumDetails)
    
    headingList = ['#','Name','Details','Static Tensor','Dynamic Tensor']
    editWidgets      = [None, self.mediumNameEntry, self.mediumDetailsEntry, None, None]
    editGetCallbacks = [None, self.getMediumName, self.getMediumDetails, None, None]
    editSetCallbacks = [None, self.setMediumName, self.setMediumDetails, None, None]
    self.mediaMatrix = ScrolledMatrix(frameC,
                                      headingList=headingList,
                                      editSetCallbacks=editSetCallbacks,
                                      editGetCallbacks=editGetCallbacks, 
                                      editWidgets=editWidgets,
                                      callback=self.selectAlignMedium,
                                      multiSelect=True)
                                 
    self.mediaMatrix.grid(row=1,column=0,sticky='nsew')
     
    
    texts = ['Add Alignment medium','Remove Alignment Medium']
    commands = [self.addAlignMedium,self.removeAlignMedium]
    buttonList = ButtonList(frameC, texts=texts, commands=commands, expands=True)
    buttonList.grid(row=2,column=0,sticky='nsew')
    
    self.editAxialEntry = FloatEntry(self, returnCallback=self.setAxial)
    self.editRhombicEntry = FloatEntry(self, returnCallback=self.setRhombic)
    self.editAlphaEulerEntry = FloatEntry(self, returnCallback=self.setEulerAlpha)
    self.editBetaEulerEntry = FloatEntry(self, returnCallback=self.setEulerBeta)
    self.editGammaEulerEntry = FloatEntry(self, returnCallback=self.setEulerGamma)
    
    
    div = LabelDivider(frameC,text='Alignment Tensors')
    div.grid(row=3,column=0,sticky='ew')
    
    headingList = ['Type', u'Axial (\u03B6)',u'Rhombic (\u03B7)',
                   u'Euler \u03B1',u'Euler \u03B2',u'Euler \u03B3']
    editWidgets      = [None,self.editAxialEntry,
                        self.editRhombicEntry,self.editAlphaEulerEntry,
                        self.editBetaEulerEntry,self.editGammaEulerEntry]
    editSetCallbacks = [None,self.setAxial,self.setRhombic,
                        self.setEulerAlpha,self.setEulerBeta,self.setEulerGamma]
    editGetCallbacks = [None,self.getAxial,self.getRhombic,
                        self.getEulerAlpha,self.getEulerBeta,self.getEulerGamma]
                   
    self.tensorMatrix = ScrolledMatrix(frameC, maxRows=2,
                                       headingList=headingList,
                                       editSetCallbacks=editSetCallbacks,
                                       editGetCallbacks=editGetCallbacks, 
                                       editWidgets=editWidgets,
                                       callback=self.selectTensor,
                                       multiSelect=True)
                                          
    self.tensorMatrix.grid(row=4,column=0,sticky='nsew')
    
    texts = ['Add Static Tensor','Add Dynamic Tensor','Remove Tensor']
    commands = [self.addStaticTensor,self.addDynamicTensor,self.removeTensor]
    buttonList = ButtonList(frameC,texts=texts, commands=commands, expands=True)
    buttonList.grid(row=5,column=0,sticky='ew')
       
    # About
    
    label = Label(frameD, text='About Meccano...')
    label.grid(row=0,column=0,sticky='w')
  
    #
  
    self.geometry('500x400')

    self.updateShiftLists()
    self.updateMolSystems()
    self.updateResidueRanges()
    self.updateConstraintSets()
    self.updateAlignMedia()
    self.updateRuns()
Exemple #6
0
class ApplicationPopup(BasePopup):

    help_url = 'http://www.ccpn.ac.uk'

    def __init__(self, root, programName='Ccpn Workflow Management System'):

        self.programName = programName
        self.font = DEFAULT_FONT
        # Application object needed to store application-specific data with project
        self.application = Application(name=PROGRAM_NAME)
        self.versionInfo = 'Version ' + VERSION
        self.ariaProjectFile = None

        self.username = None

        # what do these do??
        self.updateFuncs = []
        self.projButtons = []

        # may need these in the end
        self.ariaPaths = []
        self.isdPaths = []

        # FIXME JMCI

        # hard code this for now. this should be initialised from file
        # read during GUI login and then extended using the menu options

        # should set a placeholder. In fact, this placeholder will also have
        # a default user (guest) so that there is always a structure to
        # extend should the user wish to start from scratch and not log in

        self.repList = RepositoryList()
        self.currentTask = None

        # going to stick in shortcuts to frames for quick access
        self.frameShortcuts = {}

        # Application popup is a superclass of memops.editor.BasePoup
        BasePopup.__init__(self,
                           parent=root,
                           title=PROGRAM_NAME,
                           location='+100+100',
                           class_=self.application.name)

        self.setTitle(PROGRAM_NAME)

    def body(self, guiParent):

        self.geometry('700x600')

        # Ensure that the first row and column in popup expand
        guiParent.grid_rowconfigure(0, weight=1)
        guiParent.grid_columnconfigure(0, weight=1, minsize=200)
        frame = Frame(guiParent)  # Body widgets can be put in this frame
        frame.grid()

        # this is going to set up the options on the tabs. Really we need
        # stronger bookeeping between the options and the frames.  it
        # might make sense to define a master dictionary with option_name
        # => index. We can use this dictionary to build up the software
        # options and can also use it to define any refreshes etc (although
        # these would be better done through notifiers)

        softwareOpts = [
            'Repository', 'Project', 'Process', 'Client Tasks', 'Server Tasks',
            'Data Exchange', 'Workflow', 'Protocols', 'User'
        ]

        # FIXME JMCI

        # we should have a tidier tabbed frame. ned to discuss rules with
        # tjs but it would seem to make sense to have the tabs stretch
        # across the entire top of the frame. Check the existing options
        # first, though

        self.tabbedFrame = TabbedFrame(guiParent,
                                       options=softwareOpts,
                                       toggleOff=False,
                                       selected=0)
        self.tabbedFrame.grid(row=0, column=0, sticky='nsew')

        frames = self.tabbedFrame.frames

        # Logos
        ccpnDir = getTopDirectory()
        imageDir = os.path.join(ccpnDir, 'python', 'extendNmr', 'images')
        imageFile = os.path.join(imageDir, 'CcpnLogo.gif')
        self.ccpnLogo = Tkinter.PhotoImage(file=imageFile)

        # Dictionary to store popups opened by this application - e.g. need to close upon quit
        self.popups = {}

        # Default font
        self.font = 'Helvetica 10'

        # Closing the window from the desktop environment calls the proper quit
        self.protocol('WM_DELETE_WINDOW', self.quit)

        # jmci we are going to have to change these drastically
        self.mainMenu = Menu(self)
        self.userMenu = self.makeUserMenu()
        self.repositoryMenu = self.makeRepositoryMenu()
        self.otherMenu = self.makeOtherMenu()

        # Put the top level menu
        self.config(menu=self.mainMenu)
        self.initRepository(frames[0])
        self.initProjectFrame(frames[1])
        self.initWms(frames[2])
        self.initTasks(frames[3])
        self.initDataExch(frames[5])
        self.initWorkflow(frames[6])
        self.initProtocol(frames[7])
        self.initUserFrame(frames[8])

        self.initProject()

        if not self.project:
            for button in self.projButtons:
                button.disable()

        # the main client side daemon. This is going to run in the background
        # and control the task processing
        self.taskDaemon = TaskManager(self)
        self.taskDaemon.active = False
        self.taskDaemon.start()

    ## THE TABBED FRAMES ##

    def initRepository(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        repositoryFrame = RepositoryFrame(frame, basePopup=self)
        repositoryFrame.grid(row=1, column=0, sticky='nsew')

        self.updateFuncs.append(repositoryFrame.updateAll)

    def initProjectFrame(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        self.projectFrame = ProjectFrame(frame, basePopup=self)
        self.projectFrame.grid(row=1, column=0, sticky='nsew')

        self.updateFuncs.append(self.projectFrame.updateAll)

    def initWms(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        extendNmrFrame = ExtendNmrFrame(frame, basePopup=self)
        extendNmrFrame.grid(row=1, column=0, sticky='nsew')

        self.updateFuncs.append(extendNmrFrame.updateAll)

    def initTasks(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        tasksFrame = TasksFrame(frame, self)
        tasksFrame.grid(row=1, column=0, sticky='nsew')

        self.updateFuncs.append(tasksFrame.updateAll)

    def initDataExch(self, frame):

        row = 0
        frame.config(bg='#E6E6E6')

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        dataExchFrame = DataExchFrame(frame, basePopup=self)
        dataExchFrame.grid(row=1, column=0, sticky='nsew')

        self.updateFuncs.append(dataExchFrame.updateAll)

    def initWorkflow(self, frame):

        row = 0
        frame.config(bg='#FFFFFF')

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        workflowFrame = WorkflowFrame(frame, basePopup=self)
        workflowFrame.grid(row=1, column=0, sticky='nsew')

        self.updateFuncs.append(workflowFrame.updateAll)

    def initProtocol(self, frame):

        row = 0
        frame.config(bg='#FFFFFF')

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        protocolFrame = ProtocolFrame(frame, basePopup=self)
        protocolFrame.grid(row=1, column=0, sticky='nsew')

        self.updateFuncs.append(protocolFrame.updateAll)

    def initUserFrame(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        row = 0
        frame.config(bg='#FFFFFF')

        userFrame = UserFrame(frame, basePopup=self)
        userFrame.grid(row=1, column=0, sticky='nsew')

        self.updateFuncs.append(userFrame.updateAll)

    ## The Menu ##

    def makeUserMenu(self):
        menu = Menu(self.mainMenu, tearoff=0)
        menu.add_command(label='Log In',
                         shortcut='I',
                         command=self.openLoginPopup)
        menu.add_command(label='Log Out', shortcut='O', command=self.logout)
        menu.add_command(label='Save Profile',
                         shortcut='S',
                         command=self.tmpCall)
        menu.add_command(label='View Profile',
                         shortcut='V',
                         command=self.tmpCall)
        menu.add_command(label='Create Profile',
                         shortcut='C',
                         command=self.tmpCall)
        menu.add_command(label='Edit Profile',
                         shortcut='E',
                         command=self.tmpCall)
        self.mainMenu.add_cascade(label='User', shortcut='U', menu=menu)
        menu.options = [
            'Log In', 'Log Out', 'Save Profile', 'View Profile',
            'Create Profile', 'Edit Profile'
        ]
        return menu

    def makeRepositoryMenu(self):
        self.repMenu = Menu(self.mainMenu, tearoff=0)
        # Add various options to the menu and state the functions they call
        self.repMenu.add_command(label='Manager',
                                 shortcut='M',
                                 command=self.tmpCall)
        self.repMenu.add_command(label='Connect',
                                 shortcut='C',
                                 command=self.openRepository)

        # doesn't really work to have a disconnect; we do not have a list
        # of repositories and so would it refer to? Better to do this from
        # within the RepositoryFrame

        self.repMenu.add_command(label='Disconnect',
                                 shortcut='D',
                                 command=self.tmpCall)

        # again, this is functionality that would make sense but which it is hard to put
        # in the top level menu because it is not obvious which repository it refers
        # to

        self.repMenu.add_command(label='Import Project',
                                 shortcut='I',
                                 command=self.tmpCall)
        self.repMenu.add_command(label='Export Project',
                                 shortcut='E',
                                 command=self.tmpCall)

        # FIXME JMCI

        # the quit option needs to be tied to a dialogue box that asks whether
        # the current connection state should be saved. This will have to be
        # secured and so means that the GUI should have a login itself (beyond
        # the logins for the various resources).

        self.repMenu.add_command(label='Quit', shortcut='Q', command=self.quit)

        self.mainMenu.add_cascade(label='Repository',
                                  shortcut='R',
                                  menu=self.repMenu)
        self.repMenu.options = [
            'Connect', 'Disconnect', 'Import Project', 'Export Project', 'Quit'
        ]
        return self.repMenu

    def makeProjectMenu(self):

        # Submenu of the min menu
        menu = Menu(self.mainMenu, tearoff=0)
        # Add various options to the menu and state the functions they call
        menu.add_command(label='New', shortcut='N', command=self.newProject)
        menu.add_command(label='Open', shortcut='O', command=self.openProject)
        menu.add_command(label='Close',
                         shortcut='C',
                         command=self.closeProject)
        menu.add_command(label='Save', shortcut='S', command=self.saveProject)
        menu.add_command(label='Save As',
                         shortcut='A',
                         command=self.saveAsProject)
        menu.add_command(label='Quit', shortcut='Q', command=self.quit)
        menu.add_command(label='Version',
                         shortcut='V',
                         command=self.showVersion)
        self.mainMenu.add_cascade(label='Project', shortcut='P', menu=menu)

        menu.options = [
            'New', 'Open', 'Close', 'Save', 'Save As', 'Quit', 'Version'
        ]
        return menu

    def makeOtherMenu(self):

        # The fonts menu is a pre-created widget
        fontsMenu = FontMenu(self.mainMenu,
                             self.setFont,
                             sizes=(8, 10, 12),
                             doItalic=0,
                             doBoldItalic=0,
                             tearoff=0)

        # Submenu of the min menu
        menu = Menu(self.mainMenu, tearoff=0)
        # Only Fonts option so far
        menu.add_cascade(label='Fonts', shortcut='F', menu=fontsMenu)
        self.mainMenu.add_cascade(label='Options', shortcut='O', menu=menu)

        menu.options = [
            'Fonts',
        ]
        return menu

    def makeCcpNmrMenu(self):

        try:
            from ccpnmr.analysis.AnalysisPopup import AnalysisPopup
            haveAnalysis = True
        except ImportError:
            haveAnalysis = False

        try:
            from ccpnmr.format.gui.FormatConverter import FormatConverter
            from ccpnmr.format.gui.DataShifter import DataShifter
            haveFormatConv = True
        except ImportError:
            haveFormatConv = False

        menu = Menu(self.mainMenu, tearoff=0)

        if haveAnalysis:
            menu.add_command(label='Analysis',
                             shortcut='A',
                             command=self.ccpNmrAnalysis)
        else:
            menu.add_command(label='Analysis ** NOT INSTALLED **',
                             shortcut='A',
                             command=None)

        if haveFormatConv:
            menu.add_command(label='Format Converter',
                             shortcut='F',
                             command=self.ccpNmrFormatConverter)
            menu.add_command(label='Data Shifter',
                             shortcut='D',
                             command=self.ccpNmrDataShifter)
        else:
            menu.add_command(label='Format Converter ** NOT INSTALLED **',
                             shortcut='F',
                             command=None)
            menu.add_command(label='Data Shifter ** NOT INSTALLED **',
                             shortcut='D',
                             command=None)

        self.mainMenu.add_cascade(label='CcpNmr', shortcut='C', menu=menu)

        menu.options = ['Analysis', 'Format Converter', 'Data Shifter']
        return menu

    def ccpNmrAnalysis(self, cacheSize=64):

        from ccpnmr.analysis.AnalysisPopup import AnalysisPopup
        analysis = AnalysisPopup(self, cache_size=cacheSize, glDirect=None)
        analysis.update_idletasks()  # fast
        if self.project:
            analysis.initProject(self.project)

    def ccpNmrFormatConverter(self):

        from ccpnmr.format.gui.FormatConverter import FormatConverter
        fc = FormatConverter(self, threading=False, project=self.project)
        fc.open()
        if self.project:
            fc.initProject(self.project)

    def ccpNmrDataShifter(self):

        from ccpnmr.format.gui.DataShifter import DataShifter
        ds = DataShifter(self)
        ds.open()

    def newProject(self):

        if self.project:
            # Project already present
            if not self.closeProject():
                # If we don't close the current project do nothing
                return

        name = askString(title='Project name',
                         prompt='Enter project name:',
                         parent=self)

        if name:
            # Make the API Project object
            project = Implementation.MemopsRoot(name=name)
            nmrProject = project.newNmrProject(name=name)
            self.initProject(project)

    # placeholder method until we write code

    def tmpCall(self):

        return

    def openProject(self):

        if self.project:
            if not self.closeProject():
                return

        self.openPopup('open_project',
                       OpenProjectPopup,
                       callback=self.initProject)

    def openLoginPopup(self):

        # at the moment we do this through methods in the popup. It
        # would be much more sensible to do this through some
        # sort of callback.

        login_popup = LoginPopup(self)

        # really we want to imoblise the rest. how to do?

    def setRepository(self, rep):

        self.repList.currentRepository = rep

        if self.frameShortcuts.has_key('Repository'):
            self.frameShortcuts['Repository'].drawFrame()

        if self.frameShortcuts.has_key('Tasks'):
            self.frameShortcuts['Tasks'].drawFrame()
        #for ff in self.tabbedFrame.frames[0].children.values():
        #  ff.draw()

        #for ff in self.tabbedFrame.frames[3].children.values():
        #  ff.draw()

        for ff in self.tabbedFrame.frames[8].children.values():
            ff.draw()

    def openRepository(self):

        rep_popup = RepositoryPropertiesPopup(self)

    def closeRepository(self):

        pass

    def logout(self):

        self.setUsername(None)
        self.repList = RepositoryList()

        print 'in logout ', self.repList
        print '#########################'

        print self.tabbedFrame.frames[0].__dict__
        print '#########################'

        if self.frameShortcuts.has_key('Repository'):
            self.frameShortcuts['Repository'].drawFrame()

        #for ff in self.tabbedFrame.frames[0].children.values():
        #  ff.draw()
        for ff in self.tabbedFrame.frames[8].children.values():
            ff.draw()

    def openPopup(self, popup_name, clazz, oldStyle=False, *args, **kw):

        popup = self.popups.get(popup_name)

        if (popup):
            popup.open()
        else:
            if self.project:
                analysisProfile = self.analysisProfile
            else:
                analysisProfile = None

            if analysisProfile:
                transient = analysisProfile.transientDialogs
            else:
                transient = True

            name = popup_name

            if (oldStyle):
                popup = self.popups[popup_name] = clazz(self,
                                                        transient=transient,
                                                        *args,
                                                        **kw)
            else:
                popup = self.popups[popup_name] = clazz(self,
                                                        project=self.project,
                                                        popup_name=name,
                                                        transient=transient,
                                                        *args,
                                                        **kw)
            # above automatically opens popup

        return popup

    def closeProject(self, queryClose=True, querySave=True):

        if queryClose:
            if not showYesNo(
                    'Close project', 'Close current project?', parent=self):
                return False

        if querySave:
            if not self.checkSaving():
                return False

        self.destroyPopups()
        self.initProject()

        return True

    def saveProject(self):

        self.saveFile()

        # NBNB Rasmus 22/8/08 changed to fit AnalysisPopup (and removed 'isStored' bug)
        #if (self.project.isStored):
        #  self.saveFile()
        #else:
        #  self.askSaveFile()

    def saveAsProject(self):

        self.askSaveFile()

    def showVersion(self):

        showInfo('Version', self.versionInfo, parent=self)

    def changeFont(self, analysisProfile):

        if analysisProfile is self.analysisProfile:
            if self.font != analysisProfile.font:
                self.font = analysisProfile.font or DEFAULT_FONT
                self.setFont()

    def selectFont(self, font):  # Only called from main menu option

        if self.project:
            self.analysisProfile.font = font

    def setFont(self, font=None, popup=None):

        if font is None:
            font = self.font or DEFAULT_FONT

        else:
            self.font = font

        if not popup:
            popup = self

        childList = popup.children.values()

        classes = [
            Tkinter.Button, Tkinter.Label, Tkinter.Menu, Tkinter.Entry,
            Tkinter.Checkbutton, Tkinter.Radiobutton
        ]

        for child in childList:
            for clazz in classes:
                if isinstance(child, clazz):
                    if hasattr(child, 'font'):
                        if not child.font:
                            child.config(font=font)
                    else:
                        child.config(font=font)
                    break

            if isinstance(child, Tkinter.Frame):
                child.font = font

            elif isinstance(child, ScrolledMatrix):
                child.setFont(font)

            if hasattr(child, 'children'):
                childList.extend(child.children.values())

    def initProject(self, project=None):

        self.project = project
        if project:
            self.initTopObjects(self.project)
            self.project.application = self.application
            self.setFont()
            webBrowser = ProjectWebBrowser(self.top,
                                           popup=self,
                                           project=project)
            #self.helpButton.config(command = lambda url=self.help_url: webBrowser.open(url) )

            for i, func in enumerate(self.updateFuncs):
                func(project)

            for button in self.projButtons:
                button.enable()

            self.setupSoftware()

        else:
            for button in self.projButtons:
                button.disable()

        self.setMenuState()

    def setUsername(self, name):

        self.username = name

        print 'set username ', self.username

    # jmci FIXME

    # need to look into this carefully and analyse the possible
    # states

    def setMenuState(self):

        if self.project:
            state = Tkinter.NORMAL
        else:
            state = Tkinter.DISABLED

        # Disable bits of the project menu if there's no project
        #for option in ('Save','Save As','Close'):
        #  i = self.projectMenu.options.index(option)
        #  self.projectMenu.entryconfig(i, state=state)

        # Disable other manus if there's no project
        #for menu in [self.otherMenu,]: # Include more menus in this list
        #  for i in range(len(menu.options)):
        #    menu.entryconfig(i, state=state)

    def setupSoftware(self):

        project = self.project

        methodStore = project.currentMethodStore or \
                      project.findFirstMethodStore() or \
                      project.newMethodStore(name=project.name)

        software = methodStore.findFirstSoftware(name=PROGRAM_NAME,
                                                 version=VERSION)
        if not software:
            software = methodStore.newSoftware(name=PROGRAM_NAME,
                                               version=VERSION)

        #software.vendorName = 'PDBe & CCPN'
        #software.vendorAddress = ''
        #software.vendorWebAddress = 'http:'
        #software.details = ''

    def askSaveFile(self):

        popup = self.openPopup('save_project', SaveProjectPopup)
        popup.refresh()

    def modalAskSaveFile(self):

        popup = SaveProjectPopup(self,
                                 project=self.project,
                                 dismiss_text='Cancel Quit',
                                 modal=True)
        did_save = popup.did_save
        popup.destroy()

        return did_save

    def quitSaveProject(self):

        if (self.project.activeRepositories):
            return self.saveFile()
        else:
            return self.modalAskSaveFile()

    def destroyPopups(self):

        for key in self.popups.keys():
            popup = self.popups[key]
            popup.destroy()

        self.popups = {}

    ## WMS methods

    # should maybe merge this with setUsername

    # this will read a config file that stores user setups. How this
    # is done TBD so hack for now and just return
    def readConfig(self, userName):

        # this should return the full RepositoryList structure. In reality this
        # will parse from file. set it by hand from here for now for speed
        repList = RepositoryList(userName)

        rep1 = repList.newRepository('remote', 'localhost:8080/HalxService',
                                     'ccpn', 'remote')
        repList.currentRepository = rep1
        # should these be directory objects?
        repList.current_export_dir = '/home/jionides/work/CCPN/test_JMCI_data'
        repList.current_import_dir = '/home/jionides/work/CCPN/test_EXP_data'

        self.repList = repList

        print 'in readconfig '

        self.setRepository(rep1)

        # really should be done through notifiers
        if self.frameShortcuts.has_key('Repository'):
            self.frameShortcuts['Repository'].drawFrame()

        if self.frameShortcuts.has_key('Tasks'):
            self.frameShortcuts['Tasks'].drawFrame()

        if self.frameShortcuts.has_key('DataExch'):
            self.frameShortcuts['DataExch'].drawFrame()

        for ff in self.tabbedFrame.frames[8].children.values():
            ff.draw()

        # want to update the top menu. The idea should be to add a bar item
        # and then to list all the repositories underneath. Clicking on a given
        # repository will set the home repository as current. That seems to
        # be a good sensible way of simplifying the interface in a expected
        # way. We could, alternatively, use tabs.

        opts = {}
        self.repMenu.add('separator', **opts)

        for rep in repList.repositories:
            item = {
                'command': lambda rep=rep: self.setRepository(rep),
                'label': rep.name
            }
            self.repMenu.add('comman', **item)

        self.repMenu.config()

    ## end WMS methods

    def copyModifiedStorages(self):

        modifiedStorages = [
            storage for storage in self.project.storages if storage.isModified
        ]
        if (self.project.isModified):
            modifiedStorages.append(self.project)

        for storage in modifiedStorages:
            self.copyStorage(storage)

    def saveFile(self):

        if not self.project:
            return False

        try:
            saveProject(self.project, createFallback=True)

            print 'successfully saved project'
            return True
        except IOError, e:
            showError('Saving file', str(e), parent=self)
            return False
Exemple #7
0
    def body(self, guiFrame):

        self.geometry('450x500')

        guiFrame.grid_rowconfigure(0, weight=1)
        guiFrame.grid_columnconfigure(0, weight=1)

        options = ['Peak Separator', 'Advanced Settings']

        tabbedFrame = TabbedFrame(guiFrame, options=options)
        tabbedFrame.grid(row=0, column=0, sticky='nsew')

        buttons = UtilityButtonList(tabbedFrame.sideFrame,
                                    helpUrl=self.help_url)
        buttons.grid(row=0, column=0, sticky='e')

        self.tabbedFrame = tabbedFrame
        frameA, frameB = tabbedFrame.frames

        #
        # FrameA : Main Settings
        #

        frameA.grid_columnconfigure(1, weight=1)
        row = 0  # Label row

        row += 1
        div = LabelDivider(frameA, text='Peak Separator Parameters')
        div.grid(row=row, column=0, columnspan=2, sticky='ew')

        row += 1
        label = Label(frameA, text='Min. number of peaks:')
        label.grid(row=row, column=0, sticky='w')
        self.minPeaksEntry = IntEntry(frameA, returnCallback=self.applyChange, width=10, \
              tipText='Minimum number of peaks to find (must be > 0)')
        self.minPeaksEntry.grid(row=row, column=1, sticky='n')
        self.minPeaksEntry.bind('<Leave>', self.applyChange, '+')

        row += 1
        label = Label(frameA, text='Max. number of peaks:')
        label.grid(row=row, column=0, sticky='w')
        self.maxPeaksEntry = IntEntry(frameA, returnCallback=self.applyChange, width=10, \
              tipText='Maximum number of peaks to find (0 is unlimited - not recommended)')
        self.maxPeaksEntry.grid(row=row, column=1, sticky='n')
        self.maxPeaksEntry.bind('<Leave>', self.applyChange, '+')

        row += 1
        label = Label(frameA, text='Only pick positive peaks:')
        label.grid(row=row, column=0, sticky='w')
        entries = ['False', 'True']
        self.posPeaksButtons = RadioButtons(
            frameA,
            entries=entries,
            select_callback=self.applyChange,
            direction='horizontal',
            tipTexts=[
                'Search for both positive and negative intensity peaks',
                'Limit search to only positive peaks'
            ])
        self.posPeaksButtons.grid(row=row, column=1, sticky='n')

        row += 1
        label = Label(frameA, text='Peak Model:')
        label.grid(row=row, column=0, sticky='w')
        ### G/L Mixture works, but volume calculation involves Gamma function
        # entries = ['Gaussian', 'Lorentzian', 'G/L Mixture']
        entries = ['Gaussian', 'Lorentzian']
        self.shapeButtons = RadioButtons(
            frameA,
            entries=entries,
            select_callback=self.applyChange,
            direction='horizontal',
            tipTexts=[
                'Choose a Gaussian model peak shape to fit to peaks',
                'Choose a Lorentzian model peak shape to fit to peaks'
            ])
        self.shapeButtons.grid(row=row, column=1, sticky='n')

        row += 1
        div = LabelDivider(frameA,
                           text='Region',
                           tipText='Region that search will limit itself to')
        div.grid(row=row, column=0, columnspan=2, sticky='ew')

        row += 1
        label = Label(frameA, text='Peak List:')
        label.grid(row=row, column=0, sticky='nw')
        self.peakListPulldown = PulldownList(
            frameA,
            callback=self.setManuallyPickPeakList,
            tipText='Select which peak list new peaks are to be added to')
        self.peakListPulldown.grid(row=row, column=1, sticky='nw')

        # tricky scrolled matrix
        row += 1
        self.regionTable = None
        frameA.grid_rowconfigure(row, weight=1)
        headings = ('dim.', 'start (ppm)', 'end (ppm)', 'actual size')

        self.editDimEntry = IntEntry(self,
                                     returnCallback=self.applyChange,
                                     width=5,
                                     tipText='Dimension number')
        self.editStartEntry = FloatEntry(self,
                                         returnCallback=self.applyChange,
                                         width=5,
                                         tipText='Search area lower bound')
        self.editEndEntry = FloatEntry(self,
                                       returnCallback=self.applyChange,
                                       width=5,
                                       tipText='Search area upper bound')

        editWidgets = [
            self.editDimEntry, self.editStartEntry, self.editEndEntry, None
        ]

        editGetCallbacks = [None, None, None, None]
        editSetCallbacks = [None, None, None, None]

        self.regionTable = ScrolledMatrix(frameA,
                                          headingList=headings,
                                          multiSelect=False,
                                          editWidgets=editWidgets,
                                          editGetCallbacks=editGetCallbacks,
                                          editSetCallbacks=editSetCallbacks,
                                          initialRows=5)

        self.regionTable.grid(row=row, column=0, columnspan=2, sticky='nsew')

        # Run Button
        row += 1
        texts = ['Add Region']
        commands = [self.updateFromRegion]
        self.addResetButtons = ButtonList(
            frameA,
            texts=texts,
            commands=commands,
            tipTexts=['Add selected specrtral region'])
        self.addResetButtons.grid(row=row, column=0, columnspan=2, sticky='ew')

        row += 1
        texts = ['Separate Peaks']
        commands = [self.runPeakSeparator]
        self.runButton = ButtonList(frameA,
                                    texts=texts,
                                    commands=commands,
                                    expands=True,
                                    tipTexts=['Run peak search now'])
        self.runButton.grid(row=row, column=0, columnspan=2, sticky='nsew')

        #
        # FrameB : Further Settings
        #

        frameB.grid_columnconfigure(0, weight=1)

        row = 0

        div = LabelDivider(frameB, text='Rate:')
        div.grid(row=row, column=0, columnspan=2, sticky='ew')
        row += 1

        label = Label(frameB, text='Rate of MCMC step size change')
        label.grid(row=row, column=0, columnspan=1, sticky='w')

        self.rateEntry = FloatEntry(frameB, returnCallback=self.applyChange, width=10, \
              tipText='Rate effects speed of run, smaller values take longer but may produce better results')
        self.rateEntry.grid(row=row, column=1, sticky='n')
        self.rateEntry.bind('<Leave>', self.applyChange, '+')
        self.rateEntry.set(self.params.rate)

        # tricky scrolled matrix for line width
        row += 2
        div = LabelDivider(frameB, text='Line Width (Hz):')
        div.grid(row=row, column=0, columnspan=2, sticky='ew')

        row += 1
        label = Label(frameB, text="Descr.")
        label.grid(row=row, rowspan=2, column=0, sticky='w')

        row += 1
        self.lineWidthTable = None
        frameB.grid_rowconfigure(row, weight=1)
        lineWidthHeadings = ('dim.', 'min. σ (Hz)', 'max. σ (Hz)')

        self.editMinSigmaEntry = FloatEntry(self,
                                            returnCallback=self.applyChange,
                                            width=5,
                                            tipText='Minimum line width (Hz)')
        self.editMaxSigmaEntry = FloatEntry(self,
                                            returnCallback=self.applyChange,
                                            width=5,
                                            tipText='Maximum line width (Hz)')

        # self.editDimEntry is also from regionTable
        initialWidthRows = 4

        editLineWidthWidgets = [
            None, self.editMinSigmaEntry, self.editMaxSigmaEntry
        ]
        editLineWidthGetCallbacks = [None, self.getSigmaMin, self.getSigmaMax]
        editLineWidthSetCallbacks = [None, self.setSigmaMin, self.setSigmaMax]

        self.lineWidthTable = ScrolledMatrix(
            frameB,
            headingList=lineWidthHeadings,
            multiSelect=False,
            editWidgets=editLineWidthWidgets,
            editGetCallbacks=editLineWidthGetCallbacks,
            editSetCallbacks=editLineWidthSetCallbacks,
            initialRows=initialWidthRows)

        self.lineWidthTable.grid(row=row,
                                 column=0,
                                 columnspan=2,
                                 sticky='nsew')

        # option to 'repick' exisiting peak list
        row += initialWidthRows
        div = LabelDivider(frameB, text='(optional - repick entire peak list)')
        div.grid(row=row, column=0, columnspan=2, sticky='ew')
        row += 1

        self.repickListPulldown = PulldownList(
            frameB,
            callback=self.setRePickPeakList,
            tipText=
            'Select which peak list to repick (new peaks will be put into a new peak list)'
        )
        self.repickListPulldown.grid(row=row, column=0, sticky='nw')

        texts = ['Repick Peak List']
        commands = [self.runRepickPeaks]
        self.runButton = ButtonList(
            frameB,
            texts=texts,
            commands=commands,
            expands=True,
            tipTexts=['Repick selected peak list into a new peak list.'])
        self.runButton.grid(row=row, column=1, columnspan=1, sticky='nsew')

        row += 1
        div = LabelDivider(frameB)
        row += 1
        texts = ['Separate Peaks']
        commands = [self.runPeakSeparator]
        self.runButton = ButtonList(frameB,
                                    texts=texts,
                                    commands=commands,
                                    expands=True,
                                    tipTexts=['Run peak search now'])
        self.runButton.grid(row=row, column=0, columnspan=2, sticky='nsew')

        self.setWidgetEntries()

        self.administerNotifiers(self.registerNotify)
Exemple #8
0
class ApplicationPopup(AnalysisPopup):

    help_url = 'http://www.ccpn.ac.uk'

    allowedCallbackFuncnames = ('init', 'save', 'close')

    def __init__(self, root, programName='Extend-NMR Interface'):

        self.font = DEFAULT_FONT
        # Application object needed to store application-specific data with project
        self.application = Application(name=PROGRAM_NAME)
        self.versionInfo = 'Version' + VERSION
        self.ariaProjectFile = None
        self.doneAnalysisInfo = False

        self.updateFuncs = []
        self.projButtons = []

        self.ariaPaths = []
        self.isdPaths = []

        AnalysisPopup.__init__(self, root)

        self.program_name = PROGRAM_NAME
        self.setTitle(PROGRAM_NAME)

    def printAnalysisCommandLineInfo(self, event):

        if not self.doneAnalysisInfo:
            Analysis.printCommandLineInfo(self)
            self.doneAnalysisInfo = True

    def printCommandLineInfo(self):

        print """
 For program documentation see:
 http://www.extend-nmr.eu   
    """

    def body(self, guiParent):

        self.menus = {}
        self.menu_items = {}

        self.fixedActiveMenus = {}

        self.popups = {}

        self.callbacksDict = {}

        self.selected_objects = []

        self.menubar = menubar = Menu(guiParent)

        self.font = DEFAULT_FONT

        self.setProjectMenu()
        #

        menu = Menu(self.menubar, tearoff=0)
        menu.bind('<Button>', self.printAnalysisCommandLineInfo)
        self.menubar.add_cascade(label='CcpNmr Analysis',
                                 shortcut='C',
                                 menu=menu)
        self.menubar.add_command(label='FormatConverter',
                                 shortcut='F',
                                 command=self.runFormatConverter)

        self.menubar = menu
        self.initProject()
        self.setPeaksMenu()
        self.setMoleculeMenu()
        self.setAssignMenu()
        self.setResonanceMenu()
        self.setDataMenu()
        self.setStructureMenu()
        self.setChartMenu()
        self.setMacroMenu()
        self.setOtherMenu()
        self.setMenuState()  # need to do it again because of OtherMenu state

        # Help Submenu

        helpMenu = Menu(self.menubar, tearoff=0)
        helpMenu.add_command(label='Version',
                             shortcut='V',
                             command=self.showVersion)
        helpMenu.add_command(label='About',
                             shortcut='A',
                             command=self.showAbout)
        helpMenu.add_command(label='Help', shortcut='H', command=self.showHelp)

        menu.add_separator()
        menu.add_command(label='CCPN Updates',
                         shortcut='U',
                         image=self.iconRefresh,
                         compound='left',
                         command=self.updateAnalysis,
                         tipText='Get any new patches and updates to CcpNmr')
        menu.add_cascade(label='CCPN Help',
                         shortcut='H',
                         image=self.iconHelp,
                         compound='left',
                         menu=helpMenu)

        self.config(menu=menubar)

        # Ensure that the first row and column in popup expand
        guiParent.grid_rowconfigure(0, weight=1)
        guiParent.grid_columnconfigure(0, weight=1, minsize=200)
        frame = Frame(guiParent)  # Body widgets can be put in this frame
        frame.grid()

        softwareOpts = [
            'Extend-NMR', 'ARIA 2', 'Auremol', 'CING', ' ECI ', 'HADDOCK',
            ' ISD ', 'PRODECOMP'
        ]

        self.tabbedFrame = TabbedFrame(guiParent,
                                       options=softwareOpts,
                                       toggleOff=False,
                                       selected=0,
                                       callback=self.toggleTab)
        self.tabbedFrame.grid(row=0, column=0, sticky='nsew')

        frames = self.tabbedFrame.frames

        # Logos
        ccpnDir = getTopDirectory()

        imageDir = os.path.join(ccpnDir, 'python', 'extendNmr', 'images')

        imageFile = os.path.join(imageDir, 'Fp6Logo.gif')
        self.fp6Logo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'CingLogo.gif')
        self.cingLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'AriaLogo.gif')
        self.ariaLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'IsdLogo.gif')
        self.isdLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'HaddockLogo.gif')
        self.haddockLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'AuremolLogo.gif')
        self.auremolLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'CcpnLogo.gif')
        self.ccpnLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'ProdecompLogo.gif')
        self.prodecompLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'MddLogo.gif')
        self.mddLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'BrukerLogo.gif')
        self.brukerLogo = Tkinter.PhotoImage(file=imageFile)
        imageFile = os.path.join(imageDir, 'MsdLogo.gif')
        self.msdLogo = Tkinter.PhotoImage(file=imageFile)

        self.initExtendNmr(frames[0])

        self.initAria(frames[1])

        self.initAuremol(frames[2])

        self.initCing(frames[3])

        self.initEci(frames[4])

        self.initHaddock(frames[5])

        self.initIsd(frames[6])

        self.initProdecomp(frames[7])

        self.initProject(self.project)

        if not self.project:
            for button in self.projButtons:
                button.disable()

        self.geometry('680x670')

    def setProjectMenu(self):
        ProjectMenu = 'Project'

        # Imports submenu

        importsMenu = Menu(self.menubar, tearoff=False)
        importsMenu.add_command(label='Via Format Converter',
                                shortcut='F',
                                command=self.runFormatConverter)
        importsMenu.add_command(label='NMR-STAR 2.1.1',
                                command=self.importNmrStar211)
        importsMenu.add_command(label='NMR-STAR 3.1',
                                shortcut='N',
                                command=self.importNmrStar31)
        importsMenu.add_command(label='PDB 3.20',
                                shortcut='P',
                                command=self.importPdb)
        importsMenu.add_command(label='Coordinates (PDB-style)',
                                shortcut='C',
                                command=self.importCoordinates)

        # Preferences submenu

        fontsMenu = FontMenu(self.menubar,
                             self.selectFont,
                             sizes=(8, 10, 12),
                             doItalic=False,
                             doBoldItalic=False,
                             tearoff=0)

        prefsMenu = Menu(self.menubar, tearoff=False)
        prefsMenu.add_cascade(
            label='Fonts',
            shortcut='F',
            image=self.iconFont,
            compound='left',
            menu=fontsMenu,
            tipText='Select font to use in the graphical interface')
        prefsMenu.add_command(label='Colour Schemes',
                              image=self.iconTable,
                              compound='left',
                              shortcut='C',
                              tipText='Edit and create colour schemes',
                              command=self.editColorSchemes)
        prefsMenu.add_command(
            label='Residue Codes',
            image=self.iconTable,
            compound='left',
            shortcut='R',
            tipText=
            'User-specified codes that override the standard residue names',
            command=self.editResidueCodes)
        prefsMenu.add_command(label='User Options',
                              image=self.iconTable,
                              compound='left',
                              shortcut='U',
                              tipText='General options for Analysis behaviour',
                              command=self.editProfiles)

        #

        menu = Menu(self.menubar, tearoff=0)
        menu.add_command(
            label='New',
            shortcut='N',
            image=self.iconNewWindow,
            compound='left',
            command=self.newProject,
            tipText='Create a new, blank CCPN project (closes any open project)'
        )
        menu.add_command(
            label='Open Project',
            shortcut='O',
            image=self.iconOpen,
            compound='left',
            command=self.openProject,
            tipText=
            'Open a new CCPN project by selecting a project directory on disk')
        menu.add_command(
            label='Open Spectra',
            shortcut='p',
            image=self.iconOpenFile,
            compound='left',
            command=self.openSpectrum,
            tipText=
            'Open spectrum data fom disk, creating a default CCPN project if needed'
        )
        menu.add_command(label='Save',
                         shortcut='S',
                         image=self.iconSave,
                         compound='left',
                         command=self.saveProject,
                         tipText='Save the current CCPN project on disk')
        menu.add_command(
            label='Save As',
            shortcut='A',
            image=self.iconSaveAs,
            compound='left',
            command=self.saveAsProject,
            tipText=
            'Save the current CCPN project under a different name (project directory)'
        )
        menu.add_cascade(label='Import',
                         shortcut='I',
                         image=self.iconImport,
                         compound='left',
                         menu=importsMenu)
        menu.add_command(label='Close',
                         shortcut='C',
                         image=self.iconClose,
                         compound='left',
                         command=self.closeProject,
                         tipText='Close the current CCPN project')
        menu.add_command(
            label='Quit',
            shortcut='Q',
            image=self.iconQuit,
            compound='left',
            command=self.quit,
            tipText='Quit Extend-NMR, closing any open CCPN project')
        menu.add_separator()
        menu.add_cascade(label='Preferences',
                         shortcut='P',
                         image=self.iconPrefs,
                         compound='left',
                         menu=prefsMenu)
        menu.add_command(
            label='Validate',
            shortcut='V',
            image=self.iconTool,
            compound='left',
            command=self.validateProject,
            tipText=
            'Check the current CCPN project for data model consistency errors')
        menu.add_command(
            label='Backup',
            shortcut='B',
            image=self.iconTool,
            compound='left',
            command=self.backupProject,
            tipText='Setup options for automated backup of CCPN project data')
        menu.add_command(
            label='Archive',
            shortcut='r',
            image=self.iconTool,
            compound='left',
            command=self.archiveProject,
            tipText=
            'Save the current CCPN project in an archived form, e.g. tar gzipped'
        )

        self.menubar.add_cascade(label=ProjectMenu, shortcut='j', menu=menu)
        self.menus[ProjectMenu] = menu
        self.menu_items[ProjectMenu] = [
            'New',
            'Open Project',
            'Open Spectra',
            'Save',
            'Save As',
            'Import',
            'Close',
            'Quit',
            'Preferences',
            'Validate',
            'Backup',
            'Archive',
        ]

        # Menus that area ctive in absence of a project
        #for ii in (0,1,2,7,13,15):
        for ii in (
                0,
                1,
                2,
                7,
        ):
            self.fixedActiveMenus[(ProjectMenu, ii)] = True

    def setPopupGeometries(self):

        for key in self.popups.keys():
            popup = self.popups[key]
            if not key.startswith(window_popup_prefix):  # bit of a hack
                not self.setPopupGeometry(popup, key)

    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

    def initCing(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        canvas = Tkinter.Canvas(frame, width=702, height=77)
        canvas.grid(row=0, column=0, sticky='ew')
        canvas.create_image(0, 0, anchor='nw', image=self.cingLogo)

        cingFrame = CingFrame(frame, self)
        cingFrame.grid(row=1, column=0, sticky='nsew')

        #self.projButtons.extend(cingFrame.buttonBar.buttons)
        self.updateFuncs.append(cingFrame.updateAll)

    def initProdecomp(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)
        frame.configure(bg='#FFFFFF')

        canvas = Tkinter.Canvas(frame, width=1024, height=90, bg='#FFFFFF')
        canvas.grid(row=0, column=0, sticky='ew')
        canvas.create_image(0, 0, anchor='nw', image=self.prodecompLogo)

        prodecompFrame = ProdecompFrame(frame,
                                        basePopup=self,
                                        ccpnProject=self.project)
        prodecompFrame.grid(row=1, column=0, sticky='nsew')

        # set printOutDocString:
        frame.printOutDocString = prodecompFrame.printOutDocString

        #self.projButtons.extend(isdFrame.buttons)
        self.updateFuncs.append(prodecompFrame.updateAll)

    def initAuremol(self, frame):

        frame.expandGrid(1, 0)

        refText = """Gronwald W, Brunner K, Kirchhofer R, Nasser A, Trenner J, Ganslmeier B,
Riepl H, Ried A, Scheiber J, Elsner R, Neidig K-P, Kalbitzer HR

AUREMOL, a New Program for the Automated Structure Elucidation of
Biological Macromolecules. Bruker Reports 2004; 154/155: 11-14
    """

        canvas = Tkinter.Canvas(frame, width=700, height=160, bg='#FFFFFF')
        canvas.grid(row=0, column=0, sticky='ew')
        canvas.create_image(12, 12, anchor='nw', image=self.auremolLogo)
        canvas.create_text(200, 10, anchor='nw', text=refText)

        auremolFrame = AuremolFrame(frame, self.project, grid=(1, 0))

        #self.projButtons.extend(isdFrame.buttons)
        self.updateFuncs.append(auremolFrame.updateAll)

    def initEci(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)
        frame.parent = self  # For notifiers
        frame.configure(bg='#FFFFFF')

        canvas = Tkinter.Canvas(frame,
                                width=800,
                                height=73,
                                bd=3,
                                bg='#FFFFFF')
        canvas.grid(row=0, column=0, sticky='ew')
        canvas.create_image(10, 10, anchor='nw', image=self.msdLogo)

        eciFrame = EntryCompletionFrame(frame, basePopup=self)
        eciFrame.grid(row=1, column=0, sticky='nsew')

        #self.projButtons.extend(isdFrame.buttons)
        self.updateFuncs.append(eciFrame.updateAll)

    def initHaddock(self, frame):

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)
        frame.parent = self  # For notifiers

        canvas = Tkinter.Canvas(frame, width=753, height=92)
        canvas.grid(row=0, column=0, sticky='ew')
        canvas.create_image(0, 0, anchor='nw', image=self.haddockLogo)

        haddockFrame = HaddockFrame(frame, self.project)
        haddockFrame.grid(row=1, column=0, sticky='nsew')

        #self.projButtons.extend(isdFrame.buttons)
        self.updateFuncs.append(haddockFrame.updateAll)

    def initIsd(self, frame):

        global isd

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        frame.configure(bg='#FFFFFF')

        canvas = Tkinter.Canvas(frame,
                                width=800,
                                height=91,
                                bd=3,
                                bg='#FFFFFF')
        canvas.grid(row=0, column=0, sticky='ew', padx=0)
        canvas.create_image(0, 0, anchor='nw', image=self.isdLogo)

        isdFrame = IsdFrame(frame, self.project)
        isdFrame.grid(row=1, column=0, sticky='nsew')

        self.isd = isdFrame
        isd = self.isd

        #self.projButtons.extend(isdFrame.buttons)
        self.updateFuncs.append(isdFrame.updateAll)

    def initExtendNmr(self, frame):

        row = 0
        frame.config(bd=5)
        canvas = Tkinter.Canvas(frame,
                                width=640,
                                height=600,
                                bg='#FFFFFF',
                                bd=5)
        canvas.grid(row=row, column=0, sticky='nsew')
        canvas.create_image(15, 15, anchor='nw', image=self.fp6Logo)
        canvas.create_image(330, 15, anchor='nw', image=self.prodecompLogo)
        canvas.create_image(330, 115, anchor='nw', image=self.mddLogo)
        canvas.create_image(20, 200, anchor='nw', image=self.ccpnLogo)
        canvas.create_image(230, 220, anchor='nw', image=self.msdLogo)
        canvas.create_image(450, 200, anchor='nw', image=self.brukerLogo)
        canvas.create_image(5, 310, anchor='nw', image=self.isdLogo)
        canvas.create_image(230, 300, anchor='nw', image=self.ariaLogo)
        canvas.create_image(450, 290, anchor='nw', image=self.auremolLogo)
        canvas.create_image(5, 420, anchor='nw', image=self.haddockLogo)
        canvas.create_image(5, 520, anchor='nw', image=self.cingLogo)

        #row += 1
        #l1 = Label(frame, text='Welcome to the Extend NMR suite')
        #l1.grid(row=row, column=0, sticky='ew')

    def initAria(self, frame):

        welcomeMessage = \
        """ARIA Version 2.3. Authors: Benjamin Bardiaux, Michael Habeck,
Jens Linge, Therese Malliavin, Sean O'Donoghue, Wolfgang Rieping,
and Michael Nilges.

Rieping W., Habeck M., Bardiaux B., Bernard A., Malliavin T.E.,
Nilges M.(2007) ARIA2: automated NOE assignment and data
integration in NMR structure calculation. Bioinformatics 23:381-382"""

        frame.grid_columnconfigure(0, weight=1)
        frame.grid_rowconfigure(1, weight=1)

        canvas = Tkinter.Canvas(frame, width=700, height=114, bg='#FFFFFF')
        canvas.grid(row=0, column=0, sticky='ew')
        canvas.create_image(0, 0, anchor='nw', image=self.ariaLogo)
        canvas.create_text(250, 10, anchor='nw', text=welcomeMessage)

        ariaFrame = AriaFrame(frame, self)
        ariaFrame.grid(row=1, column=0, sticky='nsew')

        self.projButtons.extend(ariaFrame.buttons)
        self.updateFuncs.append(ariaFrame.updateAll)

    def openPopup(self, popup_name, clazz, oldStyle=False, *args, **kw):

        popup = self.popups.get(popup_name)

        if (popup):
            popup.open()
        else:
            if self.project:
                analysisProfile = self.analysisProfile
            else:
                analysisProfile = None

            if analysisProfile:
                if popup_name.startswith(window_popup_prefix):  # bit of a hack
                    transient = analysisProfile.transientWindows
                else:
                    transient = analysisProfile.transientDialogs
            else:
                transient = True

            name = popup_name

            if (oldStyle):
                popup = self.popups[popup_name] = clazz(self,
                                                        transient=transient,
                                                        *args,
                                                        **kw)
            else:
                popup = self.popups[popup_name] = clazz(self,
                                                        project=self.project,
                                                        popup_name=name,
                                                        transient=transient,
                                                        *args,
                                                        **kw)
            # above automatically opens popup

        return popup

    def initProject(self, project=None):

        AnalysisPopup.initProject(self, project, False)

        self.project = project
        if project:
            for i, func in enumerate(self.updateFuncs):
                func(project)

            for button in self.projButtons:
                button.enable()

        else:
            for button in self.projButtons:
                button.disable()

    def setupSoftware(self):

        return

        project = self.project

        methodStore = project.currentMethodStore or \
                      project.findFirstMethodStore() or \
                      project.newMethodStore(name=project.name)

        software = methodStore.findFirstSoftware(name=PROGRAM_NAME,
                                                 version=VERSION)
        if not software:
            software = methodStore.newSoftware(name=PROGRAM_NAME,
                                               version=VERSION)

        software.task = 'data pipeline'
        software.vendorName = 'The Extend-NMR Project'
        #software.vendorAddress = ''
        software.vendorWebAddress = 'http://www.extend-nmr.eu'
Exemple #9
0
    def __init__(self, parent, basePopup, *args, **kw):

        #
        # Variable initialisation
        #

        self.fcWrapper = basePopup.fcWrapper
        self.project = basePopup.project
        self.basePopup = basePopup

        # TODO necessary?
        if self.project:
            self.nmrProject = self.project.currentNmrProject
            self.entry = self.project.currentNmrEntryStore.findFirstEntry()
            if not self.entry:
                self.entry = self.project.currentNmrEntryStore.newEntry(
                    name=self.project.name)
        else:
            self.nmrProject = None

        self.sequenceCoordinatesLoaded = False
        self.shiftsLoaded = False
        self.linkResDone = False

        self.currentShiftList = None
        self.shiftListChainPairs = []

        self.moleculeList = []
        self.moleculeDict = {}

        #
        # Frame setup
        #

        Frame.__init__(self, parent, **kw)

        self.grid_columnconfigure(1, weight=1)
        self.grid_rowconfigure(1, weight=1)

        options = ['Import', 'Deposition']

        tabbedFrame = TabbedFrame(self,
                                  options=options,
                                  callback=self.selectTab)
        tabbedFrame.grid(row=1, column=0, columnspan=2, sticky='nsew')

        self.tabbedFrame = tabbedFrame
        frameA, frameD = tabbedFrame.frames

        #
        # Main
        #

        frameA.grid_columnconfigure(0, weight=1)
        #frameA.grid_columnconfigure(1, weight=1) # Change to 2 if want 2 columns
        frameA.grid_rowconfigure(12, weight=1)
        #frameA.grid_rowconfigure(12, weight=1)

        row = 0

        div = LabelDivider(
            frameA,
            text=
            'Select the full coordinate file or a sequence file (with info for a single molecule).',
            justify='center',
            grid=(row, 0),
            gridSpan=(1, 1))

        row += 1

        self.sequenceCoordinatesImport = Button(
            frameA,
            text=self.defaultSelectText,
            command=self.importSequenceOrCoords,
            foreground=self.fontDefaultColor)
        self.sequenceCoordinatesImport.grid(row=row, column=0, sticky='ew')

        row += 1

        label = Label(frameA, text="")
        label.grid(row=row, column=0, sticky='ew')

        row += 1

        div = LabelDivider(
            frameA,
            text='Select the molecule relevant for your chemical shift file.',
            justify='center',
            grid=(row, 0),
            gridSpan=(1, 1))

        row += 1

        self.moleculeSelect = Label(
            frameA,
            text="None available yet - import valid file first",
            foreground=self.fontBadColor)
        self.moleculeSelect.grid(row=row, column=0, sticky='ew')
        self.moleculeSelectRow = row

        row += 1

        label = Label(frameA, text="")
        label.grid(row=row, column=0, sticky='ew')

        row += 1

        div = LabelDivider(
            frameA,
            text=
            'Select a chemical shift file with values only for the above molecule.',
            justify='center',
            grid=(row, 0),
            gridSpan=(1, 1))

        row += 1

        self.shiftImport = Button(frameA,
                                  text=self.defaultSelectText,
                                  command=self.importShifts,
                                  foreground=self.fontDefaultColor)
        self.shiftImport.grid(row=row, column=0, sticky='ew')

        row += 1

        label = Label(frameA, text="")
        label.grid(row=row, column=0, sticky='ew')

        row += 1

        div = LabelDivider(
            frameA,
            text='Consistency check between molecule and shift information.',
            justify='center',
            grid=(row, 0),
            gridSpan=(2, 1))

        row += 1

        self.linkResCheckInfo = Label(frameA, text='')
        self.linkResCheckInfo.grid(row=row, column=0, sticky='ew')

        row += 1

        div = Separator(frameA, grid=(row, 0), gridSpan=(1, 1))

        row += 1

        texts = ['Import new sequence', 'Import new set of shifts']
        commands = [self.resetSequenceImport, self.resetShiftImport]

        self.mainButtons = ButtonList(frameA, texts=texts, commands=commands)
        self.mainButtons.grid(row=row, column=0, columnspan=2, sticky='ew')
        self.mainButtons.buttons[0].config(foreground=self.fontDefaultColor)

        #print row

        self.frameA = frameA

        #
        # Not in use...
        #

        #frameX.grid_columnconfigure(0, weight=1)
        #frameX.grid_columnconfigure(1, weight=1)
        #frameX.grid_rowconfigure(1, weight=1)
        #frameX.grid_rowconfigure(3, weight=1)

        #
        # Deposition, is updated after each successful import run.
        #

        frameD.grid_columnconfigure(0, weight=1)
        frameD.grid_rowconfigure(5, weight=1)

        self.frameD = frameD

        row = 0

        div = LabelDivider(frameD,
                           text='Imported data.',
                           justify='center',
                           grid=(row, 0),
                           gridSpan=(1, 2))

        row += 1

        self.depositionImportText = "\nImported %d shift list(s) for a total of %d shifts.\n\nImported %d molecule(s) and %d chain(s).\n\nImported %d model(s) for a total of %d atom coordinates.\n\nLinked %.2f%% of imported NMR information to %d chain(s)."
        self.depositionImportLoc = (row, 0)

        # These used for setting text above...
        self.depositionImportNums = [0, 0, 0, 0, 0, 0, 0.0, 0]
        self.importedShiftLists = []
        self.connectedChains = []

        self.depositionImportLabel = Label(frameD,
                                           text=self.depositionImportText %
                                           tuple(self.depositionImportNums),
                                           foreground=self.fontBadColor)
        self.depositionImportLabel.grid(row=row, column=0, sticky='ew')

        row += 1

        label = Label(frameD, text="")
        label.grid(row=row, column=0, sticky='ew')

        #
        # Finalize the import part, proceed to ECI.
        #

        row += 1

        div = LabelDivider(
            frameD,
            text=
            'Import completed, save project and start Entry Completion Interface.',
            justify='center',
            grid=(row, 0),
            gridSpan=(1, 1))

        row += 1

        self.eciStart = Button(frameD,
                               text="Finalise import",
                               command=self.finaliseImport,
                               foreground=self.fontBadColor)
        self.eciStart.grid(row=row, column=0, sticky='ew')