PEATDB/plugins/PEATSAplugin.py
def createJobDialog(self):
        """Get details from user using dialog
           required: structure, mutations, type of calc and a tag (optional)"""

        def validatename(text):
            if not hasattr(self.DB.meta,'peatsa_jobs'):
                return 1
            if text in self.DB.meta.peatsa_jobs:
              return -1
            else:
              return 1
        def close():
            jobdlg.destroy()
        def loadmuts():            
            filename=tkFileDialog.askopenfilename(initialdir=os.getcwd(),
                                       filetypes=[("All files","*")])
            if filename:
                mutlist.importfile(filename)
            return
        def loadmutsfromDB():
            for p in self.DB.getRecs():               
                mut = self.DB.get(p).Mutations
                if mut == None or mut=='':
                    continue
                if type(mut) is types.StringType:
                    mutlist.appendtext(mut+'\n')
                else:
                    mutstring = mut.getMutationString()
                    if mutstring != None:
                        mutlist.appendtext(mutstring+'\n')
            return
        def getstruct():
            filename=tkFileDialog.askopenfilename(defaultextension='.pdb',
                                       initialdir=os.getcwd(),
                                       filetypes=[("pdb","*.pdb"),("All files","*.*")])
            pdbentry.setvalue(filename)
            return
        def getligand():
            self.ligandfile = tkFileDialog.askopenfilename(defaultextension='.pdb',
                                       initialdir=os.getcwd(),
                                       filetypes=[("mol2","*.mol2"),("All files","*.*")])
            
        def submit():
                  
            #if calcmenu.getcurselection() == 'both':
            #    calcs = ['stability','binding']
            if calcmenu.getcurselection() == 'pka':
                calcs = ['scan']
            else:
                calcs = [calcmenu.getcurselection()]
            mutationlist = mutlist.getvalue().split('\n')
            mutationlist.remove('')
            pdbfile=None; pdb = None
            quality = mutqualentry.getvalue()
            
            if not hasattr(self.DB.meta, 'refprotein') or self.DB.meta.refprotein == None:
                tkMessageBox.showinfo('No ref protein',
                                      'Set a reference (wt) protein first')
                return
            #if self.useref.get() == 1:
            #we use ref pdb by default now
            pdbfile = self.writetempPDB()
            pdbname = self.getrefPDBName()
            
         
            if len(mutationlist) == 0 or mutationlist==[u'']:
                print 'mutation list is empty'
                return
            if hasattr(self.DB.meta,'peatsa_jobs') and nameentry.getvalue() in self.DB.meta.peatsa_jobs:
                print 'job name already used'
                return
            name=nameentry.getvalue()
            expcol = expcolmenu.getcurselection()
            self.submitJob(name=name, pdbname=pdbname,
                           pdb=pdb, pdbfile=pdbfile,
                           ligandfile=self.ligandfile,
                           mutations=mutationlist,
                           calcs=calcs, mutationquality=quality,
                           meta={'expcol':expcol,'pdbname':pdbname})         
            close()
            
        jobdlg = Toplevel()
        jobdlg.geometry('+220+220')
        jobdlg.title('Create Calculation')
        balloon = Pmw.Balloon(jobdlg)
        nameentry = Pmw.EntryField(jobdlg,
                labelpos = 'w',
                label_text = 'Name:',
                validate = validatename,
                value = 'mycalc')
        nameentry.pack(fill=BOTH,expand=1)
        balloon.bind(nameentry, 'Calculation name can be anything, but should be unique')        
        expcols = ['']+self.DB.getSimpleFields()
        expcolmenu = Pmw.OptionMenu(jobdlg,
                labelpos = 'w',
                label_text = 'Exp. col:',
                items = expcols,
                initialitem = '',
                menubutton_width = 8)        
        expcolmenu.pack(fill=BOTH,expand=1)
        balloon.bind(expcolmenu, 'Field with experimental data to compare, optional')          
        calcmenu = Pmw.OptionMenu(jobdlg,
                labelpos = 'w',
                label_text = 'Calculation Type:',
                items = self.calctypes,
                initialitem = 'stability',
                menubutton_width = 8)
        calcmenu.pack(fill=X,expand=1)
        fr=Frame(jobdlg)
        fr.pack(fill=X,expand=1)
        mutqualentry = Pmw.EntryField(jobdlg,
                labelpos = 'w',
                label_text = 'Quality:',
                validate = validatename,
                value = '2.0')
        mutqualentry.pack(fill=BOTH,expand=1)        
        Label(jobdlg,text='Using PDB: '+self.getrefPDBName()).pack(fill=BOTH,expand=1)
        self.ligandfile=None
        mutlist = Pmw.ScrolledText(jobdlg,
                labelpos = 'n',
                label_text='Mutations:',
                usehullsize = 1,
                hull_width = 200,
                hull_height = 250,
                text_wrap='word') 
        mutlist.pack(fill=BOTH,expand=1)
        Button(jobdlg,text='Load Mutations from Project',command=loadmutsfromDB).pack(fill=X,expand=1)        
        Button(jobdlg,text='Load Mutations from File',command=loadmuts).pack(fill=X,expand=1)
        balloon.bind(mutlist, 'Enter one mutation per line in the form\n A:0003:ALA or A3A')
        f=Frame(jobdlg); f.pack(fill=X,expand=1)
        Button(f,text='Submit',command=submit).pack(side=LEFT,fill=X,expand=1,pady=2)
        Button(f,text='Cancel',command=close).pack(fill=X,expand=1,pady=2)        
        jobdlg.grab_set()
        jobdlg.transient(self.parent)
        self.parent.wait_window(jobdlg)
        return
Get details from user using dialog
           required: structure, mutations, type of calc and a tag (optional)
Get details from user using dialog
required: structure, mutations, type of calc and a tag (optional)
Get details from user using dialog required : structure mutations type of calc and a tag ( optional )
def createJobDialog(self):
        def validatename(text):
            if not hasattr(self.DB.meta,'peatsa_jobs'):
                return 1
            if text in self.DB.meta.peatsa_jobs:
              return -1
            else:
              return 1
        def close():
            jobdlg.destroy()
        def loadmuts():            
            filename=tkFileDialog.askopenfilename(initialdir=os.getcwd(),
                                       filetypes=[("All files","*")])
            if filename:
                mutlist.importfile(filename)
            return
        def loadmutsfromDB():
            for p in self.DB.getRecs():               
                mut = self.DB.get(p).Mutations
                if mut == None or mut=='':
                    continue
                if type(mut) is types.StringType:
                    mutlist.appendtext(mut+'\n')
                else:
                    mutstring = mut.getMutationString()
                    if mutstring != None:
                        mutlist.appendtext(mutstring+'\n')
            return
        def getstruct():
            filename=tkFileDialog.askopenfilename(defaultextension='.pdb',
                                       initialdir=os.getcwd(),
                                       filetypes=[("pdb","*.pdb"),("All files","*.*")])
            pdbentry.setvalue(filename)
            return
        def getligand():
            self.ligandfile = tkFileDialog.askopenfilename(defaultextension='.pdb',
                                       initialdir=os.getcwd(),
                                       filetypes=[("mol2","*.mol2"),("All files","*.*")])
        def submit():
            if calcmenu.getcurselection() == 'pka':
                calcs = ['scan']
            else:
                calcs = [calcmenu.getcurselection()]
            mutationlist = mutlist.getvalue().split('\n')
            mutationlist.remove('')
            pdbfile=None; pdb = None
            quality = mutqualentry.getvalue()
            if not hasattr(self.DB.meta, 'refprotein') or self.DB.meta.refprotein == None:
                tkMessageBox.showinfo('No ref protein',
                                      'Set a reference (wt) protein first')
                return
            pdbfile = self.writetempPDB()
            pdbname = self.getrefPDBName()
            if len(mutationlist) == 0 or mutationlist==[u'']:
                print 'mutation list is empty'
                return
            if hasattr(self.DB.meta,'peatsa_jobs') and nameentry.getvalue() in self.DB.meta.peatsa_jobs:
                print 'job name already used'
                return
            name=nameentry.getvalue()
            expcol = expcolmenu.getcurselection()
            self.submitJob(name=name, pdbname=pdbname,
                           pdb=pdb, pdbfile=pdbfile,
                           ligandfile=self.ligandfile,
                           mutations=mutationlist,
                           calcs=calcs, mutationquality=quality,
                           meta={'expcol':expcol,'pdbname':pdbname})         
            close()
        jobdlg = Toplevel()
        jobdlg.geometry('+220+220')
        jobdlg.title('Create Calculation')
        balloon = Pmw.Balloon(jobdlg)
        nameentry = Pmw.EntryField(jobdlg,
                labelpos = 'w',
                label_text = 'Name:',
                validate = validatename,
                value = 'mycalc')
        nameentry.pack(fill=BOTH,expand=1)
        balloon.bind(nameentry, 'Calculation name can be anything, but should be unique')        
        expcols = ['']+self.DB.getSimpleFields()
        expcolmenu = Pmw.OptionMenu(jobdlg,
                labelpos = 'w',
                label_text = 'Exp. col:',
                items = expcols,
                initialitem = '',
                menubutton_width = 8)        
        expcolmenu.pack(fill=BOTH,expand=1)
        balloon.bind(expcolmenu, 'Field with experimental data to compare, optional')          
        calcmenu = Pmw.OptionMenu(jobdlg,
                labelpos = 'w',
                label_text = 'Calculation Type:',
                items = self.calctypes,
                initialitem = 'stability',
                menubutton_width = 8)
        calcmenu.pack(fill=X,expand=1)
        fr=Frame(jobdlg)
        fr.pack(fill=X,expand=1)
        mutqualentry = Pmw.EntryField(jobdlg,
                labelpos = 'w',
                label_text = 'Quality:',
                validate = validatename,
                value = '2.0')
        mutqualentry.pack(fill=BOTH,expand=1)        
        Label(jobdlg,text='Using PDB: '+self.getrefPDBName()).pack(fill=BOTH,expand=1)
        self.ligandfile=None
        mutlist = Pmw.ScrolledText(jobdlg,
                labelpos = 'n',
                label_text='Mutations:',
                usehullsize = 1,
                hull_width = 200,
                hull_height = 250,
                text_wrap='word') 
        mutlist.pack(fill=BOTH,expand=1)
        Button(jobdlg,text='Load Mutations from Project',command=loadmutsfromDB).pack(fill=X,expand=1)        
        Button(jobdlg,text='Load Mutations from File',command=loadmuts).pack(fill=X,expand=1)
        balloon.bind(mutlist, 'Enter one mutation per line in the form\n A:0003:ALA or A3A')
        f=Frame(jobdlg); f.pack(fill=X,expand=1)
        Button(f,text='Submit',command=submit).pack(side=LEFT,fill=X,expand=1,pady=2)
        Button(f,text='Cancel',command=close).pack(fill=X,expand=1,pady=2)        
        jobdlg.grab_set()
        jobdlg.transient(self.parent)
        self.parent.wait_window(jobdlg)
        return
def createJobDialog ( self ) : def validatename ( text ) : if not hasattr ( self . DB . meta , 'peatsa_jobs' ) : return 1 if text in self . DB . meta . peatsa_jobs : return - 1 else : return 1 def close ( ) : jobdlg . destroy ( ) def loadmuts ( ) : filename = tkFileDialog . askopenfilename ( initialdir = os . getcwd ( ) , filetypes = [ ( "All files" , "*" ) ] ) if filename : mutlist . importfile ( filename ) return def loadmutsfromDB ( ) : for p in self . DB . getRecs ( ) : mut = self . DB . get ( p ) . Mutations if mut == None or mut == '' : continue if type ( mut ) is types . StringType : mutlist . appendtext ( mut + '\n' ) else : mutstring = mut . getMutationString ( ) if mutstring != None : mutlist . appendtext ( mutstring + '\n' ) return def getstruct ( ) : filename = tkFileDialog . askopenfilename ( defaultextension = '.pdb' , initialdir = os . getcwd ( ) , filetypes = [ ( "pdb" , "*.pdb" ) , ( "All files" , "*.*" ) ] ) pdbentry . setvalue ( filename ) return def getligand ( ) : self . ligandfile = tkFileDialog . askopenfilename ( defaultextension = '.pdb' , initialdir = os . getcwd ( ) , filetypes = [ ( "mol2" , "*.mol2" ) , ( "All files" , "*.*" ) ] ) def submit ( ) : if calcmenu . getcurselection ( ) == 'pka' : calcs = [ 'scan' ] else : calcs = [ calcmenu . getcurselection ( ) ] mutationlist = mutlist . getvalue ( ) . split ( '\n' ) mutationlist . remove ( '' ) pdbfile = None ; pdb = None quality = mutqualentry . getvalue ( ) if not hasattr ( self . DB . meta , 'refprotein' ) or self . DB . meta . refprotein == None : tkMessageBox . showinfo ( 'No ref protein' , 'Set a reference (wt) protein first' ) return pdbfile = self . writetempPDB ( ) pdbname = self . getrefPDBName ( ) if len ( mutationlist ) == 0 or mutationlist == [ u'' ] : print 'mutation list is empty' return if hasattr ( self . DB . meta , 'peatsa_jobs' ) and nameentry . getvalue ( ) in self . DB . meta . peatsa_jobs : print 'job name already used' return name = nameentry . getvalue ( ) expcol = expcolmenu . getcurselection ( ) self . submitJob ( name = name , pdbname = pdbname , pdb = pdb , pdbfile = pdbfile , ligandfile = self . ligandfile , mutations = mutationlist , calcs = calcs , mutationquality = quality , meta = { 'expcol' : expcol , 'pdbname' : pdbname } ) close ( ) jobdlg = Toplevel ( ) jobdlg . geometry ( '+220+220' ) jobdlg . title ( 'Create Calculation' ) balloon = Pmw . Balloon ( jobdlg ) nameentry = Pmw . EntryField ( jobdlg , labelpos = 'w' , label_text = 'Name:' , validate = validatename , value = 'mycalc' ) nameentry . pack ( fill = BOTH , expand = 1 ) balloon . bind ( nameentry , 'Calculation name can be anything, but should be unique' ) expcols = [ '' ] + self . DB . getSimpleFields ( ) expcolmenu = Pmw . OptionMenu ( jobdlg , labelpos = 'w' , label_text = 'Exp. col:' , items = expcols , initialitem = '' , menubutton_width = 8 ) expcolmenu . pack ( fill = BOTH , expand = 1 ) balloon . bind ( expcolmenu , 'Field with experimental data to compare, optional' ) calcmenu = Pmw . OptionMenu ( jobdlg , labelpos = 'w' , label_text = 'Calculation Type:' , items = self . calctypes , initialitem = 'stability' , menubutton_width = 8 ) calcmenu . pack ( fill = X , expand = 1 ) fr = Frame ( jobdlg ) fr . pack ( fill = X , expand = 1 ) mutqualentry = Pmw . EntryField ( jobdlg , labelpos = 'w' , label_text = 'Quality:' , validate = validatename , value = '2.0' ) mutqualentry . pack ( fill = BOTH , expand = 1 ) Label ( jobdlg , text = 'Using PDB: ' + self . getrefPDBName ( ) ) . pack ( fill = BOTH , expand = 1 ) self . ligandfile = None mutlist = Pmw . ScrolledText ( jobdlg , labelpos = 'n' , label_text = 'Mutations:' , usehullsize = 1 , hull_width = 200 , hull_height = 250 , text_wrap = 'word' ) mutlist . pack ( fill = BOTH , expand = 1 ) Button ( jobdlg , text = 'Load Mutations from Project' , command = loadmutsfromDB ) . pack ( fill = X , expand = 1 ) Button ( jobdlg , text = 'Load Mutations from File' , command = loadmuts ) . pack ( fill = X , expand = 1 ) balloon . bind ( mutlist , 'Enter one mutation per line in the form\n A:0003:ALA or A3A' ) f = Frame ( jobdlg ) ; f . pack ( fill = X , expand = 1 ) Button ( f , text = 'Submit' , command = submit ) . pack ( side = LEFT , fill = X , expand = 1 , pady = 2 ) Button ( f , text = 'Cancel' , command = close ) . pack ( fill = X , expand = 1 , pady = 2 ) jobdlg . grab_set ( ) jobdlg . transient ( self . parent ) self . parent . wait_window ( jobdlg ) return
Get details from user using dialog
required: structure, mutations, type of calc and a tag (optional)
Get details from user using dialog required : structure mutations type of calc and a tag ( optional )
"""Get details from user using dialog
           required: structure, mutations, type of calc and a tag (optional)""" #if calcmenu.getcurselection() == 'both': #    calcs = ['stability','binding'] #if self.useref.get() == 1: #we use ref pdb by default now
self