pKa/Design_pKa.py
def calculate_pKa_change(self,mutations):
        """ Calculate the dpKa value(s) for the residue(s) in self.desired_pKa_changes
            and calculate the score for this set of mutations"""
        #
        # Which method are we going to use?
        #
        dpKas=None
        if not self.params['tabulated']:
            #
            # Explicit (each combination of mutations is evaluated separately)
            #
            dpKas=self.calculate_dpKas_explicit(mutations,return_protstates=self.params['stability_mode'])
            if self.params['stability_mode']:
                self.prot_states=dpKas[1]
                dpKas=dpKas[0]
        else:
            #
            # Tabulated (dpKa values from combinations of mutations is calculated
            # by adding the dpKa values for each individual mutation)
            #
            dpKas=self.calculate_dpKas_tabulated(mutations)
        #
        # If dpKas is None then we used a mutation that cannot be modelled
        #
        if not dpKas:
            return None,None
        #
        # Remove pKa changes that are too small
        #
        for group in dpKas.keys():
            #
            # Is the shift significant?
            #
            if dpKas[group]:
                if abs(dpKas[group])<self.params['sens_limit'] and self.params['calc_dpka']!=1:
                    dpKas[group]=0.0
        #
        # Score the final result
        # Score is calculated as sum of (desired_change-achieved_change)*weight
        #
        score=0.0
        import math
        desired_residues=self.desired_pKa_changes.keys()
        desired_residues.sort()
        for dpKa_residue in desired_residues:
            #
            # Score each delta pKa
            #
            weight=self.desired_pKa_changes[dpKa_residue]['weight']
            #
            # Did we get a pKa shift?
            #
            if dpKas.has_key(dpKa_residue):
                if dpKas[dpKa_residue]!=None:
                    # Yes
                    score=score+abs(self.desired_pKa_changes[dpKa_residue]['dpKa']-dpKas[dpKa_residue])*weight
                else:
                    # No - this means an extreme shift
                    # We give an unfavourable score and warn the user
                    #
                    score=score+200
                    print 'A set of mutations gave an undefined pKa value for %s\n The set of mutations was %s' %(residue,str(mutations))
            else:
                print 'No dpKa for %s with these mutations: %s' %(dpKa_residue,str(mutations))                
        #
        # Add term penalising ineffective mutations
        #
        for mutation in mutations:
            if mutation:
                score=score+self.params['mutation_penalty']
        return score,dpKas
 Calculate the dpKa value(s) for the residue(s) in self.desired_pKa_changes
            and calculate the score for this set of mutations
Calculate the dpKa value(s) for the residue(s) in self.desired_pKa_changes
and calculate the score for this set of mutations
Calculate the dpKa value ( s ) for the residue ( s ) in self . desired_pKa_changes and calculate the score for this set of mutations
def calculate_pKa_change(self,mutations):
         Which method are we going to use?
        dpKas=None
        if not self.params['tabulated']:
             Explicit (each combination of mutations is evaluated separately)
            dpKas=self.calculate_dpKas_explicit(mutations,return_protstates=self.params['stability_mode'])
            if self.params['stability_mode']:
                self.prot_states=dpKas[1]
                dpKas=dpKas[0]
        else:
             Tabulated (dpKa values from combinations of mutations is calculated
             by adding the dpKa values for each individual mutation)
            dpKas=self.calculate_dpKas_tabulated(mutations)
         If dpKas is None then we used a mutation that cannot be modelled
        if not dpKas:
            return None,None
         Remove pKa changes that are too small
        for group in dpKas.keys():
             Is the shift significant?
            if dpKas[group]:
                if abs(dpKas[group])<self.params['sens_limit'] and self.params['calc_dpka']!=1:
                    dpKas[group]=0.0
         Score the final result
         Score is calculated as sum of (desired_change-achieved_change)*weight
        score=0.0
        import math
        desired_residues=self.desired_pKa_changes.keys()
        desired_residues.sort()
        for dpKa_residue in desired_residues:
             Score each delta pKa
            weight=self.desired_pKa_changes[dpKa_residue]['weight']
             Did we get a pKa shift?
            if dpKas.has_key(dpKa_residue):
                if dpKas[dpKa_residue]!=None:
                     Yes
                    score=score+abs(self.desired_pKa_changes[dpKa_residue]['dpKa']-dpKas[dpKa_residue])*weight
                else:
                     No - this means an extreme shift
                     We give an unfavourable score and warn the user
                    score=score+200
                    print 'A set of mutations gave an undefined pKa value for %s\n The set of mutations was %s' %(residue,str(mutations))
            else:
                print 'No dpKa for %s with these mutations: %s' %(dpKa_residue,str(mutations))                
         Add term penalising ineffective mutations
        for mutation in mutations:
            if mutation:
                score=score+self.params['mutation_penalty']
        return score,dpKas
def calculate_pKa_change ( self , mutations ) : dpKas = None if not self . params [ 'tabulated' ] : dpKas = self . calculate_dpKas_explicit ( mutations , return_protstates = self . params [ 'stability_mode' ] ) if self . params [ 'stability_mode' ] : self . prot_states = dpKas [ 1 ] dpKas = dpKas [ 0 ] else : dpKas = self . calculate_dpKas_tabulated ( mutations ) if not dpKas : return None , None for group in dpKas . keys ( ) : if dpKas [ group ] : if abs ( dpKas [ group ] ) < self . params [ 'sens_limit' ] and self . params [ 'calc_dpka' ] != 1 : dpKas [ group ] = 0.0 score = 0.0 import math desired_residues = self . desired_pKa_changes . keys ( ) desired_residues . sort ( ) for dpKa_residue in desired_residues : weight = self . desired_pKa_changes [ dpKa_residue ] [ 'weight' ] if dpKas . has_key ( dpKa_residue ) : if dpKas [ dpKa_residue ] != None : score = score + abs ( self . desired_pKa_changes [ dpKa_residue ] [ 'dpKa' ] - dpKas [ dpKa_residue ] ) * weight else : score = score + 200 print 'A set of mutations gave an undefined pKa value for %s\n The set of mutations was %s' % ( residue , str ( mutations ) ) else : print 'No dpKa for %s with these mutations: %s' % ( dpKa_residue , str ( mutations ) ) for mutation in mutations : if mutation : score = score + self . params [ 'mutation_penalty' ] return score , dpKas
Calculate the dpKa value(s) for the residue(s) in self.desired_pKa_changes
and calculate the score for this set of mutations
Calculate the dpKa value ( s ) for the residue ( s ) in self . desired_pKa_changes and calculate the score for this set of mutations
""" Calculate the dpKa value(s) for the residue(s) in self.desired_pKa_changes
            and calculate the score for this set of mutations""" # # Which method are we going to use? # # # Explicit (each combination of mutations is evaluated separately) # # # Tabulated (dpKa values from combinations of mutations is calculated # by adding the dpKa values for each individual mutation) # # # If dpKas is None then we used a mutation that cannot be modelled # # # Remove pKa changes that are too small # # # Is the shift significant? # # # Score the final result # Score is calculated as sum of (desired_change-achieved_change)*weight # # # Score each delta pKa # # # Did we get a pKa shift? # # Yes # No - this means an extreme shift # We give an unfavourable score and warn the user # # # Add term penalising ineffective mutations #
self
mutations