pKaTool/pKaTool_main.py
def subtract_titration(self):
        """Subtract the second pKa calculation from the first to find differences in titration curves"""
        #
        # Choose the calc to subtract from
        #
        self.choose_win=Toplevel()
        lbl=Label(self.choose_win,text='Which calculation should we subtract from %s' %self.calc_select.get())
        lbl.grid(row=0,column=0,columnspan=4)
        #
        self.sub_calc=StringVar()
        self.sub_calc.set('Choose a dataset')
        s_button=Menubutton(self.choose_win,textvariable=self.sub_calc,relief=RAISED)
        # the menu
        s_menu=Menu(s_button,tearoff=0)
        s_button['menu']=s_menu
        for name in self.calcs.keys():
            s_menu.add_radiobutton(label=name,variable=self.sub_calc,value=name,indicatoron=1)
        s_button.grid(row=1,column=0,sticky='news')
        #
        Button(self.choose_win,text='Subtract',command=self.destroy_choose).grid(row=2,column=0)
        Button(self.choose_win,text='Cancel',command=self.cancel_subtract).grid(row=2,column=2)
        self.master.wait_window(self.choose_win)
        #
        # Create new set
        #
        first=self.current_selected_calc
        second=self.sub_calc.get()
        name=self.calcs[first]['label']+'-'+self.calcs[second]['label']
        #
        # Subtract the pKa values
        #
        intpkas=[]
        sub_pka={}
        for group in self.calcs[first]['pkavals'].keys():
            if self.calcs[second]['pkavals'].has_key(group):
                sub_pka[group]={}
                for property in self.calcs[first]['pkavals'][group].keys():
                    if self.calcs[second]['pkavals'][group].has_key(property):
                        diff=self.calcs[first]['pkavals'][group][property]-self.calcs[second]['pkavals'][group][property]
                        sub_pka[group][property]=diff
        #
        # Subtract the titration curves
        #
        sub_tits={}
        for group in self.calcs[first]['titcurv'].keys():
            if self.calcs[second]['titcurv'].has_key(group):
                sub_tits[group]={}
                for pH in self.calcs[first]['titcurv'][group].keys():
                    if self.calcs[second]['titcurv'][group].has_key(pH):
                        diff=self.calcs[first]['titcurv'][group][pH]-self.calcs[second]['titcurv'][group][pH]
                        sub_tits[group][pH]=diff
        #
        # Done subtracting. Create new set
        #
        label=self.labels[self.label_count]
        self.label_count=self.label_count+1
        self.calcs[name]={'titcurv':sub_tits.copy(),'label':label,'instance':None,'selected_groups':[],'pkavals':sub_pka.copy()}
        #
        # Add to the display pulldown menu
        #
        self.add_to_pulldown(name,label)
        self.calc_select.set(name)
        self.calc_disp[name].set(1)
        self.update_selected_calc()
        return
Subtract the second pKa calculation from the first to find differences in titration curves
Subtract the second pKa calculation from the first to find differences in titration curves
Subtract the second pKa calculation from the first to find differences in titration curves
def subtract_titration(self):
         Choose the calc to subtract from
        self.choose_win=Toplevel()
        lbl=Label(self.choose_win,text='Which calculation should we subtract from %s' %self.calc_select.get())
        lbl.grid(row=0,column=0,columnspan=4)
        self.sub_calc=StringVar()
        self.sub_calc.set('Choose a dataset')
        s_button=Menubutton(self.choose_win,textvariable=self.sub_calc,relief=RAISED)
         the menu
        s_menu=Menu(s_button,tearoff=0)
        s_button['menu']=s_menu
        for name in self.calcs.keys():
            s_menu.add_radiobutton(label=name,variable=self.sub_calc,value=name,indicatoron=1)
        s_button.grid(row=1,column=0,sticky='news')
        Button(self.choose_win,text='Subtract',command=self.destroy_choose).grid(row=2,column=0)
        Button(self.choose_win,text='Cancel',command=self.cancel_subtract).grid(row=2,column=2)
        self.master.wait_window(self.choose_win)
         Create new set
        first=self.current_selected_calc
        second=self.sub_calc.get()
        name=self.calcs[first]['label']+'-'+self.calcs[second]['label']
         Subtract the pKa values
        intpkas=[]
        sub_pka={}
        for group in self.calcs[first]['pkavals'].keys():
            if self.calcs[second]['pkavals'].has_key(group):
                sub_pka[group]={}
                for property in self.calcs[first]['pkavals'][group].keys():
                    if self.calcs[second]['pkavals'][group].has_key(property):
                        diff=self.calcs[first]['pkavals'][group][property]-self.calcs[second]['pkavals'][group][property]
                        sub_pka[group][property]=diff
         Subtract the titration curves
        sub_tits={}
        for group in self.calcs[first]['titcurv'].keys():
            if self.calcs[second]['titcurv'].has_key(group):
                sub_tits[group]={}
                for pH in self.calcs[first]['titcurv'][group].keys():
                    if self.calcs[second]['titcurv'][group].has_key(pH):
                        diff=self.calcs[first]['titcurv'][group][pH]-self.calcs[second]['titcurv'][group][pH]
                        sub_tits[group][pH]=diff
         Done subtracting. Create new set
        label=self.labels[self.label_count]
        self.label_count=self.label_count+1
        self.calcs[name]={'titcurv':sub_tits.copy(),'label':label,'instance':None,'selected_groups':[],'pkavals':sub_pka.copy()}
         Add to the display pulldown menu
        self.add_to_pulldown(name,label)
        self.calc_select.set(name)
        self.calc_disp[name].set(1)
        self.update_selected_calc()
        return
def subtract_titration ( self ) : self . choose_win = Toplevel ( ) lbl = Label ( self . choose_win , text = 'Which calculation should we subtract from %s' % self . calc_select . get ( ) ) lbl . grid ( row = 0 , column = 0 , columnspan = 4 ) self . sub_calc = StringVar ( ) self . sub_calc . set ( 'Choose a dataset' ) s_button = Menubutton ( self . choose_win , textvariable = self . sub_calc , relief = RAISED ) s_menu = Menu ( s_button , tearoff = 0 ) s_button [ 'menu' ] = s_menu for name in self . calcs . keys ( ) : s_menu . add_radiobutton ( label = name , variable = self . sub_calc , value = name , indicatoron = 1 ) s_button . grid ( row = 1 , column = 0 , sticky = 'news' ) Button ( self . choose_win , text = 'Subtract' , command = self . destroy_choose ) . grid ( row = 2 , column = 0 ) Button ( self . choose_win , text = 'Cancel' , command = self . cancel_subtract ) . grid ( row = 2 , column = 2 ) self . master . wait_window ( self . choose_win ) first = self . current_selected_calc second = self . sub_calc . get ( ) name = self . calcs [ first ] [ 'label' ] + '-' + self . calcs [ second ] [ 'label' ] intpkas = [ ] sub_pka = { } for group in self . calcs [ first ] [ 'pkavals' ] . keys ( ) : if self . calcs [ second ] [ 'pkavals' ] . has_key ( group ) : sub_pka [ group ] = { } for property in self . calcs [ first ] [ 'pkavals' ] [ group ] . keys ( ) : if self . calcs [ second ] [ 'pkavals' ] [ group ] . has_key ( property ) : diff = self . calcs [ first ] [ 'pkavals' ] [ group ] [ property ] - self . calcs [ second ] [ 'pkavals' ] [ group ] [ property ] sub_pka [ group ] [ property ] = diff sub_tits = { } for group in self . calcs [ first ] [ 'titcurv' ] . keys ( ) : if self . calcs [ second ] [ 'titcurv' ] . has_key ( group ) : sub_tits [ group ] = { } for pH in self . calcs [ first ] [ 'titcurv' ] [ group ] . keys ( ) : if self . calcs [ second ] [ 'titcurv' ] [ group ] . has_key ( pH ) : diff = self . calcs [ first ] [ 'titcurv' ] [ group ] [ pH ] - self . calcs [ second ] [ 'titcurv' ] [ group ] [ pH ] sub_tits [ group ] [ pH ] = diff label = self . labels [ self . label_count ] self . label_count = self . label_count + 1 self . calcs [ name ] = { 'titcurv' : sub_tits . copy ( ) , 'label' : label , 'instance' : None , 'selected_groups' : [ ] , 'pkavals' : sub_pka . copy ( ) } self . add_to_pulldown ( name , label ) self . calc_select . set ( name ) self . calc_disp [ name ] . set ( 1 ) self . update_selected_calc ( ) return
Subtract the second pKa calculation from the first to find differences in titration curves
Subtract the second pKa calculation from the first to find differences in titration curves
"""Subtract the second pKa calculation from the first to find differences in titration curves""" # # Choose the calc to subtract from # # # the menu # # # Create new set # # # Subtract the pKa values # # # Subtract the titration curves # # # Done subtracting. Create new set # # # Add to the display pulldown menu #
self