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"""
        #
        # Do specific CPP_Mult setup
        #
        import time
        starttime=time.time()
        #
        # Get the number of groups
        #
        residues=self.intrinsic_pKa.keys()
        residues.sort()
        #
        # num_states holds the number of states for each group
        # charged_state identified whether a state is charged or neutral
        #
        intpkas=[]
        acidbase=[]
        num_states=[]
        linear_charged_state=[]
        for residue in residues:
            num_states.append(len(self.intrinsic_pKa[residue]))
            #this_state=[]
            state_count=0
            for state in self.intrinsic_pKa[residue]:
                intpkas.append(float(state))
                acidbase.append(int(self.acid_base[residue]))
                linear_charged_state.append(self.charged_state[residue][state_count])
                state_count=state_count+1
        #
        # Linearise the matrix
        #
        linear_matrix=self.make_matrix_linear()
        #
        # Import the C++ module and run pKa calc from there
        #
        import time, math
        import pMC_mult
        FAST=pMC_mult.MC(intpkas,linear_matrix,acidbase,num_states,linear_charged_state)
        loadtime=time.time()
        #print 'CPP calculations starting at',time.strftime('%d/%m-%Y %H:%M',time.localtime(loadtime))
        FAST.set_MCsteps(int(mcsteps))
        #print 'phstart: %f, phend: %f, phstep: %f' %(phstart,phend,phstep)
        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
        #print 'CPP calculations took %.4f minutes' %tid
        #print 'setup time %.4f minutes' %loadtid
        #import sys
        #sys.stdout.flush()
        return pkavalues
Do the pKa calculation with the CPP module
Do the pKa calculation with the CPP module
Do the pKa calculation with the CPP module
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_Mult setup
        import time
        starttime=time.time()
         Get the number of groups
        residues=self.intrinsic_pKa.keys()
        residues.sort()
         num_states holds the number of states for each group
         charged_state identified whether a state is charged or neutral
        intpkas=[]
        acidbase=[]
        num_states=[]
        linear_charged_state=[]
        for residue in residues:
            num_states.append(len(self.intrinsic_pKa[residue]))
            this_state=[]
            state_count=0
            for state in self.intrinsic_pKa[residue]:
                intpkas.append(float(state))
                acidbase.append(int(self.acid_base[residue]))
                linear_charged_state.append(self.charged_state[residue][state_count])
                state_count=state_count+1
         Linearise the matrix
        linear_matrix=self.make_matrix_linear()
         Import the C++ module and run pKa calc from there
        import time, math
        import pMC_mult
        FAST=pMC_mult.MC(intpkas,linear_matrix,acidbase,num_states,linear_charged_state)
        loadtime=time.time()
        print 'CPP calculations starting at',time.strftime('%d/%m-%Y %H:%M',time.localtime(loadtime))
        FAST.set_MCsteps(int(mcsteps))
        print 'phstart: %f, phend: %f, phstep: %f' %(phstart,phend,phstep)
        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
        print 'CPP calculations took %.4f minutes' %tid
        print 'setup time %.4f minutes' %loadtid
        import sys
        sys.stdout.flush()
        return pkavalues
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 = [ ] num_states = [ ] linear_charged_state = [ ] for residue in residues : num_states . append ( len ( self . intrinsic_pKa [ residue ] ) ) state_count = 0 for state in self . intrinsic_pKa [ residue ] : intpkas . append ( float ( state ) ) acidbase . append ( int ( self . acid_base [ residue ] ) ) linear_charged_state . append ( self . charged_state [ residue ] [ state_count ] ) state_count = state_count + 1 linear_matrix = self . make_matrix_linear ( ) import time , math import pMC_mult FAST = pMC_mult . MC ( intpkas , linear_matrix , acidbase , num_states , linear_charged_state ) 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
Do the pKa calculation with the CPP module
Do the pKa calculation with the CPP module
"""Do the pKa calculation with the CPP module""" # # Do specific CPP_Mult setup # # # Get the number of groups # # # num_states holds the number of states for each group # charged_state identified whether a state is charged or neutral # #this_state=[] # # Linearise the matrix # # # Import the C++ module and run pKa calc from there # #print 'CPP calculations starting at',time.strftime('%d/%m-%Y %H:%M',time.localtime(loadtime)) #print 'phstart: %f, phend: %f, phstep: %f' %(phstart,phend,phstep) # # 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 # #print 'CPP calculations took %.4f minutes' %tid #print 'setup time %.4f minutes' %loadtid #import sys #sys.stdout.flush()
self
mcsteps
phstep
phstart
phend
verbose
complete_pka
exp_pHs