Beispiel #1
0
 def __init__(self,pdbfile,user_params={},reporter_groups=None):
     """Read the pdbfile and the wild type pKa values
     Define the reporter groups"""
     # Topdir
     import os
     self.topdir=os.getcwd()
     #
     # Set the PDB file name
     #
     self.pdbfile=os.path.join(self.topdir,pdbfile)
     import Protool
     self.PI=Protool.structureIO()
     self.PI.readpdb(self.pdbfile)
     #
     # Get the defaults from Design_pKa
     #
     import Design_pKa
     defaults=Design_pKa.get_defaults()
     self.params={}
     for key in defaults.keys():
         self.params[key]=defaults[key][0]
     self.params['pKMCsteps']=20000
     self.params['recalc_intpka']=True
     self.params['recalc_intpka_dist']=20.0
     self.params['save_temp_files']=False
     #
     # Change the values that the user specified
     #
     for u_par in user_params.keys():
         self.params[u_par]=user_params[u_par]
     #
     # Set the pKa calc parms as a subset
     #
     self.pKarun_params={}
     include=['indi','dbcrit','ion','allow_unknown_atoms','unknown_crg','unknown_rad']
     import copy
     for key in include:
         self.pKarun_params[key]=copy.copy(self.params[key])
     #
     # Set the output handler
     #
     self.O=Design_pKa.verbose(self.params['verbose'])
     #
     # Instantiate the pKa_info class and instruct it to save nothing
     #
     import Design_pKa_help
     print 'pKa_info, PDB file',self.pdbfile
     self.pKa_info=Design_pKa_help.pKa_info(pdbfile=self.pdbfile,parent=self,PBEsolver=self.params['PBEsolver'],save_file=False)
     #
     # Set the calculation routine to CPP
     #
     import pKa_MC
     self.pKaCALC=pKa_MC.pKa_calculation_class(pdbfile=self.pdbfile,pKa_info=self.pKa_info,params=self.params,parent=self)
     self.pKaCALC.set_MC_CPP()
     #
     # Re-calculate the wild type pKa values
     #
     print 'Calculating wild type pKa values'
     self.wt_pKas,self.wt_prot_states=self.pKaCALC.calc_wt_pkas()
     #
     # Set the reporter groups
     #
     if reporter_groups:
         self.reporter_groups=reporter_groups
     else:
         self.reporter_groups=self.wt_pKas.keys()
     return
Beispiel #2
0
 def __init__(self, pdbfile, user_params={}, reporter_groups=None):
     """Read the pdbfile and the wild type pKa values
     Define the reporter groups"""
     # Topdir
     import os
     self.topdir = os.getcwd()
     #
     # Set the PDB file name
     #
     self.pdbfile = os.path.join(self.topdir, pdbfile)
     import Protool
     self.PI = Protool.structureIO()
     self.PI.readpdb(self.pdbfile)
     #
     # Get the defaults from Design_pKa
     #
     import Design_pKa
     defaults = Design_pKa.get_defaults()
     self.params = {}
     for key in defaults.keys():
         self.params[key] = defaults[key][0]
     self.params['pKMCsteps'] = 20000
     self.params['recalc_intpka'] = True
     self.params['recalc_intpka_dist'] = 20.0
     self.params['save_temp_files'] = False
     #
     # Change the values that the user specified
     #
     for u_par in user_params.keys():
         self.params[u_par] = user_params[u_par]
     #
     # Set the pKa calc parms as a subset
     #
     self.pKarun_params = {}
     include = [
         'indi', 'dbcrit', 'ion', 'allow_unknown_atoms', 'unknown_crg',
         'unknown_rad'
     ]
     import copy
     for key in include:
         self.pKarun_params[key] = copy.copy(self.params[key])
     #
     # Set the output handler
     #
     self.O = Design_pKa.verbose(self.params['verbose'])
     #
     # Instantiate the pKa_info class and instruct it to save nothing
     #
     import Design_pKa_help
     print 'pKa_info, PDB file', self.pdbfile
     self.pKa_info = Design_pKa_help.pKa_info(
         pdbfile=self.pdbfile,
         parent=self,
         PBEsolver=self.params['PBEsolver'],
         save_file=False)
     #
     # Set the calculation routine to CPP
     #
     import pKa_MC
     self.pKaCALC = pKa_MC.pKa_calculation_class(pdbfile=self.pdbfile,
                                                 pKa_info=self.pKa_info,
                                                 params=self.params,
                                                 parent=self)
     self.pKaCALC.set_MC_CPP()
     #
     # Re-calculate the wild type pKa values
     #
     print 'Calculating wild type pKa values'
     self.wt_pKas, self.wt_prot_states = self.pKaCALC.calc_wt_pkas()
     #
     # Set the reporter groups
     #
     if reporter_groups:
         self.reporter_groups = reporter_groups
     else:
         self.reporter_groups = self.wt_pKas.keys()
     return
Beispiel #3
0
 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
Beispiel #4
0
 def __init__(self, params):
     #
     # Initialise
     #
     self.params = params
     import pKaTool.pKaIO as pKaIO
     self.pdbfile = self.params['pdb']
     self.MCsteps = int(self.params['MCsteps'])
     self.pHstep = float(self.params['pHstep'])
     self.pHstart = float(self.params['pHstart'])
     self.pHend = float(self.params['pHend'])
     IO = pKaIO.pKaIO(self.pdbfile)
     #
     # Define the tmpdir for all our calcs
     #
     import os
     self.topdir = os.path.split(self.pdbfile)[0]
     self.topdir = os.path.join(
         self.topdir, '%s_autonomy' % os.path.split(self.pdbfile)[1])
     if not os.path.isdir(self.topdir):
         os.mkdir(self.topdir)
     #
     # Did we find a completed pKa calculation for the PDB file
     #
     if IO.calculation_completed:
         #
         # All files found
         #
         print 'pKa calculation files found'
     else:
         print
         print 'I could not find a completed pKa calculation for the specified PDB file'
         print 'Please complete the pKa calculation first'
         print
         raise Exception()
     #
     # Get the wild type titration curves calculated with WHAT IF
     #
     import pKaTool.pKaIO
     IO = pKaTool.pKaIO.pKaIO(self.pdbfile)
     self.wt_titcurv = IO.read_titration_curve()
     self.wt_pKas = IO.readpka()
     #
     # Recalculate titration curves with the CPP algorithm
     #
     import os
     dirname = os.path.join(self.topdir, 'wt_recalc')
     if not os.path.isdir(dirname):
         os.mkdir(dirname)
     filename = os.path.join(dirname, 'WT.DAT')
     data = None
     if os.path.isfile(filename):
         try:
             fd = open(filename)
             import cPickle
             data = cPickle.load(fd)
             fd.close()
             self.wtpkas = data['pkas']
             self.wt_titcurv = data['titcurv']
             print 'Loaded wild type recalculated titration curves'
             print 'Loaded %d titration curves' % (len(
                 self.wt_titcurv.keys()))
         except:
             data = None
     #
     # If we don't have the data calculate it
     #
     if data is None:
         import pKa_MC
         print 'Recalculating wild type titration curves'
         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()
         self.pKaCALC.set_reporter_groups(self.wt_pKas.keys())
         self.wtpkas, self.wt_titcurv = self.pKaCALC.calc_wt_pkas()
         #
         # Save the data
         #
         fd = open(filename, 'w')
         import cPickle
         data = cPickle.dump(
             {
                 'pkas': self.wtpkas,
                 'titcurv': self.wt_titcurv
             }, fd)
         fd.close()
         print 'done'
         print
         print 'Calculated %d titration curves' % (len(
             self.wt_titcurv.keys()))
     #
     # Get the in_system energies
     #
     self.in_data = self.calculate_insystem_dpKas()
     #
     # Get the ex_data
     #
     self.ex_data = self.calculate_exsystem_dpKas()
     return
Beispiel #5
0
 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
Beispiel #6
0
 def __init__(self,params):
     #
     # Initialise
     #
     self.params=params
     import pKaTool.pKaIO as pKaIO
     self.pdbfile=self.params['pdb']
     self.MCsteps=int(self.params['MCsteps'])
     self.pHstep=float(self.params['pHstep'])
     self.pHstart=float(self.params['pHstart'])
     self.pHend=float(self.params['pHend'])
     IO=pKaIO.pKaIO(self.pdbfile)
     #
     # Define the tmpdir for all our calcs
     #
     import os
     self.topdir=os.path.split(self.pdbfile)[0]
     self.topdir=os.path.join(self.topdir,'%s_autonomy' %os.path.split(self.pdbfile)[1])
     if not os.path.isdir(self.topdir):
         os.mkdir(self.topdir)
     #
     # Did we find a completed pKa calculation for the PDB file
     #
     if IO.calculation_completed:
         #
         # All files found
         #
         print 'pKa calculation files found'
     else:
         print
         print 'I could not find a completed pKa calculation for the specified PDB file'
         print 'Please complete the pKa calculation first'
         print
         raise Exception()
     #
     # Get the wild type titration curves calculated with WHAT IF
     #
     import pKaTool.pKaIO
     IO=pKaTool.pKaIO.pKaIO(self.pdbfile)
     self.wt_titcurv=IO.read_titration_curve()
     self.wt_pKas=IO.readpka()
     #
     # Recalculate titration curves with the CPP algorithm
     #
     import os
     dirname=os.path.join(self.topdir,'wt_recalc')
     if not os.path.isdir(dirname):
         os.mkdir(dirname)
     filename=os.path.join(dirname,'WT.DAT')
     data=None
     if os.path.isfile(filename):
         try:
             fd=open(filename)
             import cPickle
             data=cPickle.load(fd)
             fd.close()
             self.wtpkas=data['pkas']
             self.wt_titcurv=data['titcurv']
             print 'Loaded wild type recalculated titration curves'
             print 'Loaded %d titration curves' %(len(self.wt_titcurv.keys()))
         except:
             data=None
     #
     # If we don't have the data calculate it
     #
     if data is None:
         import pKa_MC
         print 'Recalculating wild type titration curves'
         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()
         self.pKaCALC.set_reporter_groups(self.wt_pKas.keys())
         self.wtpkas,self.wt_titcurv=self.pKaCALC.calc_wt_pkas()
         #
         # Save the data
         #
         fd=open(filename,'w')
         import cPickle
         data=cPickle.dump({'pkas':self.wtpkas,'titcurv':self.wt_titcurv},fd)
         fd.close()
         print 'done'
         print
         print 'Calculated %d titration curves' %(len(self.wt_titcurv.keys()))
     #
     # Get the in_system energies
     # 
     self.in_data=self.calculate_insystem_dpKas()
     #
     # Get the ex_data
     #
     self.ex_data=self.calculate_exsystem_dpKas()
     return