pKaTool/pKa_calc.py
def _calc_pKas(self,mcsteps=200000,phstep=0.1,phstart=1.0,phend=20.0,verbose=1,complete_pka=None,exp_pHs=[]):
        """Do the pKa calculation with the CPP module for Boltzmann stats"""
        #
        # Do specific CPP setup
        #
        import time
        starttime=time.time()
        residues=self.intrinsic_pKa.keys()
        residues.sort()
        intpkas=[]
        acidbase=[]
        for residue in residues:
            intpkas.append(self.intrinsic_pKa[residue])
            acidbase.append(float(self.acid_base(residue)))
            #print residue,self.intrinsic_pKa[residue],self.acid_base(residue)
            # Works ok with mutations since self.acid_base works on the last residue
        linear_matrix=self.make_matrix_linear()
        #raw_input('ok?')
        #
        # Import the C++ module and run pKa calc from there
        #
        import time, math
        import pMC
        reload(pMC)
        use_MC=0 # This is Boltzmann
        FAST=pMC.MC(intpkas,linear_matrix,acidbase,use_MC)
        loadtime=time.time()
        FAST.set_MCsteps(int(mcsteps))
        pKa_values=FAST.calc_pKas(phstart,phend,phstep)
        #
        # Put the pKa values back in a dictionary
        #
        pkavalues={}
        count=0
        for residue in residues:
            pkavalues[residue]=pKa_values[count]
            if pKa_values[count]<-100.0:
                pkavalues[residue]=-9999.9
            count=count+1
        #
        # Now get the titration curves
        #
        # pMC returns a specification of how many values it returns
        #
        pH_start=pKa_values[count]
        pH_step=pKa_values[count+1]
        pH_num=pKa_values[count+2]
        count=count+3
        #
        #
        #
        self.pHvalues=[]
        self.prot_states={}
        for residue in residues:
            self.prot_states[residue]={}
            while 1:
                pH=float(pKa_values[count])
                count=count+1
                charge=float(pKa_values[count])
                count=count+1
                #
                # If we find the terminator value
                #
                if pKa_values[count]==999.0:
                    if pKa_values[count+1]==-999.0:
                        count=count+2
                        break
                self.prot_states[residue][pH]=charge
            #
            #
            if self.pHvalues==[]:
                self.pHvalues=self.prot_states[residue].keys()
                self.pHvalues.sort()
            #
            # prot_states also contain the pKa value
            #
            self.prot_states[residue]['pKa']=pkavalues[residue]
          
        #
        # Construct the proper pKa array
        #
        self.pka={}
        for group in pkavalues.keys():
            self.pka[group]={'pKa':pkavalues[group]}
        if complete_pka:
            self.complete_pka()
        #
        # Construct the pHvalues array
        #
        
        #
        # All done
        #
        loadtid=(loadtime-starttime)/60.0
        tid=time.time()-starttime
        tid=tid/60.0
        return pkavalues,self.prot_states
Do the pKa calculation with the CPP module for Boltzmann stats
Do the pKa calculation with the CPP module for Boltzmann stats
Do the pKa calculation with the CPP module for Boltzmann stats
def _calc_pKas(self,mcsteps=200000,phstep=0.1,phstart=1.0,phend=20.0,verbose=1,complete_pka=None,exp_pHs=[]):
         Do specific CPP setup
        import time
        starttime=time.time()
        residues=self.intrinsic_pKa.keys()
        residues.sort()
        intpkas=[]
        acidbase=[]
        for residue in residues:
            intpkas.append(self.intrinsic_pKa[residue])
            acidbase.append(float(self.acid_base(residue)))
            print residue,self.intrinsic_pKa[residue],self.acid_base(residue)
             Works ok with mutations since self.acid_base works on the last residue
        linear_matrix=self.make_matrix_linear()
        raw_input('ok?')
         Import the C++ module and run pKa calc from there
        import time, math
        import pMC
        reload(pMC)
        use_MC=0  This is Boltzmann
        FAST=pMC.MC(intpkas,linear_matrix,acidbase,use_MC)
        loadtime=time.time()
        FAST.set_MCsteps(int(mcsteps))
        pKa_values=FAST.calc_pKas(phstart,phend,phstep)
         Put the pKa values back in a dictionary
        pkavalues={}
        count=0
        for residue in residues:
            pkavalues[residue]=pKa_values[count]
            if pKa_values[count]<-100.0:
                pkavalues[residue]=-9999.9
            count=count+1
         Now get the titration curves
         pMC returns a specification of how many values it returns
        pH_start=pKa_values[count]
        pH_step=pKa_values[count+1]
        pH_num=pKa_values[count+2]
        count=count+3
        self.pHvalues=[]
        self.prot_states={}
        for residue in residues:
            self.prot_states[residue]={}
            while 1:
                pH=float(pKa_values[count])
                count=count+1
                charge=float(pKa_values[count])
                count=count+1
                 If we find the terminator value
                if pKa_values[count]==999.0:
                    if pKa_values[count+1]==-999.0:
                        count=count+2
                        break
                self.prot_states[residue][pH]=charge
            if self.pHvalues==[]:
                self.pHvalues=self.prot_states[residue].keys()
                self.pHvalues.sort()
             prot_states also contain the pKa value
            self.prot_states[residue]['pKa']=pkavalues[residue]
         Construct the proper pKa array
        self.pka={}
        for group in pkavalues.keys():
            self.pka[group]={'pKa':pkavalues[group]}
        if complete_pka:
            self.complete_pka()
         Construct the pHvalues array
         All done
        loadtid=(loadtime-starttime)/60.0
        tid=time.time()-starttime
        tid=tid/60.0
        return pkavalues,self.prot_states
def _calc_pKas ( self , mcsteps = 200000 , phstep = 0.1 , phstart = 1.0 , phend = 20.0 , verbose = 1 , complete_pka = None , exp_pHs = [ ] ) : import time starttime = time . time ( ) residues = self . intrinsic_pKa . keys ( ) residues . sort ( ) intpkas = [ ] acidbase = [ ] for residue in residues : intpkas . append ( self . intrinsic_pKa [ residue ] ) acidbase . append ( float ( self . acid_base ( residue ) ) ) linear_matrix = self . make_matrix_linear ( ) import time , math import pMC reload ( pMC ) use_MC = 0 FAST = pMC . MC ( intpkas , linear_matrix , acidbase , use_MC ) loadtime = time . time ( ) FAST . set_MCsteps ( int ( mcsteps ) ) pKa_values = FAST . calc_pKas ( phstart , phend , phstep ) pkavalues = { } count = 0 for residue in residues : pkavalues [ residue ] = pKa_values [ count ] if pKa_values [ count ] < - 100.0 : pkavalues [ residue ] = - 9999.9 count = count + 1 pH_start = pKa_values [ count ] pH_step = pKa_values [ count + 1 ] pH_num = pKa_values [ count + 2 ] count = count + 3 self . pHvalues = [ ] self . prot_states = { } for residue in residues : self . prot_states [ residue ] = { } while 1 : pH = float ( pKa_values [ count ] ) count = count + 1 charge = float ( pKa_values [ count ] ) count = count + 1 if pKa_values [ count ] == 999.0 : if pKa_values [ count + 1 ] == - 999.0 : count = count + 2 break self . prot_states [ residue ] [ pH ] = charge if self . pHvalues == [ ] : self . pHvalues = self . prot_states [ residue ] . keys ( ) self . pHvalues . sort ( ) self . prot_states [ residue ] [ 'pKa' ] = pkavalues [ residue ] self . pka = { } for group in pkavalues . keys ( ) : self . pka [ group ] = { 'pKa' : pkavalues [ group ] } if complete_pka : self . complete_pka ( ) loadtid = ( loadtime - starttime ) / 60.0 tid = time . time ( ) - starttime tid = tid / 60.0 return pkavalues , self . prot_states
Do the pKa calculation with the CPP module for Boltzmann stats
Do the pKa calculation with the CPP module for Boltzmann stats
"""Do the pKa calculation with the CPP module for Boltzmann stats""" # # Do specific CPP setup # #print residue,self.intrinsic_pKa[residue],self.acid_base(residue) # Works ok with mutations since self.acid_base works on the last residue #raw_input('ok?') # # Import the C++ module and run pKa calc from there # # This is Boltzmann # # Put the pKa values back in a dictionary # # # Now get the titration curves # # pMC returns a specification of how many values it returns # # # # # # If we find the terminator value # # # # # prot_states also contain the pKa value # # # Construct the proper pKa array # # # Construct the pHvalues array # # # All done #
self
mcsteps
phstep
phstart
phend
verbose
complete_pka
exp_pHs