def addfiles(self, accepted): """ """ for rec in accepted: r = rec[0] rec_data = self.app.engine.RecBook[r] types = "" unk = '' flex_res = '[no]' chains = '' for a in sorted(rec_data['atypes']): types += " %s" % a types = types.strip() for a in sorted(rec_data['atypes_unknown']): unk += ' %s' % a unk = unk.strip() if rec_data['is_flexible']: # in rec_data.keys(): #print "ISFLEXI" flex_res = " ".join(rec_data['flex_res']) chains = " ".join(rec_data['chains']) self.recFileManager.listbox.insert('end', rec_data['name'], chains, len(rec_data['residues']), flex_res, types, unk, rec_data['filename']) # EVENT # XXX TEMPORARY self.app.configTab.setReceptorList() #elif action=='del': #print "FIND A WAY TO DELETE SOMETHING FROM self.tab2.recContainer" # find the index! #self.tab1.ligContainer.listbox.delete(0,END) # XXX Obsolete # pass e = RaccoonEvents.UserInputRequirementUpdate('rec') self.app.eventManager.dispatchEvent(e) self.updatereccount()
def libselect_cb_ssh(self, libname = None, filters = {}): #, event=None): """ manage the selection of a library for cluster submission TODO filters now are empty, so the entire library is selected by default """ if libname == None: try: s = self.ligLibPanel.listbox.curselection()[0] sel = self.ligLibPanel.listbox.get(s)[0] except: return libname = sel[0] #print "SELECTED LIB=[%s]" % libname self.dprint("SELECTED LIB=[%s]" % libname) # need ask the server for the lib lib = self.app.server.getLibrary(libname) if lib == None: t = 'Library selection' i = 'error' m = ('There was an error selecting the library.\n\n' 'The library "%s" does not exist on the server' % libname) tmb.showinfo(parent=self.ligLibPanel, title=t,message=m, icon=i) return False self.app.ligand_source = [ {'lib': lib, 'filters' : filters } ] self._selectedLib.config(text='%s' % libname) e = RaccoonEvents.UserInputRequirementUpdate('lig') self.app.eventManager.dispatchEvent(e) return True
def destroy(self, obj, event=None): """ remove a filter from the filters db and destroy the widget """ obj.pack_forget() self.filters.remove(obj) e = RaccoonEvents.FilterInteractionEvent() self.eventManager.dispatchEvent(e)
def updatereccount(self): """update labels and list in the config panel in the """ # update the count of accepted receptors msg = 'Accepted structures [ %s ]' % len(self.app.engine.RecBook) self.recGroup.configure(tag_text=msg) ## XXX THIS IS THE CONFIG PANEL ENTRY ## self.GUI_rec_list_container.insert('end', rec_data['name']) e = RaccoonEvents.ReceptorListChange() self.app.eventManager.dispatchEvent(e)
def setAllInactive(self, event=None): """ set all filters inactive""" change = False for o in self.filters: if o.isActive(): o.disable() change = True if change: e = RaccoonEvents.FilterInteractionEvent() self.eventManager.dispatchEvent(e)
def setAllActive(self, event=None): """ set all filters active""" change = False for o in self.filters: if not o.isActive(): o.enable(quiet=True) if o.isActive(): change = False if change: e = RaccoonEvents.FilterInteractionEvent() self.eventManager.dispatchEvent(e)
def _call_lib_manager_del(self,event=None): # test if there's a server if self.app.server == None: title ='No server selected' msg = ('Connect to a server in the Setup tab ' 'to remove libraries...') tmb.showinfo(parent = self.frame, title = title, message = msg) return # test if it is racconized if not self.app.server.properties['ready']: title ='Server is not ready' msg = ('The server has not been prepared ("racconized") yet.\n\n' 'Prepare it in the Setup tab and try again.') tmb.showinfo(parent = self.frame, title = title, message = msg) return if len(self.app.server.getLibraries()) == 0: title ='No libraries' msg = ('The server does not have libraries installed.') tmb.showinfo(parent = self.frame, title = title, message = msg) return try: s = self.ligLibPanel.listbox.curselection()[0] sel = self.ligLibPanel.listbox.get(s)[0] except: #print "Nothing selected, leaving..." return libname = sel[0] t = 'Delete library' m = ('The library "%s" is going to be deleted.\n\n' 'All files on the remote server are going to be erased.\n\n' 'Are you sure?') % libname w = 'warning' i = 'info' e = 'error' if not tmb.askyesno(parent=self.parent, title=t, message=m, icon =w): return # deselect library to be deleted if it is selected if len(self.app.ligand_source): if libname == self.app.ligand_source[0]['lib'].name: self.libdeselect_cb() reply = self.app.server.delLibrary(libname, delfiles=True) if reply: m = 'Operation completed' tmb.showinfo(parent = self.parent, title=t, message = m, icon = i) else: m = 'Operation was *NOT successful' tmb.showinfo(parent = self.parent, title=t, message = m, icon = e) self.app.setBusy() e = RaccoonEvents.ServerConnection() self.app.eventManager.dispatchEvent(e) self.app.setReady()
def invertStatus(self, event=None): """ invert filter status""" change = False for o in self.filters: if o.isActive(): o.disable() change = True else: o.enable(quiet=True) if o.isActive(): change = True if change: e = RaccoonEvents.FilterInteractionEvent() self.eventManager.dispatchEvent(e)
def prepare_ligands_for_guse(self): """ Prepare ligands for gUSE. This includes looping through all ligands and compressing them in a zip file (ligands.zip) """ # if there are no ligands attached if len(self._ligand_list) == 0: return # this class is needed in order access the ligands themselves and put them in an iterable libraryOfLigands # because of the way the original Raccoon2 has been written (preparing libraries for a cluster) class Library(): def __init__(self, ligands, name = 'noname'): self.info = { 'name' : name, 'count' : 0, 'date' : None, 'format' : None, 'index_file': None, 'comments': "", 'properties' : {}, 'type' : None, } self.ligands = ligands def name(self): """ used for sorting libraries """ return self.info['name'] def get_ligands(self): return self.ligands libraryOfLigands = Library(list(self._ligand_list)) self.app.ligand_source = [ {'lib': libraryOfLigands, 'filters' : None } ] # show the appropriate message in line with the way it was written in the original Raccoon2 try: title ='Ligands prepared successfully' msg = ('The ligands have been prepared succesfully.') tmb.showinfo(parent = self.win.interior(), title = title, message = msg) del self._ligand_list[:] e = RaccoonEvents.UserInputRequirementUpdate('lig') self.app.eventManager.dispatchEvent(e) except: title ='Error while preparing ligands for gUSE' msg = ('There was an error while uploading the ligands, make sure they are named correctly.') tmb.showinfo(parent = self.win.interior(), title = title, message = msg) self.destroy()
def deletefiles(self, nuke=False, event=None): if nuke == True: # EVENT UPDATES self.app.engine.removeReceptors() self.recFileManager.listbox.delete(0, 'end') self.updatereccount() else: try: s = self.recFileManager.listbox.curselection()[0] sel = self.recFileManager.listbox.get(s)[0] except: #print "BB_REC> Nothing selected, leaving..." return name = sel[0] self.app.engine.removeReceptors([name]) self.recFileManager.listbox.delete(s) e = RaccoonEvents.UserInputRequirementUpdate('rec') self.app.eventManager.dispatchEvent(e) self.updatereccount()
def _go(event=None): #server.debug = True #libobj.debug= True self.app.setBusy() if comment: libobj.info['comment'] = comment libobj.upload( dirname, remotepath, autoregister=0, bg = True) self.RUNNING = True self._stopclosebutton.configure(text= 'Stop', command=stop) status = server.transfer.progress(percent=1) while status < 100.: if server.transfer._STOP: break status = server.transfer.progress(percent=1) pc_var.set(status) self.bar.update() time.sleep(0.2) self.RUNNING = False libobj.debug = True # DEBUG if server.transfer._status['completed']: # EVENT trigger the event refresh of server list #idxfile = remotepath + '/'+ dirname +'/'+'library.db' #idxfile = 'library.db' self._statuslab1.configure(text='Generating index file') self._statuslab2.configure(text='...saving...') libobj.saveIndex() self._statuslab1.configure(text='Registering library to Library Index') self._statuslab2.configure(text='...ongoing...') libobj.register() self._statuslab1.configure(text='\nLibrary upload completed!') self._statuslab2.configure(text=' ') del self._ligand_list[:] self.delete(nuke=True) e = RaccoonEvents.ServerConnection() self.app.eventManager.dispatchEvent(e) else: error = server.transfer_status['error'] self._statuslab1.configure(text='Error trasnferring files!') self._statuslab2.configure(text=error) self._stopclosebutton.configure(text= 'Close', command=forceclose) self.app.setReady()
def __init__(self, app, parent, debug=False): rb.TabBase.__init__(self, app, parent, debug = False) rb.RaccoonDefaultWidget.__init__(self, parent) self.resource = self.app.resource self.dockengine = self.app.dockengine self.app.eventManager.registerListener(RaccoonEvents.SetDockingEngine, self.handleEngine) self.app.eventManager.registerListener(RaccoonEvents.ReceptorListChange, self.setReceptorList) self.app.eventManager.registerListener(RaccoonEvents.ReceptorListChange, self.nuke) self.camera = None # embedded camera object self._loaded_struct = [] self._boxevent = RaccoonEvents.SearchConfigChange() self._searchevent = None # XXX TODO? # switch for loading multiple receptors in the viewer self.recLoaderMultiMode = tk.BooleanVar(value=False) self._currRec = []# [ { 'name':xxxx, 'obj':[ rigid, flex ], 'fname':xxxx }, ... ] self.initIcons() self.makeInterface()
def nuke(self, event=None, quiet=False): """ remove all the filters at once""" if len(self.filters) == 0: return if not quiet: for o in self.filters: if o.isActive(): t = 'Remove all filters' i = 'info' m = ( 'All interaction filters are going to be removed.\n\nAre you sure?' ) if not tmb.askyesno( parent=self.interior(), title=t, message=m, icon=i): return break for o in self.filters: o.pack_forget() self.filters = [] e = RaccoonEvents.FilterInteractionEvent() self.eventManager.dispatchEvent(e)
def libdeselect_cb(self): """ deselect the library""" self.app.ligand_source = [] self._selectedLib.config(text='%s' % '(none)') e = RaccoonEvents.UserInputRequirementUpdate('lig') self.app.eventManager.dispatchEvent(e)
def __init__(self, parent, update_cb=None, debug=False): #, destroy_cb): rb.RaccoonDefaultWidget.__init__(self, parent) DebugTools.DebugObj.__init__(self, debug) Pmw.Group.__init__(self, parent=parent, tag_text='Target interactions', tag_font=self.FONTbold, ring_border=1, ring_highlightcolor='black', ring_highlightbackground='black', ring_highlightthickness=1, ring_relief='flat') self.eventManager = RaccoonEvents.RaccoonEventManager() self.eventManager.registerListener( RaccoonEvents.FilterInteractionEvent, self.update) self.initIcons() self.filters = [] self.update_cb = update_cb self.container = tk.Frame( self.interior()) # this contains the widgets on the left # build toolbar self.toolbar = tk.Frame(self.container) # add button b = tk.Button(self.toolbar, text='+', image=self._ICON_add, command=self.add, **self.BORDER) b.pack(anchor='w', side='left') # remove button b = tk.Button(self.toolbar, text='-', image=self._ICON_del, **self.BORDER) b.pack(anchor='w', side='left', padx=1) selmenu = [ None, ['Remove inactive', 'normal', self.removeInactive], ['Remove all', 'normal', self.nuke], ] menu = rb.RacMenu(b, selmenu, placement='under') # selection button menu b = tk.Button(self.toolbar, text='s', image=self._ICON_selmenu, **self.BORDER) b.pack(anchor='w', side='left', padx=0) selmenu = [ None, ['Activate all', 'normal', self.setAllActive], ['Deactivate all', 'normal', self.setAllInactive], ['Invert active/inactive', 'normal', self.invertStatus], ] menu = rb.RacMenu(b, selmenu, placement='under') # mode pulldown self._mode_choices = {'match all': 'all', 'match any': 'any'} self.modeChoice = OptionMenuFix( self.toolbar, menubutton_font=self.FONT, menu_font=self.FONT, menubutton_width=10, menubutton_bd=1, menubutton_highlightbackground='black', menubutton_borderwidth=1, menubutton_highlightcolor='black', menubutton_highlightthickness=1, menubutton_height=1, #command = self.trigger, items=sorted(self._mode_choices.keys(), reverse=True), ) f = tk.Frame(self.toolbar) self.labelActiveFilt = tk.IntVar(value='0') tk.Label(f, text='active filters:', font=self.FONT).pack(anchor='w', side='left') tk.Label(f, textvar=self.labelActiveFilt, font=self.FONTbold).pack(anchor='w', side='left') f.pack(anchor='w', side='left', padx=15) self.modeChoice.pack(anchor='w', side='right', padx=1) self.toolbar.pack(anchor='w', side='top', expand=1, fill='x', padx=4, pady=2) # build filter filtFrame self.filtFrame = Pmw.ScrolledFrame( self.container, horizflex='expand', # vertflex='expand', vscrollmode='static', hscrollmode='dynamic') #self.filtFrame.component('hull').configure(**self.BORDER) self.filtFrame.component('clipper').configure(bg='white') self.filtFrame.component('frame').configure(relief='flat', bg='white') #self.filtFrame.component('vertscrollbar').bind("<Button-4>", self.mousescroll) for c in [ 'borderframe', 'clipper', 'frame', 'horizscrollbar', 'hull', 'vertscrollbar' ]: self.filtFrame.component(c).bind("<Button-4>", self.mousescroll) self.filtFrame.component(c).bind("<Button-5>", self.mousescroll) self.interior().bind("<Button-4>", self.mousescroll) self.interior().bind("<Button-5>", self.mousescroll) self.filtFrame.pack(anchor='w', side='top', expand=1, fill='both', padx=4, pady=2) self.container.pack(anchor='w', side='left', expand=1, fill='both') self.percentageFrame = tk.Frame( self.interior()) # this contains the widgets on the right # pie self.pie = hf.PercentPie(self.percentageFrame, radius=50) self.pie.pack(anchor='n', side='top', padx=5, pady=5) #self.pie.set_percent(20) # passed label f = tk.Frame(self.percentageFrame) tk.Label(f, text='passed :', font=self.FONTbold).pack(side='left', anchor='w') self.statusLabel = tk.Label(f, text='0', width=8, anchor='w', font=self.FONT) self.statusLabel.pack(side='left', anchor='w') f.pack(anchor='n', side='top') #self.percentageFrame.pack(anchor='e',side='left', expand=1, fill='y') self.percentageFrame.pack(expand=0, fill=None, anchor='e', side='left')
def sendEvent(self): """ trigger the event""" e = RaccoonEvents.FilterInteractionEvent() self.eventManager.dispatchEvent(e)