pKa/Design_pKa.py
def dpKa_philn10(self,mutation,target_residue,verbose=None):
        """
        # For a given mutation, calculate the change in the pKa value if the target using phi/ln(10)
        """
        # If we have no mutation, then we have no change
        #
        if not mutation:
            return 0.0
        #
        # Check that target_residue and mutation is not the same residue
        #
        import pKD_tools
        if pKD_tools.get_resnum_from_mut(mutation)==pKD_tools.get_resnum_from_res(target_residue):
            return None
        #
        # Get the interaction energy 
        #
        int_ene=None
        if self.data.has_key(mutation):
            if self.data[mutation].has_key('neutral mutation'):
                #
                # We have a neutral mutation e.g. ARG:0112:GLN
                # In this case we get the interaction energy from the matrix file
                #
                oldres=pKD_tools.get_oldres_from_mut(mutation)
                newres=pKD_tools.get_newres_from_mut(mutation)
                #
                # Check that we have a neutral mutation
                #
                if pKarun.is_titratable(oldres) and not pKarun.is_titratable(newres):
                    int_ene=self.matrix[oldres][target_residue]
                    int_ene=int_ene[0]-int_ene[1]-int_ene[2]+int_ene[3]
                else:
                    print 'Could not find interaction energy'
                    print 'oldres',oldres
                    print 'target',target_residue
                    int_ene=0.0
                    print 'This should not happen'
                    raise pKD_error('Something is wrong')
            elif self.data[mutation].has_key(target_residue):
                int_ene=self.data[mutation][target_residue]
            else:
                print 'Could not find residue: %s ' %mutation
                print 'When trying to get the interaction energy for mutation %s with target residue %s' %(str(mutation),str(target_residue))
                keys=self.data[mutation].keys()
                keys.sort()
                print keys
                raise pKD_error('Could not find interaction energy')
        else:
            print 'Could not find mutation: %s' %mutation
            keys=self.data.keys()
            keys.sort()
            print keys
            raise Exception()
        if not int_ene:
            raise pKD_error('Could not get interaction energy')
        #
        # Calculate the dpKa 
        #
        dpKa=0.0
        import math
        #
        # The sign of the interaction energy tells us if we have
        # an upward or a downward shift
        #
        if pKarun.isacid(target_residue):
            # Acid
            dpKa=int_ene/math.log(10)
        else:
            # Base
            dpKa=-int_ene/math.log(10)
        #
        # Was the wt residue (that of the mutation) a charged group?
        #
        import string
        number=string.split(mutation,':')[1]
        new_residue=':'+number+':'+string.split(mutation,':')[-1]
        old_residue=':'+number+':'+string.split(mutation,':')[0]
        if pKarun.is_charged(old_residue):
                #
                # Calculate effect of the mutation
                #
                #if pKa.istitratable(new_residue):
                if pKarun.is_charged(new_residue):
                    if pKarun.isacid(old_residue)==pKarun.isacid(mutation):
                        dpKa=0.0
                    else:
                        #
                        # If it was the opposite sign, then we get twice the effect
                        #
                        dpKa=2.0*dpKa
                else:
                    #
                    # Not titratable, - a neutral mutation
                    # Opposite effect of old residue
                    #
                    if pKarun.isacid(target_residue):
                        # Acid
                        dpKa=-int_ene/math.log(10)
                    else:
                        # Base
                        dpKa=int_ene/math.log(10)
        #
        # ok, all done. Return dpKa
        #
        return dpKa

        # For a given mutation, calculate the change in the pKa value if the target using phi/ln(10)
        
For a given mutation, calculate the change in the pKa value if the target using phi/ln(10)
For a given mutation calculate the change in the pKa value if the target using phi / ln ( 10 )
def dpKa_philn10(self,mutation,target_residue,verbose=None):
        if not mutation:
            return 0.0
         Check that target_residue and mutation is not the same residue
        import pKD_tools
        if pKD_tools.get_resnum_from_mut(mutation)==pKD_tools.get_resnum_from_res(target_residue):
            return None
         Get the interaction energy 
        int_ene=None
        if self.data.has_key(mutation):
            if self.data[mutation].has_key('neutral mutation'):
                 We have a neutral mutation e.g. ARG:0112:GLN
                 In this case we get the interaction energy from the matrix file
                oldres=pKD_tools.get_oldres_from_mut(mutation)
                newres=pKD_tools.get_newres_from_mut(mutation)
                 Check that we have a neutral mutation
                if pKarun.is_titratable(oldres) and not pKarun.is_titratable(newres):
                    int_ene=self.matrix[oldres][target_residue]
                    int_ene=int_ene[0]-int_ene[1]-int_ene[2]+int_ene[3]
                else:
                    print 'Could not find interaction energy'
                    print 'oldres',oldres
                    print 'target',target_residue
                    int_ene=0.0
                    print 'This should not happen'
                    raise pKD_error('Something is wrong')
            elif self.data[mutation].has_key(target_residue):
                int_ene=self.data[mutation][target_residue]
            else:
                print 'Could not find residue: %s ' %mutation
                print 'When trying to get the interaction energy for mutation %s with target residue %s' %(str(mutation),str(target_residue))
                keys=self.data[mutation].keys()
                keys.sort()
                print keys
                raise pKD_error('Could not find interaction energy')
        else:
            print 'Could not find mutation: %s' %mutation
            keys=self.data.keys()
            keys.sort()
            print keys
            raise Exception()
        if not int_ene:
            raise pKD_error('Could not get interaction energy')
         Calculate the dpKa 
        dpKa=0.0
        import math
         The sign of the interaction energy tells us if we have
         an upward or a downward shift
        if pKarun.isacid(target_residue):
             Acid
            dpKa=int_ene/math.log(10)
        else:
             Base
            dpKa=-int_ene/math.log(10)
         Was the wt residue (that of the mutation) a charged group?
        import string
        number=string.split(mutation,':')[1]
        new_residue=':'+number+':'+string.split(mutation,':')[-1]
        old_residue=':'+number+':'+string.split(mutation,':')[0]
        if pKarun.is_charged(old_residue):
                 Calculate effect of the mutation
                if pKa.istitratable(new_residue):
                if pKarun.is_charged(new_residue):
                    if pKarun.isacid(old_residue)==pKarun.isacid(mutation):
                        dpKa=0.0
                    else:
                         If it was the opposite sign, then we get twice the effect
                        dpKa=2.0*dpKa
                else:
                     Not titratable, - a neutral mutation
                     Opposite effect of old residue
                    if pKarun.isacid(target_residue):
                         Acid
                        dpKa=-int_ene/math.log(10)
                    else:
                         Base
                        dpKa=int_ene/math.log(10)
         ok, all done. Return dpKa
        return dpKa
def dpKa_philn10 ( self , mutation , target_residue , verbose = None ) : if not mutation : return 0.0 import pKD_tools if pKD_tools . get_resnum_from_mut ( mutation ) == pKD_tools . get_resnum_from_res ( target_residue ) : return None int_ene = None if self . data . has_key ( mutation ) : if self . data [ mutation ] . has_key ( 'neutral mutation' ) : oldres = pKD_tools . get_oldres_from_mut ( mutation ) newres = pKD_tools . get_newres_from_mut ( mutation ) if pKarun . is_titratable ( oldres ) and not pKarun . is_titratable ( newres ) : int_ene = self . matrix [ oldres ] [ target_residue ] int_ene = int_ene [ 0 ] - int_ene [ 1 ] - int_ene [ 2 ] + int_ene [ 3 ] else : print 'Could not find interaction energy' print 'oldres' , oldres print 'target' , target_residue int_ene = 0.0 print 'This should not happen' raise pKD_error ( 'Something is wrong' ) elif self . data [ mutation ] . has_key ( target_residue ) : int_ene = self . data [ mutation ] [ target_residue ] else : print 'Could not find residue: %s ' % mutation print 'When trying to get the interaction energy for mutation %s with target residue %s' % ( str ( mutation ) , str ( target_residue ) ) keys = self . data [ mutation ] . keys ( ) keys . sort ( ) print keys raise pKD_error ( 'Could not find interaction energy' ) else : print 'Could not find mutation: %s' % mutation keys = self . data . keys ( ) keys . sort ( ) print keys raise Exception ( ) if not int_ene : raise pKD_error ( 'Could not get interaction energy' ) dpKa = 0.0 import math if pKarun . isacid ( target_residue ) : dpKa = int_ene / math . log ( 10 ) else : dpKa = - int_ene / math . log ( 10 ) import string number = string . split ( mutation , ':' ) [ 1 ] new_residue = ':' + number + ':' + string . split ( mutation , ':' ) [ - 1 ] old_residue = ':' + number + ':' + string . split ( mutation , ':' ) [ 0 ] if pKarun . is_charged ( old_residue ) : if pKarun . is_charged ( new_residue ) : if pKarun . isacid ( old_residue ) == pKarun . isacid ( mutation ) : dpKa = 0.0 else : dpKa = 2.0 * dpKa else : if pKarun . isacid ( target_residue ) : dpKa = - int_ene / math . log ( 10 ) else : dpKa = int_ene / math . log ( 10 ) return dpKa
For a given mutation, calculate the change in the pKa value if the target using phi/ln(10)
For a given mutation calculate the change in the pKa value if the target using phi / ln ( 10 )
"""
        # For a given mutation, calculate the change in the pKa value if the target using phi/ln(10)
        """ # If we have no mutation, then we have no change # # # Check that target_residue and mutation is not the same residue # # # Get the interaction energy  # # # We have a neutral mutation e.g. ARG:0112:GLN # In this case we get the interaction energy from the matrix file # # # Check that we have a neutral mutation # # # Calculate the dpKa  # # # The sign of the interaction energy tells us if we have # an upward or a downward shift # # Acid # Base # # Was the wt residue (that of the mutation) a charged group? # # # Calculate effect of the mutation # #if pKa.istitratable(new_residue): # # If it was the opposite sign, then we get twice the effect # # # Not titratable, - a neutral mutation # Opposite effect of old residue # # Acid # Base # # ok, all done. Return dpKa #
self
mutation
target_residue
verbose