Пример #1
0
def set_parameters(pdbfile=None,
                   design_statement=None,
                   min_dist=None,
                   num_muts=None):
    #
    # Set the parameters that are the same for all permutations
    #
    defaults = Design_pKa.get_defaults()
    #
    # PDB file
    #
    defaults['pdb'][0] = pdbfile
    #
    # pKa calculation parameters
    #
    defaults['pHstart'][0] = 0.1
    defaults['pHstop'][0] = 12.0
    defaults['pHstep'][0] = 0.05
    defaults['pKMCsteps'][0] = 200000
    #
    # Design settings
    #
    # Target
    #
    defaults['pKas'][0] = design_statement
    #
    # Method
    #
    defaults['MC'][0] = 1
    defaults['tabulated'][0] = 1
    defaults['MCsteps'][0] = 0
    defaults['TR'][0] = None
    defaults['MC'][0] = 1
    #
    # Be not-so-noisy
    #
    defaults['silent'][0] = 2
    #
    # Minimum distance between target and mutation
    #
    defaults['min_target_dist'][0] = min_dist
    #
    # Max number of mutations
    #
    defaults['max_mutations'][0] = int(num_muts)
    #
    # Do not save the solutions
    #
    defaults['save_solutions'][0] = None
    return defaults
Пример #2
0
def set_parameters(pdbfile=None,design_statement=None,min_dist=None,num_muts=None):
    #
    # Set the parameters that are the same for all permutations
    #
    defaults=Design_pKa.get_defaults()
    #
    # PDB file
    #
    defaults['pdb'][0]=pdbfile
    #
    # pKa calculation parameters
    #
    defaults['pHstart'][0]=0.1
    defaults['pHstop'][0]=12.0
    defaults['pHstep'][0]=0.05
    defaults['pKMCsteps'][0]=200000
    #
    # Design settings
    #
    # Target
    #
    defaults['pKas'][0]=design_statement
    #
    # Method
    #
    defaults['MC'][0]=1
    defaults['tabulated'][0]=1
    defaults['MCsteps'][0]=0
    defaults['TR'][0]=None
    defaults['MC'][0]=1
    #
    # Be not-so-noisy
    #
    defaults['silent'][0]=2
    #
    # Minimum distance between target and mutation
    #
    defaults['min_target_dist'][0]=min_dist
    #
    # Max number of mutations
    #
    defaults['max_mutations'][0]=int(num_muts)
    #
    # Do not save the solutions
    #
    defaults['save_solutions'][0]=None
    return defaults
Пример #3
0
def local_defaults(pdbfile,
                   target_residue,
                   target_dpKa,
                   min_dist,
                   pKMCsteps=None):
    #
    # Set the parameters that are the same for all permutations
    #
    defaults = Design_pKa.get_defaults()
    # PDB file
    defaults['pdb'][0] = pdbfile
    #
    # pKa calculation parameters
    #
    defaults['pHstart'][0] = 0.1
    defaults['pHstop'][0] = 12.0
    defaults['pHstep'][0] = 0.05
    defaults['pKMCsteps'][0] = 200000
    if pKMCsteps:
        defaults['pKMCsteps'][0] = pKMCsteps
    #
    # Design settings
    #
    # Target
    #
    target = target_residue + '=' + target_dpKa
    defaults['pKas'][0] = target
    #
    # Method
    #
    defaults['MC'][0] = 1
    defaults['tabulated'][0] = 1
    defaults['MCsteps'][0] = 0
    #
    # Be not-so-noisy
    #
    defaults['silent'][0] = 2
    #
    # Minimum distance between target and mutation
    #
    defaults['min_target_dist'][0] = min_dist
    #
    # Do not save the solutions
    #
    defaults['save_solutions'][0] = None
    return defaults
Пример #4
0
def local_defaults(pdbfile,target_residue,target_dpKa,min_dist,pKMCsteps=None):
    #
    # Set the parameters that are the same for all permutations
    #
    defaults=Design_pKa.get_defaults()
    # PDB file
    defaults['pdb'][0]=pdbfile
    #
    # pKa calculation parameters
    #
    defaults['pHstart'][0]=0.1
    defaults['pHstop'][0]=12.0
    defaults['pHstep'][0]=0.05
    defaults['pKMCsteps'][0]=200000
    if pKMCsteps:
        defaults['pKMCsteps'][0]=pKMCsteps
    #
    # Design settings
    #
    # Target
    #
    target=target_residue+'='+target_dpKa
    defaults['pKas'][0]=target
    #
    # Method
    #
    defaults['MC'][0]=1
    defaults['tabulated'][0]=1
    defaults['MCsteps'][0]=0
    #
    # Be not-so-noisy
    #
    defaults['silent'][0]=2
    #
    # Minimum distance between target and mutation
    #
    defaults['min_target_dist'][0]=min_dist
    #
    # Do not save the solutions
    #
    defaults['save_solutions'][0]=None
    return defaults
Пример #5
0
def get_this_defaults(pdbfile,target_residue,target_dpKa):
    #
    # Set the parameters that are the same for all permutations
    #
    import Design_pKa

    defaults=Design_pKa.get_defaults()
    # PDB file
    defaults['pdb'][0]=pdbfile
    #
    # pKa calculation parameters
    #
    defaults['pHstart'][0]=0.0
    defaults['pHstop'][0]=14.0
    defaults['pHstep'][0]=0.05
    defaults['MCsteps'][0]=1
    defaults['pKMCsteps'][0]=50000
    #
    # Design settings
    #
    # Target
    #
    target=target_residue+'='+target_dpKa
    defaults['pKas'][0]=target
    #
    # Be not-so-noisy
    #

    defaults['silent'][0]=1

    #
    # Minimum distance between target and mutation
    #
    defaults['min_target_dist'][0]=5.0
    defaults['max_mutations'][0]=20.0
    return defaults
Пример #6
0
def get_this_defaults(pdbfile, target_residue, target_dpKa):
    #
    # Set the parameters that are the same for all permutations
    #
    import Design_pKa

    defaults = Design_pKa.get_defaults()
    # PDB file
    defaults['pdb'][0] = pdbfile
    #
    # pKa calculation parameters
    #
    defaults['pHstart'][0] = 0.0
    defaults['pHstop'][0] = 14.0
    defaults['pHstep'][0] = 0.05
    defaults['MCsteps'][0] = 1
    defaults['pKMCsteps'][0] = 50000
    #
    # Design settings
    #
    # Target
    #
    target = target_residue + '=' + target_dpKa
    defaults['pKas'][0] = target
    #
    # Be not-so-noisy
    #

    defaults['silent'][0] = 1

    #
    # Minimum distance between target and mutation
    #
    defaults['min_target_dist'][0] = 5.0
    defaults['max_mutations'][0] = 20.0
    return defaults
Пример #7
0
def get_solutions(pdbfile,target_residue,target_dpKa,dpKas):
    #
    # Main routine.
    # Get the solutions with MC_tab and then rescore them with a subset of
    # the different methods
    #
    # Get solutions
    #
    import Design_pKa
    defaults=Design_pKa.get_defaults()
    defaults=get_this_defaults(pdbfile,target_residue,target_dpKa)
    # Method
    defaults['MC'][0]=1
    defaults['tabulated'][0]=1
    #
    # Check if we already did this..
    #
    missing=None
    for x in range(1,11):
        if not dpKas.has_key(x):
            missing=1
            print 'Design solutions not calculated'
            break
    #
    # Do it?
    #
    if missing:
        solutions=Design_pKa.run_opt(defaults)
        solution_keys=solutions.keys()
    else:
        solution_keys=dpKas.keys()
    solution_keys.sort()
    #
    # Calculate pKa values using the other methods
    #
    # Define all the other methods that we will use
    #
    # First element is method, second is value of 'tabulated'
    #
    methods=[['TR',None],[None,None],['MC',None],['TR',1],['MC',1]]
    for solution in solution_keys[:10]:
        #
        # Make sure the dictionary is ready
        #
        if not dpKas.has_key(solution):
            dpKas[solution]={}
            dpKas[solution]['mutations']=solutions[solution]['mutations']
            realmut=None
            for mutation in solutions[solution]['mutations']:
                if mutation:
                    realmut=1
            if not realmut:
                continue
        #
        # Now calc dpKas with different methods
        #
        for method,tabulated in methods:
            #
            # Print info
            #
            print
            print 'Calculating dpKa for %s with %s. Tabulated: %s' %(str(dpKas[solution]['mutations']),method,tabulated)
            #
            # Get defaults
            #
            defaults=get_this_defaults(pdbfile,target_residue,target_dpKa)
            if method:
                # Choose method
                defaults[method][0]=1
            #
            # Set tabulated
            #
            defaults['tabulated'][0]=tabulated
            #
            # Set the general parameters
            #
            mutations=dpKas[solution]['mutations']
            import string
            #
            # Remove all None elements from mutations
            #
            filtered_muts=[]
            for mut in mutations:
                if mut:
                    filtered_muts.append(mut)
            #
            # Set the mutations variable in defaults
            #
            defaults['mutations'][0]=string.join(filtered_muts,',')
            # Calculate delta pkas
            defaults['calc_dpka'][0]=1
            #
            # Set a more meaningful method name
            #
            method_name=method
            if not method:
                method_name='phi/ln10'
            #
            # Is this tabulated mode?
            #
            if tabulated:
                method_name=method_name+'_tab'
            #
            # Get the dpKa(s)
            #
            if not dpKas[solution].has_key(method_name):
                tmp=Design_pKa.run_opt(defaults)
                #
                # We should have only one key
                #
                keys=tmp.keys()
                if len(keys)!=1:
                    print keys
                    raise 'Too many keys when calculating dpkas for one solution'
                dpKas[solution][method_name]=tmp[keys[0]]
            
    #
    # Done
    #
    return dpKas
Пример #8
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
Пример #9
0
def get_solutions(pdbfile, target_residue, target_dpKa, dpKas):
    #
    # Main routine.
    # Get the solutions with MC_tab and then rescore them with a subset of
    # the different methods
    #
    # Get solutions
    #
    import Design_pKa
    defaults = Design_pKa.get_defaults()
    defaults = get_this_defaults(pdbfile, target_residue, target_dpKa)
    # Method
    defaults['MC'][0] = 1
    defaults['tabulated'][0] = 1
    #
    # Check if we already did this..
    #
    missing = None
    for x in range(1, 11):
        if not dpKas.has_key(x):
            missing = 1
            print 'Design solutions not calculated'
            break
    #
    # Do it?
    #
    if missing:
        solutions = Design_pKa.run_opt(defaults)
        solution_keys = solutions.keys()
    else:
        solution_keys = dpKas.keys()
    solution_keys.sort()
    #
    # Calculate pKa values using the other methods
    #
    # Define all the other methods that we will use
    #
    # First element is method, second is value of 'tabulated'
    #
    methods = [['TR', None], [None, None], ['MC', None], ['TR', 1], ['MC', 1]]
    for solution in solution_keys[:10]:
        #
        # Make sure the dictionary is ready
        #
        if not dpKas.has_key(solution):
            dpKas[solution] = {}
            dpKas[solution]['mutations'] = solutions[solution]['mutations']
            realmut = None
            for mutation in solutions[solution]['mutations']:
                if mutation:
                    realmut = 1
            if not realmut:
                continue
        #
        # Now calc dpKas with different methods
        #
        for method, tabulated in methods:
            #
            # Print info
            #
            print
            print 'Calculating dpKa for %s with %s. Tabulated: %s' % (str(
                dpKas[solution]['mutations']), method, tabulated)
            #
            # Get defaults
            #
            defaults = get_this_defaults(pdbfile, target_residue, target_dpKa)
            if method:
                # Choose method
                defaults[method][0] = 1
            #
            # Set tabulated
            #
            defaults['tabulated'][0] = tabulated
            #
            # Set the general parameters
            #
            mutations = dpKas[solution]['mutations']
            import string
            #
            # Remove all None elements from mutations
            #
            filtered_muts = []
            for mut in mutations:
                if mut:
                    filtered_muts.append(mut)
            #
            # Set the mutations variable in defaults
            #
            defaults['mutations'][0] = string.join(filtered_muts, ',')
            # Calculate delta pkas
            defaults['calc_dpka'][0] = 1
            #
            # Set a more meaningful method name
            #
            method_name = method
            if not method:
                method_name = 'phi/ln10'
            #
            # Is this tabulated mode?
            #
            if tabulated:
                method_name = method_name + '_tab'
            #
            # Get the dpKa(s)
            #
            if not dpKas[solution].has_key(method_name):
                tmp = Design_pKa.run_opt(defaults)
                #
                # We should have only one key
                #
                keys = tmp.keys()
                if len(keys) != 1:
                    print keys
                    raise 'Too many keys when calculating dpkas for one solution'
                dpKas[solution][method_name] = tmp[keys[0]]

    #
    # Done
    #
    return dpKas
Пример #10
0
def run_sugelm(pdbfile):
    """Run the SugELM command"""
    #
    # Get the name of the PDB file
    #
    import os
    pdb_name = os.path.split(pdbfile)[1]
    pdb_dir = os.path.split(pdbfile)[0]
    topdir = os.getcwd()
    #
    # Check if pKa values were calculated for this file
    #
    import pKaTool.pKaIO
    X = pKaTool.pKaIO.pKaIO(pdbfile)
    if not X.calculation_completed:
        print 'pKa calculation not completed for %s' % pdbfile
        return None
    #
    # Read the pKa values
    #
    pkas = X.readpka()
    target = pkas.keys()[2]
    #
    # Create the SUGELM file
    #
    import Design_pKa
    tparams = Design_pKa.get_defaults()
    params = {}
    for key in tparams.keys():
        params[key] = tparams[key][0]
    #
    # Set the other parameters
    #
    params['pHstart'] = 0.1
    params['pHstop'] = 12.0
    params['pHstep'] = 0.05
    params['pKMCsteps'] = 200000,
    params['pKas'] = target + '=+1.0'
    params['MC'] = 0
    params['TR'] = 0
    params['min_target_dist'] = 1.0
    params['save_solutions'] = None
    params['silent'] = 0
    params['pdb'] = pdbfile
    params['generate_mutations'] = True
    #
    # Log message
    #
    import sys
    print 'Starting pKD mutation preparation'
    sys.stdout.flush()
    try:
        X = Design_pKa.Design_pKa(params)
        X.get_interaction_energies()
        print 'Calculated interaction energies'
    except:
        send_email('*****@*****.**', 'SUGELM failed for ' + pdbfile)
        return None
    #
    # Write a flag file to alert the scheduler
    #
    fd = open(os.path.join(pdb_dir, 'ready'), 'w')
    fd.write('SUGELM is done\n')
    fd.close()
    return 1
Пример #11
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
Пример #12
0
def run_sugelm(pdbfile):
    """Run the SugELM command"""
    #
    # Get the name of the PDB file
    #
    import os
    pdb_name=os.path.split(pdbfile)[1]
    pdb_dir=os.path.split(pdbfile)[0]
    topdir=os.getcwd()
    #
    # Check if pKa values were calculated for this file
    #
    import pKaTool.pKaIO
    X=pKaTool.pKaIO.pKaIO(pdbfile)
    if not X.calculation_completed:
        print 'pKa calculation not completed for %s' %pdbfile
        return None
    #
    # Read the pKa values
    #
    pkas=X.readpka()
    target=pkas.keys()[2]
    #
    # Create the SUGELM file
    #
    import Design_pKa
    tparams=Design_pKa.get_defaults()
    params={}
    for key in tparams.keys():
        params[key]=tparams[key][0]
    #
    # Set the other parameters
    #
    params['pHstart']=0.1
    params['pHstop']=12.0
    params['pHstep']=0.05
    params['pKMCsteps']=200000,
    params['pKas']=target+'=+1.0'
    params['MC']=0
    params['TR']=0
    params['min_target_dist']=1.0
    params['save_solutions']=None
    params['silent']=0
    params['pdb']=pdbfile
    params['generate_mutations']=True
    #
    # Log message
    #
    import sys
    print 'Starting pKD mutation preparation'
    sys.stdout.flush()
    try:
        X=Design_pKa.Design_pKa(params)
        X.get_interaction_energies()
        print 'Calculated interaction energies'
    except:
        send_email('*****@*****.**','SUGELM failed for '+pdbfile)
        return None
    #
    # Write a flag file to alert the scheduler
    #
    fd=open(os.path.join(pdb_dir,'ready'),'w')
    fd.write('SUGELM is done\n')
    fd.close()
    return 1