pKa/analyse_pKa_values.py
def calculate_insystem_dpKas(self):
        """Calculate the dpKas for all residues"""
        import pKarun.pKa_utility_functions as pKa_utility_functions
        import os
        groups=self.wt_pKas.keys()
        groups.sort()
        self.in_data={}
        count=1
        for group in groups:
            print 'Group: %s (%3d of %3d)' %(group,count,len(groups))
            count=count+1
            dirname=os.path.join(self.topdir,'in_system')
            if not os.path.isdir(dirname):
                os.mkdir(dirname)
            filename=os.path.join(dirname,group+'.DAT')
            data=None
            if os.path.isfile(filename):
                try:
                    fd=open(filename)
                    import cPickle
                    data=cPickle.load(fd)
                    fd.close()
                    self.in_data[group]=data
                    print 'Loaded in_system data for %s' %group
                except:
                    data=None
            #
            # If we don't have the data calculate it
            #
            if data is None:
                print 'Calculating in_system dpKas when removing: %s' %group
                import pKa_MC
                pKa_params={'pHstart':self.pHstart,'pHstop':self.pHend,'pHstep':self.pHstep,'pKMCsteps':self.MCsteps,'verbose':1}
                self.pKaCALC=pKa_MC.pKa_calculation_class(self.pdbfile,pKa_info=None,params=pKa_params,parent=self)
                self.pKaCALC.set_MC_CPP()
                reporter_groups=groups[:]
                reporter_groups.remove(group)
                self.pKaCALC.set_reporter_groups(reporter_groups)
                self.pKaCALC.remove_interactions_with(group)
                pkas,titcurvs=self.pKaCALC.calc_wt_pkas()
                self.in_data[group]=titcurvs
                print 'I got %d titration curves' %(len(titcurvs.keys()))
                #
                # Save the data
                #
                fd=open(filename,'w')
                import cPickle
                data=cPickle.dump(titcurvs,fd)
                fd.close()
                print 'done'
                print
            print
        #
        # Integrate differences from wild type titration curve
        #
        data={}
        rgroups=self.in_data.keys()
        rgroups.sort()
        for removed_group in rgroups:
            data[removed_group]={}
            tgroups=self.in_data[removed_group].keys()
            tgroups.sort()
            for tgroup in tgroups:
                if removed_group==tgroup:
                    continue
                pH_values=self.in_data[removed_group][tgroup].keys()
                pH_values.sort()
                pH_values.remove('pKa')
                pH_step=pH_values[1]-pH_values[0]
                diff=0.0
                for pH in pH_values:
                    diff=diff+(self.in_data[removed_group][tgroup][pH]-self.wt_titcurv[tgroup][pH])*pH_step
                if abs(diff)<0.1:
                    diff=0.0
                data[removed_group][tgroup]=diff
        return data
Calculate the dpKas for all residues
Calculate the dpKas for all residues
Calculate the dpKas for all residues
def calculate_insystem_dpKas(self):
        import pKarun.pKa_utility_functions as pKa_utility_functions
        import os
        groups=self.wt_pKas.keys()
        groups.sort()
        self.in_data={}
        count=1
        for group in groups:
            print 'Group: %s (%3d of %3d)' %(group,count,len(groups))
            count=count+1
            dirname=os.path.join(self.topdir,'in_system')
            if not os.path.isdir(dirname):
                os.mkdir(dirname)
            filename=os.path.join(dirname,group+'.DAT')
            data=None
            if os.path.isfile(filename):
                try:
                    fd=open(filename)
                    import cPickle
                    data=cPickle.load(fd)
                    fd.close()
                    self.in_data[group]=data
                    print 'Loaded in_system data for %s' %group
                except:
                    data=None
             If we don't have the data calculate it
            if data is None:
                print 'Calculating in_system dpKas when removing: %s' %group
                import pKa_MC
                pKa_params={'pHstart':self.pHstart,'pHstop':self.pHend,'pHstep':self.pHstep,'pKMCsteps':self.MCsteps,'verbose':1}
                self.pKaCALC=pKa_MC.pKa_calculation_class(self.pdbfile,pKa_info=None,params=pKa_params,parent=self)
                self.pKaCALC.set_MC_CPP()
                reporter_groups=groups[:]
                reporter_groups.remove(group)
                self.pKaCALC.set_reporter_groups(reporter_groups)
                self.pKaCALC.remove_interactions_with(group)
                pkas,titcurvs=self.pKaCALC.calc_wt_pkas()
                self.in_data[group]=titcurvs
                print 'I got %d titration curves' %(len(titcurvs.keys()))
                 Save the data
                fd=open(filename,'w')
                import cPickle
                data=cPickle.dump(titcurvs,fd)
                fd.close()
                print 'done'
                print
            print
         Integrate differences from wild type titration curve
        data={}
        rgroups=self.in_data.keys()
        rgroups.sort()
        for removed_group in rgroups:
            data[removed_group]={}
            tgroups=self.in_data[removed_group].keys()
            tgroups.sort()
            for tgroup in tgroups:
                if removed_group==tgroup:
                    continue
                pH_values=self.in_data[removed_group][tgroup].keys()
                pH_values.sort()
                pH_values.remove('pKa')
                pH_step=pH_values[1]-pH_values[0]
                diff=0.0
                for pH in pH_values:
                    diff=diff+(self.in_data[removed_group][tgroup][pH]-self.wt_titcurv[tgroup][pH])*pH_step
                if abs(diff)<0.1:
                    diff=0.0
                data[removed_group][tgroup]=diff
        return data
def calculate_insystem_dpKas ( self ) : import pKarun . pKa_utility_functions as pKa_utility_functions import os groups = self . wt_pKas . keys ( ) groups . sort ( ) self . in_data = { } count = 1 for group in groups : print 'Group: %s (%3d of %3d)' % ( group , count , len ( groups ) ) count = count + 1 dirname = os . path . join ( self . topdir , 'in_system' ) if not os . path . isdir ( dirname ) : os . mkdir ( dirname ) filename = os . path . join ( dirname , group + '.DAT' ) data = None if os . path . isfile ( filename ) : try : fd = open ( filename ) import cPickle data = cPickle . load ( fd ) fd . close ( ) self . in_data [ group ] = data print 'Loaded in_system data for %s' % group except : data = None if data is None : print 'Calculating in_system dpKas when removing: %s' % group import pKa_MC pKa_params = { 'pHstart' : self . pHstart , 'pHstop' : self . pHend , 'pHstep' : self . pHstep , 'pKMCsteps' : self . MCsteps , 'verbose' : 1 } self . pKaCALC = pKa_MC . pKa_calculation_class ( self . pdbfile , pKa_info = None , params = pKa_params , parent = self ) self . pKaCALC . set_MC_CPP ( ) reporter_groups = groups [ : ] reporter_groups . remove ( group ) self . pKaCALC . set_reporter_groups ( reporter_groups ) self . pKaCALC . remove_interactions_with ( group ) pkas , titcurvs = self . pKaCALC . calc_wt_pkas ( ) self . in_data [ group ] = titcurvs print 'I got %d titration curves' % ( len ( titcurvs . keys ( ) ) ) fd = open ( filename , 'w' ) import cPickle data = cPickle . dump ( titcurvs , fd ) fd . close ( ) print 'done' print print data = { } rgroups = self . in_data . keys ( ) rgroups . sort ( ) for removed_group in rgroups : data [ removed_group ] = { } tgroups = self . in_data [ removed_group ] . keys ( ) tgroups . sort ( ) for tgroup in tgroups : if removed_group == tgroup : continue pH_values = self . in_data [ removed_group ] [ tgroup ] . keys ( ) pH_values . sort ( ) pH_values . remove ( 'pKa' ) pH_step = pH_values [ 1 ] - pH_values [ 0 ] diff = 0.0 for pH in pH_values : diff = diff + ( self . in_data [ removed_group ] [ tgroup ] [ pH ] - self . wt_titcurv [ tgroup ] [ pH ] ) * pH_step if abs ( diff ) < 0.1 : diff = 0.0 data [ removed_group ] [ tgroup ] = diff return data
Calculate the dpKas for all residues
Calculate the dpKas for all residues
"""Calculate the dpKas for all residues""" # # If we don't have the data calculate it # # # Save the data # # # Integrate differences from wild type titration curve #
self