pKaTool/CCPS_stab_opt.py
def _CCPS_population_base(self,variable,primary,spec):
        """Function that will give a score for how well one of the CCPS population meets the targets"""
        #
        # Loaded profile or entered values
        #
        if spec['profile']['var'].get()==0:
            #
            # Entered values
            #
            # Get the pH values where we want to impose the criterium
            #
            if not self.CCPS_pH_vals:
                self.CCPS_pH_vals=self.get_pH_range(spec['pH']['var'].get())
            print 'Monitoring activity at these pH values',self.CCPS_pH_vals
            #
            # pH values have already been identified
            #
            opttype=spec['opttype']['var'].get()
            cutoff=spec['cutoff']['var'].get()
            if opttype=='maximise':
                sum_act=0.0
                count=0
                for pH in self.CCPS_pH_vals:
                    if primary:
                        if self.act_prof[pH]<cutoff:
                            sum_act=sum_act+self.act_prof[pH]
                            count=count+1
                    else:
                        if self.act_prof2[pH]<cutoff:
                            sum_act=sum_act+self.act_prof2[pH]
                            count=count+1
            
                if count>1:
                    sum_act=sum_act/float(count)
                sum_act=max(cutoff/100.0-sum_act,0)
            else:
                raise Exception
        else:
            #
            # Loaded profile
            #
            sum_act=0.0
            #
            # Optimse profile, or each protonation state on its own
            #
            if spec['sumopt']['var'].get()==1:
                for pH in variable.keys():
                    if primary:
                        sum_act=sum_act+abs(variable[pH]-self.act_prof[pH])
                    else:
                        sum_act=sum_act+abs(variable[pH]-self.act_prof2[pH])
            else:
                #
                # Find the difference between each protonation state
                #
                diffs=[]
                for state in self.states:
                    thisdiff=0.0
                    if (primary and self.act_state[state].get()==1) or (not primary and self.act_state2[state].get()==1):
                        for pH in variable.keys():
                            thisdiff=thisdiff+abs(self.X.all_states[pH][state]['pop']-variable[pH])
                        diffs.append(thisdiff)
                sum_act=max(diffs)
        #
        # Scale the sum by the weight
        #
        sum_act=sum_act*spec['weight']['var'].get()
        return sum_act
Function that will give a score for how well one of the CCPS population meets the targets
Function that will give a score for how well one of the CCPS population meets the targets
Function that will give a score for how well one of the CCPS population meets the targets
def _CCPS_population_base(self,variable,primary,spec):
         Loaded profile or entered values
        if spec['profile']['var'].get()==0:
             Entered values
             Get the pH values where we want to impose the criterium
            if not self.CCPS_pH_vals:
                self.CCPS_pH_vals=self.get_pH_range(spec['pH']['var'].get())
            print 'Monitoring activity at these pH values',self.CCPS_pH_vals
             pH values have already been identified
            opttype=spec['opttype']['var'].get()
            cutoff=spec['cutoff']['var'].get()
            if opttype=='maximise':
                sum_act=0.0
                count=0
                for pH in self.CCPS_pH_vals:
                    if primary:
                        if self.act_prof[pH]<cutoff:
                            sum_act=sum_act+self.act_prof[pH]
                            count=count+1
                    else:
                        if self.act_prof2[pH]<cutoff:
                            sum_act=sum_act+self.act_prof2[pH]
                            count=count+1
                if count>1:
                    sum_act=sum_act/float(count)
                sum_act=max(cutoff/100.0-sum_act,0)
            else:
                raise Exception
        else:
             Loaded profile
            sum_act=0.0
             Optimse profile, or each protonation state on its own
            if spec['sumopt']['var'].get()==1:
                for pH in variable.keys():
                    if primary:
                        sum_act=sum_act+abs(variable[pH]-self.act_prof[pH])
                    else:
                        sum_act=sum_act+abs(variable[pH]-self.act_prof2[pH])
            else:
                 Find the difference between each protonation state
                diffs=[]
                for state in self.states:
                    thisdiff=0.0
                    if (primary and self.act_state[state].get()==1) or (not primary and self.act_state2[state].get()==1):
                        for pH in variable.keys():
                            thisdiff=thisdiff+abs(self.X.all_states[pH][state]['pop']-variable[pH])
                        diffs.append(thisdiff)
                sum_act=max(diffs)
         Scale the sum by the weight
        sum_act=sum_act*spec['weight']['var'].get()
        return sum_act
def _CCPS_population_base ( self , variable , primary , spec ) : if spec [ 'profile' ] [ 'var' ] . get ( ) == 0 : if not self . CCPS_pH_vals : self . CCPS_pH_vals = self . get_pH_range ( spec [ 'pH' ] [ 'var' ] . get ( ) ) print 'Monitoring activity at these pH values' , self . CCPS_pH_vals opttype = spec [ 'opttype' ] [ 'var' ] . get ( ) cutoff = spec [ 'cutoff' ] [ 'var' ] . get ( ) if opttype == 'maximise' : sum_act = 0.0 count = 0 for pH in self . CCPS_pH_vals : if primary : if self . act_prof [ pH ] < cutoff : sum_act = sum_act + self . act_prof [ pH ] count = count + 1 else : if self . act_prof2 [ pH ] < cutoff : sum_act = sum_act + self . act_prof2 [ pH ] count = count + 1 if count > 1 : sum_act = sum_act / float ( count ) sum_act = max ( cutoff / 100.0 - sum_act , 0 ) else : raise Exception else : sum_act = 0.0 if spec [ 'sumopt' ] [ 'var' ] . get ( ) == 1 : for pH in variable . keys ( ) : if primary : sum_act = sum_act + abs ( variable [ pH ] - self . act_prof [ pH ] ) else : sum_act = sum_act + abs ( variable [ pH ] - self . act_prof2 [ pH ] ) else : diffs = [ ] for state in self . states : thisdiff = 0.0 if ( primary and self . act_state [ state ] . get ( ) == 1 ) or ( not primary and self . act_state2 [ state ] . get ( ) == 1 ) : for pH in variable . keys ( ) : thisdiff = thisdiff + abs ( self . X . all_states [ pH ] [ state ] [ 'pop' ] - variable [ pH ] ) diffs . append ( thisdiff ) sum_act = max ( diffs ) sum_act = sum_act * spec [ 'weight' ] [ 'var' ] . get ( ) return sum_act
Function that will give a score for how well one of the CCPS population meets the targets
Function that will give a score for how well one of the CCPS population meets the targets
"""Function that will give a score for how well one of the CCPS population meets the targets""" # # Loaded profile or entered values # # # Entered values # # Get the pH values where we want to impose the criterium # # # pH values have already been identified # # # Loaded profile # # # Optimse profile, or each protonation state on its own # # # Find the difference between each protonation state # # # Scale the sum by the weight #
self
variable
primary
spec