pKa/analyse_pKa_values.py
def do_ex_system(self):
        """
        # Calculate the effects of titratable groups "ex_system"
        """
        import os
        filename=os.path.join(self.topdir,'ex_system.DAT')
        data=None
        if os.path.isfile(filename):
            try:
                print 'Loading ex_system data'
                fd=open(filename)
                import cPickle
                data=cPickle.load(fd)
                fd.close()
                return data
            except:
                data=None
        #
        # If we don't have the data calculate it
        #
        if data is None:
            import pKaTool.pKaIO
            define_pka=pKaTool.pKaIO.pKaIO(self.pdbfile) 
            #
            # pKa calc found, let;s continue
            #
            pKa_values=define_pka.readpka()
            #
            # read the WHAT IF pKa files
            #
            desolv=define_pka.read_desolv() 
            backgr=define_pka.read_backgr()
            matrix=define_pka.read_matrix() 
            #
            # Get all groups
            #
            titgrps= matrix.keys()          
            titgrps.sort()#sorts titgroups
            #
            # Start calculating pKa values for each pair
            #
            pKa={}
            titcurv={}
            counter=0
            for group1 in titgrps:
                print 'Ex_system for group %s (%3d of %3d)' %(group1,counter,len(titgrps))
                counter=counter+1
                for group2 in titgrps:
                    #
                    # Do we need to insert an empty dictionary in pKa[group1]?
                    #
                    if not pKa.has_key(group1):
                        pKa[group1]={}
                        titcurv[group1]={}
                    #
                    # Do not calculate if group1 is equal to group2
                    #
                    if group1==group2:
                        continue
                    #
                    # Do not calculate if we already have the result
                    #
                    if pKa.has_key(group2):
                        if pKa[group2].has_key(group1):
                            pKa[group1][group2]=pKa[group2][group1]
                            titcurv[group1][group2]=titcurv[group2][group1]
                            continue
                    #
                    # Do the pKa calculation
                    #
                    import pKaTool.pKa_calc
                    define_MC=pKaTool.pKa_calc.Boltzmann()
                    define_MC.desolv={group1:desolv[group1],group2:desolv[group2]}
                    define_MC.backgr={group1:backgr[group1],group2:backgr[group2]}
                    define_MC.matrix={group1:matrix[group1],group2:matrix[group2]}
                    pKa[group1][group2]=define_MC.calc_pKas(0,0.1,-20.0,30.0)
                    titcurv[group1][group2]=define_MC.prot_states
            #
            # Save results
            #
            import pickle
            fd=open(filename,'w')
            pickle.dump(titcurv,fd)
            fd.close()
            print            
            print 'All done'
            print
        return titcurv

        # Calculate the effects of titratable groups "ex_system"
        
Calculate the effects of titratable groups "ex_system"
Calculate the effects of titratable groups " ex_system "
def do_ex_system(self):
        import os
        filename=os.path.join(self.topdir,'ex_system.DAT')
        data=None
        if os.path.isfile(filename):
            try:
                print 'Loading ex_system data'
                fd=open(filename)
                import cPickle
                data=cPickle.load(fd)
                fd.close()
                return data
            except:
                data=None
         If we don't have the data calculate it
        if data is None:
            import pKaTool.pKaIO
            define_pka=pKaTool.pKaIO.pKaIO(self.pdbfile) 
             pKa calc found, let;s continue
            pKa_values=define_pka.readpka()
             read the WHAT IF pKa files
            desolv=define_pka.read_desolv() 
            backgr=define_pka.read_backgr()
            matrix=define_pka.read_matrix() 
             Get all groups
            titgrps= matrix.keys()          
            titgrps.sort()sorts titgroups
             Start calculating pKa values for each pair
            pKa={}
            titcurv={}
            counter=0
            for group1 in titgrps:
                print 'Ex_system for group %s (%3d of %3d)' %(group1,counter,len(titgrps))
                counter=counter+1
                for group2 in titgrps:
                     Do we need to insert an empty dictionary in pKa[group1]?
                    if not pKa.has_key(group1):
                        pKa[group1]={}
                        titcurv[group1]={}
                     Do not calculate if group1 is equal to group2
                    if group1==group2:
                        continue
                     Do not calculate if we already have the result
                    if pKa.has_key(group2):
                        if pKa[group2].has_key(group1):
                            pKa[group1][group2]=pKa[group2][group1]
                            titcurv[group1][group2]=titcurv[group2][group1]
                            continue
                     Do the pKa calculation
                    import pKaTool.pKa_calc
                    define_MC=pKaTool.pKa_calc.Boltzmann()
                    define_MC.desolv={group1:desolv[group1],group2:desolv[group2]}
                    define_MC.backgr={group1:backgr[group1],group2:backgr[group2]}
                    define_MC.matrix={group1:matrix[group1],group2:matrix[group2]}
                    pKa[group1][group2]=define_MC.calc_pKas(0,0.1,-20.0,30.0)
                    titcurv[group1][group2]=define_MC.prot_states
             Save results
            import pickle
            fd=open(filename,'w')
            pickle.dump(titcurv,fd)
            fd.close()
            print            
            print 'All done'
            print
        return titcurv
def do_ex_system ( self ) : import os filename = os . path . join ( self . topdir , 'ex_system.DAT' ) data = None if os . path . isfile ( filename ) : try : print 'Loading ex_system data' fd = open ( filename ) import cPickle data = cPickle . load ( fd ) fd . close ( ) return data except : data = None if data is None : import pKaTool . pKaIO define_pka = pKaTool . pKaIO . pKaIO ( self . pdbfile ) pKa_values = define_pka . readpka ( ) desolv = define_pka . read_desolv ( ) backgr = define_pka . read_backgr ( ) matrix = define_pka . read_matrix ( ) titgrps = matrix . keys ( ) titgrps . sort ( ) pKa = { } titcurv = { } counter = 0 for group1 in titgrps : print 'Ex_system for group %s (%3d of %3d)' % ( group1 , counter , len ( titgrps ) ) counter = counter + 1 for group2 in titgrps : if not pKa . has_key ( group1 ) : pKa [ group1 ] = { } titcurv [ group1 ] = { } if group1 == group2 : continue if pKa . has_key ( group2 ) : if pKa [ group2 ] . has_key ( group1 ) : pKa [ group1 ] [ group2 ] = pKa [ group2 ] [ group1 ] titcurv [ group1 ] [ group2 ] = titcurv [ group2 ] [ group1 ] continue import pKaTool . pKa_calc define_MC = pKaTool . pKa_calc . Boltzmann ( ) define_MC . desolv = { group1 : desolv [ group1 ] , group2 : desolv [ group2 ] } define_MC . backgr = { group1 : backgr [ group1 ] , group2 : backgr [ group2 ] } define_MC . matrix = { group1 : matrix [ group1 ] , group2 : matrix [ group2 ] } pKa [ group1 ] [ group2 ] = define_MC . calc_pKas ( 0 , 0.1 , - 20.0 , 30.0 ) titcurv [ group1 ] [ group2 ] = define_MC . prot_states import pickle fd = open ( filename , 'w' ) pickle . dump ( titcurv , fd ) fd . close ( ) print print 'All done' print return titcurv
Calculate the effects of titratable groups "ex_system"
Calculate the effects of titratable groups " ex_system "
"""
        # Calculate the effects of titratable groups "ex_system"
        """ # # If we don't have the data calculate it # # # pKa calc found, let;s continue # # # read the WHAT IF pKa files # # # Get all groups # #sorts titgroups # # Start calculating pKa values for each pair # # # Do we need to insert an empty dictionary in pKa[group1]? # # # Do not calculate if group1 is equal to group2 # # # Do not calculate if we already have the result # # # Do the pKa calculation # # # Save results #
self