pKaTool/pKa_system_file_menu.py
def convert_titration_data(self,exp_tit_data, acid_bases = None):
        """Scale the loaded curves and fix the experimental -> theoretical curve mapping"""
        if not getattr(self,'titration_data',None):
            self.titration_data={}
        #
        # associate experimental curves with groups
        #
        do_scaling = IntVar()
        keys = exp_tit_data.keys()

        # experimental -> theoretical group mapping, if not provided
        if acid_bases == None:
            acid_bases = []
            for key in keys:
                # exp residue, acid/base,Group name
                temp = [key, StringVar(),StringVar()]
                acid_bases.append(temp)
            popup = Dialog(self.window, acid_bases, do_scaling, self.titration_curves,self.groups)
            self.window.wait_window(popup.top)

        else:
            do_scaling.set(1)

        for i in range(len(acid_bases)):
            if not acid_bases[i][2].get() == 'None':
                #print 'Matching',acid_bases[i][2].get(),'with',acid_bases[i][0]
                #
                # Name groups in gui
                #
                j = int(acid_bases[i][2].get()[1:5]) #This is probably a stupid way to find the group index
                self.titration_data[acid_bases[i][2].get()]= exp_tit_data[acid_bases[i][0]]

                self.groups[j].name.set(keys[i])
        #
        # scale data to fit titration curves
        #
        if do_scaling.get() == 1:
            for key in self.titration_data.keys():
                min = 1e6
                max = -1e6
                pHatMax = 0
                pHatMin = 0
                for ph in self.titration_data[key].keys():
                    cur = self.titration_data[key][ph]
                    if cur > max:
                        max = cur
                        pHatMax = ph
                    if cur < min:
                        min = cur
                        pHatMin = ph

                type = 1
                if pHatMax < pHatMin:
                    type = 2

                a_b = ''
                for i in range(len(acid_bases)):
                    if key == acid_bases[i][2].get():
                        a_b = acid_bases[i][1].get()

                for ph in self.titration_data[key].keys():
                    if type == 1:
                        if a_b == 'acid':
                            self.titration_data[key][ph] = -(self.titration_data[key][ph]-min)/(max - min)
                        elif a_b == 'base':
                            self.titration_data[key][ph] = -(self.titration_data[key][ph]-max)/(max - min)
                    elif type == 2:
                        if a_b == 'acid':
                            self.titration_data[key][ph] = (self.titration_data[key][ph]-max)/(max - min)
                        elif a_b == 'base':
                            self.titration_data[key][ph] = (self.titration_data[key][ph]-min)/(max - min)

            #
            # Set the flag for displaying loaded curves
            #
            self.display_loaded_curves.set(1)
            self.update_pkasystem_curves()
        return
Scale the loaded curves and fix the experimental -> theoretical curve mapping
Scale the loaded curves and fix the experimental -> theoretical curve mapping
Scale the loaded curves and fix the experimental - > theoretical curve mapping
def convert_titration_data(self,exp_tit_data, acid_bases = None):
        if not getattr(self,'titration_data',None):
            self.titration_data={}
         associate experimental curves with groups
        do_scaling = IntVar()
        keys = exp_tit_data.keys()
         experimental -> theoretical group mapping, if not provided
        if acid_bases == None:
            acid_bases = []
            for key in keys:
                 exp residue, acid/base,Group name
                temp = [key, StringVar(),StringVar()]
                acid_bases.append(temp)
            popup = Dialog(self.window, acid_bases, do_scaling, self.titration_curves,self.groups)
            self.window.wait_window(popup.top)
        else:
            do_scaling.set(1)
        for i in range(len(acid_bases)):
            if not acid_bases[i][2].get() == 'None':
                print 'Matching',acid_bases[i][2].get(),'with',acid_bases[i][0]
                 Name groups in gui
                j = int(acid_bases[i][2].get()[1:5]) This is probably a stupid way to find the group index
                self.titration_data[acid_bases[i][2].get()]= exp_tit_data[acid_bases[i][0]]
                self.groups[j].name.set(keys[i])
         scale data to fit titration curves
        if do_scaling.get() == 1:
            for key in self.titration_data.keys():
                min = 1e6
                max = -1e6
                pHatMax = 0
                pHatMin = 0
                for ph in self.titration_data[key].keys():
                    cur = self.titration_data[key][ph]
                    if cur > max:
                        max = cur
                        pHatMax = ph
                    if cur < min:
                        min = cur
                        pHatMin = ph
                type = 1
                if pHatMax < pHatMin:
                    type = 2
                a_b = ''
                for i in range(len(acid_bases)):
                    if key == acid_bases[i][2].get():
                        a_b = acid_bases[i][1].get()
                for ph in self.titration_data[key].keys():
                    if type == 1:
                        if a_b == 'acid':
                            self.titration_data[key][ph] = -(self.titration_data[key][ph]-min)/(max - min)
                        elif a_b == 'base':
                            self.titration_data[key][ph] = -(self.titration_data[key][ph]-max)/(max - min)
                    elif type == 2:
                        if a_b == 'acid':
                            self.titration_data[key][ph] = (self.titration_data[key][ph]-max)/(max - min)
                        elif a_b == 'base':
                            self.titration_data[key][ph] = (self.titration_data[key][ph]-min)/(max - min)
             Set the flag for displaying loaded curves
            self.display_loaded_curves.set(1)
            self.update_pkasystem_curves()
        return
def convert_titration_data ( self , exp_tit_data , acid_bases = None ) : if not getattr ( self , 'titration_data' , None ) : self . titration_data = { } do_scaling = IntVar ( ) keys = exp_tit_data . keys ( ) if acid_bases == None : acid_bases = [ ] for key in keys : temp = [ key , StringVar ( ) , StringVar ( ) ] acid_bases . append ( temp ) popup = Dialog ( self . window , acid_bases , do_scaling , self . titration_curves , self . groups ) self . window . wait_window ( popup . top ) else : do_scaling . set ( 1 ) for i in range ( len ( acid_bases ) ) : if not acid_bases [ i ] [ 2 ] . get ( ) == 'None' : j = int ( acid_bases [ i ] [ 2 ] . get ( ) [ 1 : 5 ] ) self . titration_data [ acid_bases [ i ] [ 2 ] . get ( ) ] = exp_tit_data [ acid_bases [ i ] [ 0 ] ] self . groups [ j ] . name . set ( keys [ i ] ) if do_scaling . get ( ) == 1 : for key in self . titration_data . keys ( ) : min = 1e6 max = - 1e6 pHatMax = 0 pHatMin = 0 for ph in self . titration_data [ key ] . keys ( ) : cur = self . titration_data [ key ] [ ph ] if cur > max : max = cur pHatMax = ph if cur < min : min = cur pHatMin = ph type = 1 if pHatMax < pHatMin : type = 2 a_b = '' for i in range ( len ( acid_bases ) ) : if key == acid_bases [ i ] [ 2 ] . get ( ) : a_b = acid_bases [ i ] [ 1 ] . get ( ) for ph in self . titration_data [ key ] . keys ( ) : if type == 1 : if a_b == 'acid' : self . titration_data [ key ] [ ph ] = - ( self . titration_data [ key ] [ ph ] - min ) / ( max - min ) elif a_b == 'base' : self . titration_data [ key ] [ ph ] = - ( self . titration_data [ key ] [ ph ] - max ) / ( max - min ) elif type == 2 : if a_b == 'acid' : self . titration_data [ key ] [ ph ] = ( self . titration_data [ key ] [ ph ] - max ) / ( max - min ) elif a_b == 'base' : self . titration_data [ key ] [ ph ] = ( self . titration_data [ key ] [ ph ] - min ) / ( max - min ) self . display_loaded_curves . set ( 1 ) self . update_pkasystem_curves ( ) return
Scale the loaded curves and fix the experimental -> theoretical curve mapping
Scale the loaded curves and fix the experimental - > theoretical curve mapping
"""Scale the loaded curves and fix the experimental -> theoretical curve mapping""" # # associate experimental curves with groups # # experimental -> theoretical group mapping, if not provided # exp residue, acid/base,Group name #print 'Matching',acid_bases[i][2].get(),'with',acid_bases[i][0] # # Name groups in gui # #This is probably a stupid way to find the group index # # scale data to fit titration curves # # # Set the flag for displaying loaded curves #
self
exp_tit_data
acid_bases