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=[],
        monitor_groups=None,monitor_states=None):
        """Do the pKa calculation with the CPP module"""
        #
        # 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=1
        FAST=pMC.MC(intpkas,linear_matrix,acidbase,use_MC)
        loadtime=time.time()
        FAST.set_MCsteps(int(mcsteps))
        #
        # If we monitor a CCPS then define it
        #
        if monitor_states:
            FAST.set_monitor_states(monitor_states)
        #
        #
        # Calculate pKa values
        #
        pKa_values=FAST.calc_pKas(phstart,phend,phstep)
        #
        # Get the CCPS population back
        #
        if monitor_states:
            self.pH=[]
            self.CCPS_pop=[]
            CCPS_pop=FAST._CCPS_population
            for count in range(0,len(CCPS_pop),2):
                #print CCPS_pop[count],CCPS_pop[count+1]
                self.pH.append(CCPS_pop[count])
                self.CCPS_pop.append(CCPS_pop[count+1])
        #
        # 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
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=[],
        monitor_groups=None,monitor_states=None):
         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=1
        FAST=pMC.MC(intpkas,linear_matrix,acidbase,use_MC)
        loadtime=time.time()
        FAST.set_MCsteps(int(mcsteps))
         If we monitor a CCPS then define it
        if monitor_states:
            FAST.set_monitor_states(monitor_states)
         Calculate pKa values
        pKa_values=FAST.calc_pKas(phstart,phend,phstep)
         Get the CCPS population back
        if monitor_states:
            self.pH=[]
            self.CCPS_pop=[]
            CCPS_pop=FAST._CCPS_population
            for count in range(0,len(CCPS_pop),2):
                print CCPS_pop[count],CCPS_pop[count+1]
                self.pH.append(CCPS_pop[count])
                self.CCPS_pop.append(CCPS_pop[count+1])
         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 = [ ] , monitor_groups = None , monitor_states = None ) : 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 = 1 FAST = pMC . MC ( intpkas , linear_matrix , acidbase , use_MC ) loadtime = time . time ( ) FAST . set_MCsteps ( int ( mcsteps ) ) if monitor_states : FAST . set_monitor_states ( monitor_states ) pKa_values = FAST . calc_pKas ( phstart , phend , phstep ) if monitor_states : self . pH = [ ] self . CCPS_pop = [ ] CCPS_pop = FAST . _CCPS_population for count in range ( 0 , len ( CCPS_pop ) , 2 ) : self . pH . append ( CCPS_pop [ count ] ) self . CCPS_pop . append ( CCPS_pop [ count + 1 ] ) 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
Do the pKa calculation with the CPP module
"""Do the pKa calculation with the CPP module""" # # 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 # # # If we monitor a CCPS then define it # # # # Calculate pKa values # # # Get the CCPS population back # #print CCPS_pop[count],CCPS_pop[count+1] # # 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
monitor_groups
monitor_states