pKaTool/pKaTool_main.py
def load_titration(self,pdbfilename=None):
        """Load the results of a pKa calculation"""
        import os
        if not pdbfilename:
            pdbfilename=tkFileDialog.askopenfilename(defaultextension='.pdb',
                                                     initialdir=os.getcwd(),
                                                     filetypes=[("WHAT IF pKa dir","*.pdb"),
                                                                ("pKaTool pKa calc file","*.ppc"),
                                                                ("MEAD pKa file","*.pka"),
                                                                ("All files","*.*")],
                                                     parent=self.master)
        #
        # Did we get a name?
        #
        if not pdbfilename:
            return
        pdbfilename=os.path.join(os.getcwd(),pdbfilename)
        if not os.path.isfile(pdbfilename):
            tkMessageBox.showwarning("File not found",
                                    'File not found: %s' %pdbfilename
                                    ,parent=self.master)
            return
        #
        # Is it a WHAT IF type file?
        #
        if pdbfilename[-4:]=='.pdb':
            #
            # Open the file and assess status
            #
            import os
            pdbfilename_short=os.path.split(pdbfilename)[1]
            label=self.labels[self.label_count]
            self.calcs[pdbfilename_short]={'instance':pKaIO.pKaIO(pdbfilename),'selected_groups':[],'label':label}
            self.X2=self.calcs[pdbfilename_short]['instance']
            if not self.X2.assess_status():
                tkMessageBox.showwarning("pKa calculations not complete",
                                         'Please perform a complete pKa calculation for this PDB file'
                                         ,parent=self.master)
                del self.calcs[pdbfilename_short]
                return
            #
            # Read the titration curve
            #
            self.calcs[pdbfilename_short]['titcurv']=self.X2.readtitcurv()
            #
            # read the pKa values
            #
            self.calcs[pdbfilename_short]['pkavals']=self.X2.readpka()
            #
            # Store the PDB file
            #
            fd=open(pdbfilename)
            self.calcs[pdbfilename_short]['pdblines']=fd.readlines()
            fd.close()
            #
            # Add to the display pulldown menu
            #
            self.label_count=self.label_count+1
            self.add_to_pulldown(pdbfilename_short,label)
            self.calc_select.set(pdbfilename_short)
            self.calc_disp[pdbfilename_short].set(1)
            self.update_selected_calc()
        elif pdbfilename[-4:]=='.ppc':
            #
            # pKaTool file
            #
            prog=Toplevel()
            prog.geometry('250x100')
            prog.title('Load progress')
            self.set_position(prog)
            self.load_file=StringVar()
            self.load_file.set('Opening file...')
            Label(prog,textvariable=self.load_file).grid(row=0,column=0)
            prog.update_idletasks()


            import pickle, copy, os
            fd=open(pdbfilename)
            calcs=pickle.load(fd)
            fd.close()

            import os
            count=0
            for calc in calcs.keys():
                count=count+1
                self.load_file.set('Parsing %s (%d of %d)' %(os.path.split(calc)[1],count,len(calcs.keys())))
                prog.update_idletasks()
                calc_name=os.path.split(calc)[1]
                self.calcs[calc_name]=copy.deepcopy(calcs[calc])
                self.label_count=self.label_count+1
                self.add_to_pulldown(calc_name,'')
                self.calc_select.set(calc_name)
                self.calc_disp[calc_name].set(1)
                self.update_selected_calc()
            prog.destroy()
        elif pdbfilename[-4:]=='.pka':
            #
            # MEAD file
            #
            import os
            pdbfilename_short=os.path.split(pdbfilename)[1]
            label=self.labels[self.label_count]
            self.calcs[pdbfilename_short]={'instance':pKaIO.pKaIO(pdbfilename),'selected_groups':[],'label':label}
            self.X2=self.calcs[pdbfilename_short]['instance']
            #
            # Read the titration curve
            #
            self.calcs[pdbfilename_short]['titcurv']=self.X2.readtitcurv(pdbfilename)
            #
            # read the pKa values
            #
            self.calcs[pdbfilename_short]['pkavals']=self.X2.readpka(pdbfilename)
            #
            # Put the pKa value in the titration curves
            #
            for group in self.calcs[pdbfilename_short]['titcurv']:
                self.calcs[pdbfilename_short]['titcurv'][group]['pKa']=self.calcs[pdbfilename_short]['pkavals'][group]['pKa']
            #
            # Store the PDB file
            #
            fd=open(pdbfilename)
            lines=fd.readlines()
            fd.close()
            pdblines=self.X2.read_MEADfile(lines,mode='pdb')
            self.calcs[pdbfilename_short]['pdblines']=pdblines
            #
            # Add to the display pulldown menu
            #
            self.label_count=self.label_count+1
            self.add_to_pulldown(pdbfilename_short,label)
            self.calc_select.set(pdbfilename_short)
            self.calc_disp[pdbfilename_short].set(1)
            self.update_selected_calc()
        return
Load the results of a pKa calculation
Load the results of a pKa calculation
Load the results of a pKa calculation
def load_titration(self,pdbfilename=None):
        import os
        if not pdbfilename:
            pdbfilename=tkFileDialog.askopenfilename(defaultextension='.pdb',
                                                     initialdir=os.getcwd(),
                                                     filetypes=[("WHAT IF pKa dir","*.pdb"),
                                                                ("pKaTool pKa calc file","*.ppc"),
                                                                ("MEAD pKa file","*.pka"),
                                                                ("All files","*.*")],
                                                     parent=self.master)
         Did we get a name?
        if not pdbfilename:
            return
        pdbfilename=os.path.join(os.getcwd(),pdbfilename)
        if not os.path.isfile(pdbfilename):
            tkMessageBox.showwarning("File not found",
                                    'File not found: %s' %pdbfilename
                                    ,parent=self.master)
            return
         Is it a WHAT IF type file?
        if pdbfilename[-4:]=='.pdb':
             Open the file and assess status
            import os
            pdbfilename_short=os.path.split(pdbfilename)[1]
            label=self.labels[self.label_count]
            self.calcs[pdbfilename_short]={'instance':pKaIO.pKaIO(pdbfilename),'selected_groups':[],'label':label}
            self.X2=self.calcs[pdbfilename_short]['instance']
            if not self.X2.assess_status():
                tkMessageBox.showwarning("pKa calculations not complete",
                                         'Please perform a complete pKa calculation for this PDB file'
                                         ,parent=self.master)
                del self.calcs[pdbfilename_short]
                return
             Read the titration curve
            self.calcs[pdbfilename_short]['titcurv']=self.X2.readtitcurv()
             read the pKa values
            self.calcs[pdbfilename_short]['pkavals']=self.X2.readpka()
             Store the PDB file
            fd=open(pdbfilename)
            self.calcs[pdbfilename_short]['pdblines']=fd.readlines()
            fd.close()
             Add to the display pulldown menu
            self.label_count=self.label_count+1
            self.add_to_pulldown(pdbfilename_short,label)
            self.calc_select.set(pdbfilename_short)
            self.calc_disp[pdbfilename_short].set(1)
            self.update_selected_calc()
        elif pdbfilename[-4:]=='.ppc':
             pKaTool file
            prog=Toplevel()
            prog.geometry('250x100')
            prog.title('Load progress')
            self.set_position(prog)
            self.load_file=StringVar()
            self.load_file.set('Opening file...')
            Label(prog,textvariable=self.load_file).grid(row=0,column=0)
            prog.update_idletasks()
            import pickle, copy, os
            fd=open(pdbfilename)
            calcs=pickle.load(fd)
            fd.close()
            import os
            count=0
            for calc in calcs.keys():
                count=count+1
                self.load_file.set('Parsing %s (%d of %d)' %(os.path.split(calc)[1],count,len(calcs.keys())))
                prog.update_idletasks()
                calc_name=os.path.split(calc)[1]
                self.calcs[calc_name]=copy.deepcopy(calcs[calc])
                self.label_count=self.label_count+1
                self.add_to_pulldown(calc_name,'')
                self.calc_select.set(calc_name)
                self.calc_disp[calc_name].set(1)
                self.update_selected_calc()
            prog.destroy()
        elif pdbfilename[-4:]=='.pka':
             MEAD file
            import os
            pdbfilename_short=os.path.split(pdbfilename)[1]
            label=self.labels[self.label_count]
            self.calcs[pdbfilename_short]={'instance':pKaIO.pKaIO(pdbfilename),'selected_groups':[],'label':label}
            self.X2=self.calcs[pdbfilename_short]['instance']
             Read the titration curve
            self.calcs[pdbfilename_short]['titcurv']=self.X2.readtitcurv(pdbfilename)
             read the pKa values
            self.calcs[pdbfilename_short]['pkavals']=self.X2.readpka(pdbfilename)
             Put the pKa value in the titration curves
            for group in self.calcs[pdbfilename_short]['titcurv']:
                self.calcs[pdbfilename_short]['titcurv'][group]['pKa']=self.calcs[pdbfilename_short]['pkavals'][group]['pKa']
             Store the PDB file
            fd=open(pdbfilename)
            lines=fd.readlines()
            fd.close()
            pdblines=self.X2.read_MEADfile(lines,mode='pdb')
            self.calcs[pdbfilename_short]['pdblines']=pdblines
             Add to the display pulldown menu
            self.label_count=self.label_count+1
            self.add_to_pulldown(pdbfilename_short,label)
            self.calc_select.set(pdbfilename_short)
            self.calc_disp[pdbfilename_short].set(1)
            self.update_selected_calc()
        return
def load_titration ( self , pdbfilename = None ) : import os if not pdbfilename : pdbfilename = tkFileDialog . askopenfilename ( defaultextension = '.pdb' , initialdir = os . getcwd ( ) , filetypes = [ ( "WHAT IF pKa dir" , "*.pdb" ) , ( "pKaTool pKa calc file" , "*.ppc" ) , ( "MEAD pKa file" , "*.pka" ) , ( "All files" , "*.*" ) ] , parent = self . master ) if not pdbfilename : return pdbfilename = os . path . join ( os . getcwd ( ) , pdbfilename ) if not os . path . isfile ( pdbfilename ) : tkMessageBox . showwarning ( "File not found" , 'File not found: %s' % pdbfilename , parent = self . master ) return if pdbfilename [ - 4 : ] == '.pdb' : import os pdbfilename_short = os . path . split ( pdbfilename ) [ 1 ] label = self . labels [ self . label_count ] self . calcs [ pdbfilename_short ] = { 'instance' : pKaIO . pKaIO ( pdbfilename ) , 'selected_groups' : [ ] , 'label' : label } self . X2 = self . calcs [ pdbfilename_short ] [ 'instance' ] if not self . X2 . assess_status ( ) : tkMessageBox . showwarning ( "pKa calculations not complete" , 'Please perform a complete pKa calculation for this PDB file' , parent = self . master ) del self . calcs [ pdbfilename_short ] return self . calcs [ pdbfilename_short ] [ 'titcurv' ] = self . X2 . readtitcurv ( ) self . calcs [ pdbfilename_short ] [ 'pkavals' ] = self . X2 . readpka ( ) fd = open ( pdbfilename ) self . calcs [ pdbfilename_short ] [ 'pdblines' ] = fd . readlines ( ) fd . close ( ) self . label_count = self . label_count + 1 self . add_to_pulldown ( pdbfilename_short , label ) self . calc_select . set ( pdbfilename_short ) self . calc_disp [ pdbfilename_short ] . set ( 1 ) self . update_selected_calc ( ) elif pdbfilename [ - 4 : ] == '.ppc' : prog = Toplevel ( ) prog . geometry ( '250x100' ) prog . title ( 'Load progress' ) self . set_position ( prog ) self . load_file = StringVar ( ) self . load_file . set ( 'Opening file...' ) Label ( prog , textvariable = self . load_file ) . grid ( row = 0 , column = 0 ) prog . update_idletasks ( ) import pickle , copy , os fd = open ( pdbfilename ) calcs = pickle . load ( fd ) fd . close ( ) import os count = 0 for calc in calcs . keys ( ) : count = count + 1 self . load_file . set ( 'Parsing %s (%d of %d)' % ( os . path . split ( calc ) [ 1 ] , count , len ( calcs . keys ( ) ) ) ) prog . update_idletasks ( ) calc_name = os . path . split ( calc ) [ 1 ] self . calcs [ calc_name ] = copy . deepcopy ( calcs [ calc ] ) self . label_count = self . label_count + 1 self . add_to_pulldown ( calc_name , '' ) self . calc_select . set ( calc_name ) self . calc_disp [ calc_name ] . set ( 1 ) self . update_selected_calc ( ) prog . destroy ( ) elif pdbfilename [ - 4 : ] == '.pka' : import os pdbfilename_short = os . path . split ( pdbfilename ) [ 1 ] label = self . labels [ self . label_count ] self . calcs [ pdbfilename_short ] = { 'instance' : pKaIO . pKaIO ( pdbfilename ) , 'selected_groups' : [ ] , 'label' : label } self . X2 = self . calcs [ pdbfilename_short ] [ 'instance' ] self . calcs [ pdbfilename_short ] [ 'titcurv' ] = self . X2 . readtitcurv ( pdbfilename ) self . calcs [ pdbfilename_short ] [ 'pkavals' ] = self . X2 . readpka ( pdbfilename ) for group in self . calcs [ pdbfilename_short ] [ 'titcurv' ] : self . calcs [ pdbfilename_short ] [ 'titcurv' ] [ group ] [ 'pKa' ] = self . calcs [ pdbfilename_short ] [ 'pkavals' ] [ group ] [ 'pKa' ] fd = open ( pdbfilename ) lines = fd . readlines ( ) fd . close ( ) pdblines = self . X2 . read_MEADfile ( lines , mode = 'pdb' ) self . calcs [ pdbfilename_short ] [ 'pdblines' ] = pdblines self . label_count = self . label_count + 1 self . add_to_pulldown ( pdbfilename_short , label ) self . calc_select . set ( pdbfilename_short ) self . calc_disp [ pdbfilename_short ] . set ( 1 ) self . update_selected_calc ( ) return
Load the results of a pKa calculation
Load the results of a pKa calculation
"""Load the results of a pKa calculation""" # # Did we get a name? # # # Is it a WHAT IF type file? # # # Open the file and assess status # # # Read the titration curve # # # read the pKa values # # # Store the PDB file # # # Add to the display pulldown menu # # # pKaTool file # # # MEAD file # # # Read the titration curve # # # read the pKa values # # # Put the pKa value in the titration curves # # # Store the PDB file # # # Add to the display pulldown menu #
self
pdbfilename