pKaTool/pKa_system_micro.py
def update_microstates(self,X):
        """Update the curves describing the microscopic states"""
        self.X = X
        phvals=X.all_states.keys()
        self.init_kcat_array()

        if getattr(self,'activity_data',None):
            for ph in self.activity_data:
                if not ph in phvals:
                    phvals.append(ph)

        phvals.sort()
        self.phvals=phvals
        #
        # Delete all lines
        #
        for obj in self.state_lines.keys():
            self.state_win_cv.delete(obj)
            del self.state_lines[obj]
        #
        # Get the states
        #
        self.states=states=X.all_states[phvals[0]].keys()
        states.sort()
        #
        # Do we have the window open?
        #
        if not getattr(self,'state_win',None):
            self.init_win(X)
        #
        # Draw the states
        #
        state_count=0

        for state in states:
            #
            # Get the colour
            #
            colour=self.colour_order[state_count%len(self.colour_order)]
            fg_col='black'
            if colour=='black' or colour=='blue':
                fg_col='white'
            if colour=='green':
                colour='cyan'
            state_count=state_count+1
            #
            # Draw the state
            #
            lastpH=phvals[0]
            lastcrg=X.all_states[lastpH][state]['pop']
            #
            # Normalise the population
            #
            pops=[]
            for pH in phvals[1:]:
                pops.append(X.all_states[pH][state]['pop'])
            max_pop=max(pops)
            if max_pop>0.0:
                factor=1.0/max_pop
            else:
                factor=1.0
            self.state_pop[state].set('Max pop: %5.2e' %max_pop)
            #
            # Draw the state if the user wants to
            #
            charges=[]
            for pH in phvals[1:]:
                lastx,lasty=self.get_xy(lastpH,lastcrg)
                crg=X.all_states[pH][state]['pop']
                x,y=self.get_xy(pH,crg)
                if self.state_box[state].get()==1:
                    self.state_lines[(self.state_win_cv.create_line(lastx,lasty,float(x),float(y),
                                                                    fill=colour,
                                                                    width=self.linewidth))]=1
                #
                # Scale the maximum population to 1.0 for pKa fitting
                #
                charges.append([pH,crg*factor])
                lastcrg=crg
                lastpH=pH
            #
            # Determine the pK1/2 values for this state
            #
            if self.determine_pkhalf_checkvar.get()==1:
                pkas=self.determine_pkhalf(charges,1)
                if len(pkas)>0:
                    self.pk1[state].set('%5.2f' %pkas[0])
                    if len(pkas)>1:
                        self.pk2[state].set('%5.2f' %pkas[1])
            else:
                self.pk1[state].set('NA')
                self.pk2[state].set('NA')
        #
        # Draw the primary CCPS
        #
        act_prof = self.get_act_prof_and_tc_and_ftir()[0]
        if act_prof!={}:
            lastpH=phvals[0]
            last_activity=act_prof[lastpH]
            for pH in phvals[1:]:
                lastx,lasty=self.get_xy(lastpH,last_activity)
                activity=act_prof[pH]
                x,y=self.get_xy(pH,activity)
                self.state_lines[(self.state_win_cv.create_line(lastx,lasty,float(x),float(y),
                                                                fill='green',
                                                                width=3))]=1
                last_activity=activity
                lastpH=pH
        #
        # Secondary CCPS
        #
        act_prof = self.get_act_prof_and_tc_and_ftir()[-1]
        if act_prof!={}:
            lastpH=phvals[0]
            last_activity=act_prof[lastpH]
            for pH in phvals[1:]:
                lastx,lasty=self.get_xy(lastpH,last_activity)
                activity=act_prof[pH]
                x,y=self.get_xy(pH,activity)
                self.state_lines[(self.state_win_cv.create_line(lastx,lasty,float(x),float(y),
                                                                fill='orange',
                                                                width=3))]=1
                last_activity=activity
                lastpH=pH
        #
        # Draw the primary experimental pH-activity profile
        #
        if getattr(self,'activity_data',None):    
            phs = self.activity_data.keys()
            phs.sort()
            for ph in phs:
                activity = self.activity_data[ph]
                x,y=self.get_xy(float(ph),float(activity))
                handle=self.state_win_cv.create_oval(x-2,y-2,x+2,y+2,fill='green')
                self.state_lines[handle]=1
        #
        # Draw the secondary experimental pH-activity profile
        #
        if getattr(self,'secondary_activity_data',None):    
            phs = self.secondary_activity_data.keys()
            phs.sort()
            for ph in phs:
                activity = self.secondary_activity_data[ph]
                x,y=self.get_xy(float(ph),float(activity))
                handle=self.state_win_cv.create_oval(x-2,y-2,x+2,y+2,fill='orange')
                self.state_lines[handle]=1

                    
        return
Update the curves describing the microscopic states
Update the curves describing the microscopic states
Update the curves describing the microscopic states
def update_microstates(self,X):
        self.X = X
        phvals=X.all_states.keys()
        self.init_kcat_array()
        if getattr(self,'activity_data',None):
            for ph in self.activity_data:
                if not ph in phvals:
                    phvals.append(ph)
        phvals.sort()
        self.phvals=phvals
         Delete all lines
        for obj in self.state_lines.keys():
            self.state_win_cv.delete(obj)
            del self.state_lines[obj]
         Get the states
        self.states=states=X.all_states[phvals[0]].keys()
        states.sort()
         Do we have the window open?
        if not getattr(self,'state_win',None):
            self.init_win(X)
         Draw the states
        state_count=0
        for state in states:
             Get the colour
            colour=self.colour_order[state_count%len(self.colour_order)]
            fg_col='black'
            if colour=='black' or colour=='blue':
                fg_col='white'
            if colour=='green':
                colour='cyan'
            state_count=state_count+1
             Draw the state
            lastpH=phvals[0]
            lastcrg=X.all_states[lastpH][state]['pop']
             Normalise the population
            pops=[]
            for pH in phvals[1:]:
                pops.append(X.all_states[pH][state]['pop'])
            max_pop=max(pops)
            if max_pop>0.0:
                factor=1.0/max_pop
            else:
                factor=1.0
            self.state_pop[state].set('Max pop: %5.2e' %max_pop)
             Draw the state if the user wants to
            charges=[]
            for pH in phvals[1:]:
                lastx,lasty=self.get_xy(lastpH,lastcrg)
                crg=X.all_states[pH][state]['pop']
                x,y=self.get_xy(pH,crg)
                if self.state_box[state].get()==1:
                    self.state_lines[(self.state_win_cv.create_line(lastx,lasty,float(x),float(y),
                                                                    fill=colour,
                                                                    width=self.linewidth))]=1
                 Scale the maximum population to 1.0 for pKa fitting
                charges.append([pH,crg*factor])
                lastcrg=crg
                lastpH=pH
             Determine the pK1/2 values for this state
            if self.determine_pkhalf_checkvar.get()==1:
                pkas=self.determine_pkhalf(charges,1)
                if len(pkas)>0:
                    self.pk1[state].set('%5.2f' %pkas[0])
                    if len(pkas)>1:
                        self.pk2[state].set('%5.2f' %pkas[1])
            else:
                self.pk1[state].set('NA')
                self.pk2[state].set('NA')
         Draw the primary CCPS
        act_prof = self.get_act_prof_and_tc_and_ftir()[0]
        if act_prof!={}:
            lastpH=phvals[0]
            last_activity=act_prof[lastpH]
            for pH in phvals[1:]:
                lastx,lasty=self.get_xy(lastpH,last_activity)
                activity=act_prof[pH]
                x,y=self.get_xy(pH,activity)
                self.state_lines[(self.state_win_cv.create_line(lastx,lasty,float(x),float(y),
                                                                fill='green',
                                                                width=3))]=1
                last_activity=activity
                lastpH=pH
         Secondary CCPS
        act_prof = self.get_act_prof_and_tc_and_ftir()[-1]
        if act_prof!={}:
            lastpH=phvals[0]
            last_activity=act_prof[lastpH]
            for pH in phvals[1:]:
                lastx,lasty=self.get_xy(lastpH,last_activity)
                activity=act_prof[pH]
                x,y=self.get_xy(pH,activity)
                self.state_lines[(self.state_win_cv.create_line(lastx,lasty,float(x),float(y),
                                                                fill='orange',
                                                                width=3))]=1
                last_activity=activity
                lastpH=pH
         Draw the primary experimental pH-activity profile
        if getattr(self,'activity_data',None):    
            phs = self.activity_data.keys()
            phs.sort()
            for ph in phs:
                activity = self.activity_data[ph]
                x,y=self.get_xy(float(ph),float(activity))
                handle=self.state_win_cv.create_oval(x-2,y-2,x+2,y+2,fill='green')
                self.state_lines[handle]=1
         Draw the secondary experimental pH-activity profile
        if getattr(self,'secondary_activity_data',None):    
            phs = self.secondary_activity_data.keys()
            phs.sort()
            for ph in phs:
                activity = self.secondary_activity_data[ph]
                x,y=self.get_xy(float(ph),float(activity))
                handle=self.state_win_cv.create_oval(x-2,y-2,x+2,y+2,fill='orange')
                self.state_lines[handle]=1
        return
def update_microstates ( self , X ) : self . X = X phvals = X . all_states . keys ( ) self . init_kcat_array ( ) if getattr ( self , 'activity_data' , None ) : for ph in self . activity_data : if not ph in phvals : phvals . append ( ph ) phvals . sort ( ) self . phvals = phvals for obj in self . state_lines . keys ( ) : self . state_win_cv . delete ( obj ) del self . state_lines [ obj ] self . states = states = X . all_states [ phvals [ 0 ] ] . keys ( ) states . sort ( ) if not getattr ( self , 'state_win' , None ) : self . init_win ( X ) state_count = 0 for state in states : colour = self . colour_order [ state_count % len ( self . colour_order ) ] fg_col = 'black' if colour == 'black' or colour == 'blue' : fg_col = 'white' if colour == 'green' : colour = 'cyan' state_count = state_count + 1 lastpH = phvals [ 0 ] lastcrg = X . all_states [ lastpH ] [ state ] [ 'pop' ] pops = [ ] for pH in phvals [ 1 : ] : pops . append ( X . all_states [ pH ] [ state ] [ 'pop' ] ) max_pop = max ( pops ) if max_pop > 0.0 : factor = 1.0 / max_pop else : factor = 1.0 self . state_pop [ state ] . set ( 'Max pop: %5.2e' % max_pop ) charges = [ ] for pH in phvals [ 1 : ] : lastx , lasty = self . get_xy ( lastpH , lastcrg ) crg = X . all_states [ pH ] [ state ] [ 'pop' ] x , y = self . get_xy ( pH , crg ) if self . state_box [ state ] . get ( ) == 1 : self . state_lines [ ( self . state_win_cv . create_line ( lastx , lasty , float ( x ) , float ( y ) , fill = colour , width = self . linewidth ) ) ] = 1 charges . append ( [ pH , crg * factor ] ) lastcrg = crg lastpH = pH if self . determine_pkhalf_checkvar . get ( ) == 1 : pkas = self . determine_pkhalf ( charges , 1 ) if len ( pkas ) > 0 : self . pk1 [ state ] . set ( '%5.2f' % pkas [ 0 ] ) if len ( pkas ) > 1 : self . pk2 [ state ] . set ( '%5.2f' % pkas [ 1 ] ) else : self . pk1 [ state ] . set ( 'NA' ) self . pk2 [ state ] . set ( 'NA' ) act_prof = self . get_act_prof_and_tc_and_ftir ( ) [ 0 ] if act_prof != { } : lastpH = phvals [ 0 ] last_activity = act_prof [ lastpH ] for pH in phvals [ 1 : ] : lastx , lasty = self . get_xy ( lastpH , last_activity ) activity = act_prof [ pH ] x , y = self . get_xy ( pH , activity ) self . state_lines [ ( self . state_win_cv . create_line ( lastx , lasty , float ( x ) , float ( y ) , fill = 'green' , width = 3 ) ) ] = 1 last_activity = activity lastpH = pH act_prof = self . get_act_prof_and_tc_and_ftir ( ) [ - 1 ] if act_prof != { } : lastpH = phvals [ 0 ] last_activity = act_prof [ lastpH ] for pH in phvals [ 1 : ] : lastx , lasty = self . get_xy ( lastpH , last_activity ) activity = act_prof [ pH ] x , y = self . get_xy ( pH , activity ) self . state_lines [ ( self . state_win_cv . create_line ( lastx , lasty , float ( x ) , float ( y ) , fill = 'orange' , width = 3 ) ) ] = 1 last_activity = activity lastpH = pH if getattr ( self , 'activity_data' , None ) : phs = self . activity_data . keys ( ) phs . sort ( ) for ph in phs : activity = self . activity_data [ ph ] x , y = self . get_xy ( float ( ph ) , float ( activity ) ) handle = self . state_win_cv . create_oval ( x - 2 , y - 2 , x + 2 , y + 2 , fill = 'green' ) self . state_lines [ handle ] = 1 if getattr ( self , 'secondary_activity_data' , None ) : phs = self . secondary_activity_data . keys ( ) phs . sort ( ) for ph in phs : activity = self . secondary_activity_data [ ph ] x , y = self . get_xy ( float ( ph ) , float ( activity ) ) handle = self . state_win_cv . create_oval ( x - 2 , y - 2 , x + 2 , y + 2 , fill = 'orange' ) self . state_lines [ handle ] = 1 return
Update the curves describing the microscopic states
Update the curves describing the microscopic states
"""Update the curves describing the microscopic states""" # # Delete all lines # # # Get the states # # # Do we have the window open? # # # Draw the states # # # Get the colour # # # Draw the state # # # Normalise the population # # # Draw the state if the user wants to # # # Scale the maximum population to 1.0 for pKa fitting # # # Determine the pK1/2 values for this state # # # Draw the primary CCPS # # # Secondary CCPS # # # Draw the primary experimental pH-activity profile # # # Draw the secondary experimental pH-activity profile #
self
X