def main(): # # Get the PDB file # import sys,os pdbfile=sys.argv[1] suffix=sys.argv[2] if os.environ['USER']=='nielsen': filename=os.path.join('/enzyme/nielsen/work/pKa_design/accuracy','accuracy_'+os.path.split(pdbfile)[1]) elif os.environ['USER']=='btconnolly': filename=os.path.join('/enzyme/btconnolly/pKa_design',suffix+'accuracy_'+os.path.split(pdbfile)[1]) #filename=os.path.join(os.getcwd(),'accuracy_'+os.path.split(pdbfile)[1]) print 'Setting dictionary filename to',filename # # Make sure that we delete all info from previous runs # wtpKafile=pdbfile+'_wt_pKavals' if os.path.isfile(wtpKafile): os.unlink(wtpKafile) # # Do we have a completed pKa calc for it? # import pKa X=pKa.pKaIO(pdbfile) X.usenewnames() if not X.assess_status(): import os print 'You have to run a pKa calculation first' raise Exception() # # OK, got the pKa calc. Read results # wt_pKas=X.readpka() groups=wt_pKas.keys() groups.sort() # # Design target: for all groups with pKa value between 2 and 10: +2 and -2 # DB=dictIO(filename) import os if os.path.isfile(filename): # # Load old file # accuracy=DB.load() else: # # No, no old restuls # accuracy={} # # Add the PDB file # fd=open(pdbfile) lines=fd.readlines() fd.close() accuracy['pdbfile']=lines # # Add the full wt pKa values # accuracy['wt_full']=wt_pKas DB.save(accuracy) # --------------------------------------- # # Delete old files # import Design_pKa Design_pKa.delete_old_files(pdbfile,'N','N') # # Start looping # groups.sort() for group in groups: #if not group==':0129:LEU:CTERM': # continue if not accuracy.has_key(group): accuracy[group]={} # # Is somebody working on this group? # accuracy=DB.update(accuracy) if accuracy[group].has_key('locked'): if accuracy[group]['locked']==1: continue # # Lock group # accuracy[group]['locked']=1 # # Save the dictionary # accuracy=DB.update(accuracy) # # OK, now we can calculate in peace # pKaval=wt_pKas[group]['pKa'] if pKaval>2.0 and pKaval<10.0: # # First design pKa +2.0 # design='+2.0' if not accuracy[group].has_key(design): accuracy[group][design]={} print 'Designing and evalulating: %s' %(group+design) dpKas=get_solutions(pdbfile,group,design,accuracy[group][design]) accuracy[group][design]=dpKas.copy() # # Then do pKa -2.0 # design='m2.0' if not accuracy[group].has_key(design): accuracy[group][design]={} print 'Designing and evalulating: %s' %(group+design) dpKas=get_solutions(pdbfile,group,design,accuracy[group][design]) accuracy[group][design]=dpKas.copy() else: accuracy[group]['pKa out of range']=1 # # Unlock group and merge results # accuracy[group]['locked']=None accuracy=DB.update(accuracy) # # All done # return
def main(): # # Get the PDB file # import sys, os pdbfile = sys.argv[1] suffix = sys.argv[2] if os.environ['USER'] == 'nielsen': filename = os.path.join('/enzyme/nielsen/work/pKa_design/accuracy', 'accuracy_' + os.path.split(pdbfile)[1]) elif os.environ['USER'] == 'btconnolly': filename = os.path.join( '/enzyme/btconnolly/pKa_design', suffix + 'accuracy_' + os.path.split(pdbfile)[1]) #filename=os.path.join(os.getcwd(),'accuracy_'+os.path.split(pdbfile)[1]) print 'Setting dictionary filename to', filename # # Make sure that we delete all info from previous runs # wtpKafile = pdbfile + '_wt_pKavals' if os.path.isfile(wtpKafile): os.unlink(wtpKafile) # # Do we have a completed pKa calc for it? # import pKa X = pKa.pKaIO(pdbfile) X.usenewnames() if not X.assess_status(): import os print 'You have to run a pKa calculation first' raise Exception() # # OK, got the pKa calc. Read results # wt_pKas = X.readpka() groups = wt_pKas.keys() groups.sort() # # Design target: for all groups with pKa value between 2 and 10: +2 and -2 # DB = dictIO(filename) import os if os.path.isfile(filename): # # Load old file # accuracy = DB.load() else: # # No, no old restuls # accuracy = {} # # Add the PDB file # fd = open(pdbfile) lines = fd.readlines() fd.close() accuracy['pdbfile'] = lines # # Add the full wt pKa values # accuracy['wt_full'] = wt_pKas DB.save(accuracy) # --------------------------------------- # # Delete old files # import Design_pKa Design_pKa.delete_old_files(pdbfile, 'N', 'N') # # Start looping # groups.sort() for group in groups: #if not group==':0129:LEU:CTERM': # continue if not accuracy.has_key(group): accuracy[group] = {} # # Is somebody working on this group? # accuracy = DB.update(accuracy) if accuracy[group].has_key('locked'): if accuracy[group]['locked'] == 1: continue # # Lock group # accuracy[group]['locked'] = 1 # # Save the dictionary # accuracy = DB.update(accuracy) # # OK, now we can calculate in peace # pKaval = wt_pKas[group]['pKa'] if pKaval > 2.0 and pKaval < 10.0: # # First design pKa +2.0 # design = '+2.0' if not accuracy[group].has_key(design): accuracy[group][design] = {} print 'Designing and evalulating: %s' % (group + design) dpKas = get_solutions(pdbfile, group, design, accuracy[group][design]) accuracy[group][design] = dpKas.copy() # # Then do pKa -2.0 # design = 'm2.0' if not accuracy[group].has_key(design): accuracy[group][design] = {} print 'Designing and evalulating: %s' % (group + design) dpKas = get_solutions(pdbfile, group, design, accuracy[group][design]) accuracy[group][design] = dpKas.copy() else: accuracy[group]['pKa out of range'] = 1 # # Unlock group and merge results # accuracy[group]['locked'] = None accuracy = DB.update(accuracy) # # All done # return
def main(pdbfile=None): # # Calculate the matrix of pKa shifts [number of mutations:min distance from active site] # # Get the PDB file # print print 'Construct dpKa matrix' print print 'Usage: Design_dist_nummuts <pdbfile> <database file> <method>' print # # Are we running in parallel? # import os mpi_rank = None try: import mpi mpi_rank = mpi.rank mpi_size = mpi.size print 'MPI rank', mpi_rank print 'MPI size', mpi_size if size == 1: mpi_rank = None except: # # No MPI # pass # # start the run # import sys, os if len(sys.argv) < 4: raise 'Incorrect usage' if not pdbfile: pdbfile = sys.argv[1] if len(sys.argv) > 2: dir = sys.argv[2] else: raise 'You have to provide a dir for the output' os.chdir(dir) # # Get the method # method = sys.argv[3] # # Are we doing this cheap style? # mcstep_factor = 1.00 if sys.argv[-1] == 'cheap': mcstep_factor = 0.01 # # Set the file name # filename = os.path.join( dir, 'distance_nummuts__' + os.path.split(pdbfile)[1]) + '_' + method # # Keep the cheap results separated from the real results # if sys.argv[-1] == 'cheap': filename = filename + 'cheap' # # Print the filename of the dictionary # print 'Setting dictionary filename to', filename DB = dictIO(filename) print 'I am running in %s' % os.getcwd() # # Do we have a completed pKa calc for it? # import pKaTool.pKaIO X = pKaTool.pKaIO.pKaIO(pdbfile) if not X.assess_status(): print 'You have to run a pKa calculation first' raise Exception() # # OK, got the pKa calc. Read results # wt_pKas = X.readpka() groups = wt_pKas.keys() groups.sort() # # Design target: for all groups with pKa value between 2 and 10: +2 and -2 # import os if os.path.isfile(filename): # # Load old file # results = DB.load() else: # # No, no old restuls # results = {} # # Add the PDB file # fd = open(pdbfile) lines = fd.readlines() fd.close() results['pdbfile'] = lines # # Add the full wt pKa values # results['wt_full'] = wt_pKas DB.save(results) # --------------------------------------- # # Delete old files # Design_pKa.delete_old_files(pdbfile, 'N', 'Y') # # Start looping # dist_range = range(1, 26) num_muts_range = range(1, 21) count = 0 design_low = 2.0 design_high = 10.0 # # Count the number of designable groups # design_groups = [] for group in groups: pKaval = wt_pKas[group]['pKa'] if pKaval > design_low and pKaval < design_high: design_groups.append(group) tot_count = float( len(design_groups) * 2 * len(dist_range) * len(num_muts_range)) / 100.0 # # Set the number of MC steps # # #if len(groups)<60: pKMCsteps = 200000 #else: # #print 'We have %d groups, so increasing pKMCsteps' %(len(groups)) # pKMCsteps=200000 pKMCsteps = int(mcstep_factor * float(pKMCsteps)) # # Start of loop # groups.sort() # # Are we running MPI? # if mpi_rank != None: fraction = 1.0 / float(mpi_size) print 'I will be doing %.2f %% of the job' % (100.0 * fraction) num_groups = len(groups) print 'Specifically I will be doing groups', groups[ int(fraction * mpi_rank * num_groups):int(fraction * (mpi_rank + 1) * num_groups)] print fraction * mpi_rank * num_groups, 'to', fraction * ( mpi_rank + 1) * num_groups groups = groups[int(fraction * mpi_rank * num_groups):int(fraction * (mpi_rank + 1) * num_groups)] # # Sleep to desynchronize processes # import time time.sleep(mpi_rank) print mpi_rank, 'done sleeping!' import sys sys.stdout.flush() # # Do the calculation # for group in groups: # # Loop over all groups # if not results.has_key(group): results[group] = {} # # Is somebody working on this group? # #results=DB.update(results) if results[group].has_key('locked'): if results[group]['locked'] == 1: print '%s is locked' % group continue # # Lock group # results[group]['locked'] = 1 # # Force reinitialisation of instance # X = None # # Loop over number of mutations and distance cut-off # pKaval = wt_pKas[group]['pKa'] if pKaval > design_low and pKaval < design_high: for design in ['+20.0', 'm20.0']: if not results[group].has_key(design): results[group][design] = {} for min_target_dist in dist_range: for num_muts in num_muts_range: if not results[group][design].has_key(num_muts): results[group][design][num_muts] = {} # # Print what we are doing # print 'Checking: %20s design: %s, dist: %5.1f, nummuts: %3d %%done %5.2f' % ( group, design, min_target_dist, num_muts, float(count) / tot_count) count = count + 1 # # .. # if not results[group][design][num_muts].has_key( min_target_dist): results[group][design][num_muts][ min_target_dist] = {} # # Get the solutions # dpKas, data_added, X = get_solutions_dist_nummuts( pdbfile, group, design, num_muts, min_target_dist, results[group][design] [num_muts][min_target_dist], method, pKMCsteps, X) results[group][design][num_muts][ min_target_dist] = dpKas.copy() pass results = DB.update(results) else: results[group]['pKa out of range'] = 1 # # Unlock group and merge results # del results[group]['locked'] results = DB.update(results) # # All done # print print 'All done - normal exit' print return
def main(pdbfile=None): # # Calculate the matrix of pKa shifts [number of mutations:min distance from active site] # # Get the PDB file # print print 'Construct dpKa matrix' print print 'Usage: Design_dist_nummuts <pdbfile> <database file> <method>' print # # Are we running in parallel? # import os mpi_rank=None try: import mpi mpi_rank=mpi.rank mpi_size=mpi.size print 'MPI rank',mpi_rank print 'MPI size',mpi_size if size==1: mpi_rank=None except: # # No MPI # pass # # start the run # import sys,os if len(sys.argv)<4: raise 'Incorrect usage' if not pdbfile: pdbfile=sys.argv[1] if len(sys.argv)>2: dir=sys.argv[2] else: raise 'You have to provide a dir for the output' os.chdir(dir) # # Get the method # method=sys.argv[3] # # Are we doing this cheap style? # mcstep_factor=1.00 if sys.argv[-1]=='cheap': mcstep_factor=0.01 # # Set the file name # filename=os.path.join(dir,'distance_nummuts__'+os.path.split(pdbfile)[1])+'_'+method # # Keep the cheap results separated from the real results # if sys.argv[-1]=='cheap': filename=filename+'cheap' # # Print the filename of the dictionary # print 'Setting dictionary filename to',filename DB=dictIO(filename) print 'I am running in %s' %os.getcwd() # # Do we have a completed pKa calc for it? # import pKaTool.pKaIO X=pKaTool.pKaIO.pKaIO(pdbfile) if not X.assess_status(): print 'You have to run a pKa calculation first' raise Exception() # # OK, got the pKa calc. Read results # wt_pKas=X.readpka() groups=wt_pKas.keys() groups.sort() # # Design target: for all groups with pKa value between 2 and 10: +2 and -2 # import os if os.path.isfile(filename): # # Load old file # results=DB.load() else: # # No, no old restuls # results={} # # Add the PDB file # fd=open(pdbfile) lines=fd.readlines() fd.close() results['pdbfile']=lines # # Add the full wt pKa values # results['wt_full']=wt_pKas DB.save(results) # --------------------------------------- # # Delete old files # Design_pKa.delete_old_files(pdbfile,'N','Y') # # Start looping # dist_range=range(1,26) num_muts_range=range(1,21) count=0 design_low=2.0 design_high=10.0 # # Count the number of designable groups # design_groups=[] for group in groups: pKaval=wt_pKas[group]['pKa'] if pKaval>design_low and pKaval<design_high: design_groups.append(group) tot_count=float(len(design_groups)*2*len(dist_range)*len(num_muts_range))/100.0 # # Set the number of MC steps # # #if len(groups)<60: pKMCsteps=200000 #else: # #print 'We have %d groups, so increasing pKMCsteps' %(len(groups)) # pKMCsteps=200000 pKMCsteps=int(mcstep_factor*float(pKMCsteps)) # # Start of loop # groups.sort() # # Are we running MPI? # if mpi_rank!=None: fraction=1.0/float(mpi_size) print 'I will be doing %.2f %% of the job' %(100.0*fraction) num_groups=len(groups) print 'Specifically I will be doing groups',groups[int(fraction*mpi_rank*num_groups):int(fraction*(mpi_rank+1)*num_groups)] print fraction*mpi_rank*num_groups,'to',fraction*(mpi_rank+1)*num_groups groups=groups[int(fraction*mpi_rank*num_groups):int(fraction*(mpi_rank+1)*num_groups)] # # Sleep to desynchronize processes # import time time.sleep(mpi_rank) print mpi_rank,'done sleeping!' import sys sys.stdout.flush() # # Do the calculation # for group in groups: # # Loop over all groups # if not results.has_key(group): results[group]={} # # Is somebody working on this group? # #results=DB.update(results) if results[group].has_key('locked'): if results[group]['locked']==1: print '%s is locked' %group continue # # Lock group # results[group]['locked']=1 # # Force reinitialisation of instance # X=None # # Loop over number of mutations and distance cut-off # pKaval=wt_pKas[group]['pKa'] if pKaval>design_low and pKaval<design_high: for design in ['+20.0','m20.0']: if not results[group].has_key(design): results[group][design]={} for min_target_dist in dist_range: for num_muts in num_muts_range: if not results[group][design].has_key(num_muts): results[group][design][num_muts]={} # # Print what we are doing # print 'Checking: %20s design: %s, dist: %5.1f, nummuts: %3d %%done %5.2f' %(group,design, min_target_dist, num_muts,float(count)/tot_count) count=count+1 # # .. # if not results[group][design][num_muts].has_key(min_target_dist): results[group][design][num_muts][min_target_dist]={} # # Get the solutions # dpKas,data_added,X=get_solutions_dist_nummuts(pdbfile, group, design,num_muts, min_target_dist, results[group][design][num_muts][min_target_dist], method,pKMCsteps,X) results[group][design][num_muts][min_target_dist]=dpKas.copy() pass results=DB.update(results) else: results[group]['pKa out of range']=1 # # Unlock group and merge results # del results[group]['locked'] results=DB.update(results) # # All done # print print 'All done - normal exit' print return
def main(pdbfile=None): # # Calculate the matrix of pKa shifts [number of mutations:min distance from active site] # # Get the PDB file # print print 'Construct dpKa matrix for a single design criterium' print print 'Usage: Design_two_targets <pdbfile> <database file> <design statement>' print # # start the run # import sys, os if len(sys.argv) < 4: raise 'Incorrect usage' if not pdbfile: pdbfile = sys.argv[1] if len(sys.argv) > 2: dir = sys.argv[2] else: raise 'You have to provide a dir for the output' os.chdir(dir) # # Get the method # method = 'MC' # # Which design are we doing? # design_statement = sys.argv[3] # # Set the file name # filename = os.path.join( dir, 'designtwo__' + os.path.split(pdbfile)[1]) + '_' + method + design_statement # # Print the filename of the dictionary # print 'Setting dictionary filename to', filename DB = dictIO(filename) print 'I am running in %s' % os.getcwd() # # Get wild type pKa values # import pKaTool.pKaIO X = pKaTool.pKaIO.pKaIO(pdbfile) if not X.assess_status(): import os print 'You have to run a pKa calculation first' raise Exception() # # OK, got the pKa calc. Read results # wt_pKas = X.readpka() # # See if we have an old database file we should work on # import os if os.path.isfile(filename): # # Load old file # results = DB.load() else: # # No, no old restuls # results = {} # # Add the PDB file # fd = open(pdbfile) lines = fd.readlines() fd.close() results['pdbfile'] = lines # # Add the full wt pKa values # results['wt_full'] = wt_pKas DB.save(results) # --------------------------------------- # # Delete old files # import Design_pKa Design_pKa.delete_old_files(pdbfile, 'N', 'N') # # Start looping # dist_range = range(1, 26) num_muts_range = range(1, 21) count = 0 # # Set the number of MC steps # pKMCsteps = 200000 # # Start of loop # # # Loop over number of mutations and distance cut-off # X = None if not results.has_key(design_statement): results[design_statement] = {} for min_target_dist in dist_range: for num_muts in num_muts_range: # # Make sure the dictionary entries are there # if not results[design_statement].has_key(num_muts): results[design_statement][num_muts] = {} if not results[design_statement][num_muts].has_key( min_target_dist): results[design_statement][num_muts][min_target_dist] = {} # # Have we done this one yet? # x = 'Checking dist: %5.2f #muts: %2d....' % ( float(min_target_dist), num_muts) print x, if results[design_statement][num_muts][min_target_dist] == {}: print 'not done. Designing solutions:' # # Get the parameters # defaults = set_parameters(pdbfile=pdbfile, design_statement=design_statement, min_dist=min_target_dist, num_muts=num_muts) params = {} for key in defaults.keys(): params[key] = defaults[key][0] # # Call the design routine # if not X: X = Design_pKa.Design_pKa(params) solutions, dpKa_dict = Design_pKa.run_opt(defaults, X) res = dpKa_dict.keys() res.sort() #for r in res: # print r,dpKa_dict[r] # # Store the solutions # print 'Found these solutions' print dpKa_dict.keys() if dpKa_dict.keys() == []: results[design_statement][num_muts][min_target_dist] = { method: { 'None': 'No solutions' } } else: results[design_statement][num_muts][min_target_dist] = { method: dpKa_dict.copy() } results = DB.update(results) else: print 'done.' # # All done # print print 'All done - normal exit' print return
def main(pdbfile=None): # # Calculate the matrix of pKa shifts [number of mutations:min distance from active site] # # Get the PDB file # print print 'Construct dpKa matrix for a single design criterium' print print 'Usage: Design_two_targets <pdbfile> <database file> <design statement>' print # # start the run # import sys,os if len(sys.argv)<4: raise 'Incorrect usage' if not pdbfile: pdbfile=sys.argv[1] if len(sys.argv)>2: dir=sys.argv[2] else: raise 'You have to provide a dir for the output' os.chdir(dir) # # Get the method # method='MC' # # Which design are we doing? # design_statement=sys.argv[3] # # Set the file name # filename=os.path.join(dir,'designtwo__'+os.path.split(pdbfile)[1])+'_'+method+design_statement # # Print the filename of the dictionary # print 'Setting dictionary filename to',filename DB=dictIO(filename) print 'I am running in %s' %os.getcwd() # # Get wild type pKa values # import pKaTool.pKaIO X=pKaTool.pKaIO.pKaIO(pdbfile) if not X.assess_status(): import os print 'You have to run a pKa calculation first' raise Exception() # # OK, got the pKa calc. Read results # wt_pKas=X.readpka() # # See if we have an old database file we should work on # import os if os.path.isfile(filename): # # Load old file # results=DB.load() else: # # No, no old restuls # results={} # # Add the PDB file # fd=open(pdbfile) lines=fd.readlines() fd.close() results['pdbfile']=lines # # Add the full wt pKa values # results['wt_full']=wt_pKas DB.save(results) # --------------------------------------- # # Delete old files # import Design_pKa Design_pKa.delete_old_files(pdbfile,'N','N') # # Start looping # dist_range=range(1,26) num_muts_range=range(1,21) count=0 # # Set the number of MC steps # pKMCsteps=200000 # # Start of loop # # # Loop over number of mutations and distance cut-off # X=None if not results.has_key(design_statement): results[design_statement]={} for min_target_dist in dist_range: for num_muts in num_muts_range: # # Make sure the dictionary entries are there # if not results[design_statement].has_key(num_muts): results[design_statement][num_muts]={} if not results[design_statement][num_muts].has_key(min_target_dist): results[design_statement][num_muts][min_target_dist]={} # # Have we done this one yet? # x='Checking dist: %5.2f #muts: %2d....' %(float(min_target_dist),num_muts) print x, if results[design_statement][num_muts][min_target_dist]=={}: print 'not done. Designing solutions:' # # Get the parameters # defaults=set_parameters(pdbfile=pdbfile, design_statement=design_statement, min_dist=min_target_dist, num_muts=num_muts) params={} for key in defaults.keys(): params[key]=defaults[key][0] # # Call the design routine # if not X: X=Design_pKa.Design_pKa(params) solutions,dpKa_dict=Design_pKa.run_opt(defaults,X) res=dpKa_dict.keys() res.sort() #for r in res: # print r,dpKa_dict[r] # # Store the solutions # print 'Found these solutions' print dpKa_dict.keys() if dpKa_dict.keys()==[]: results[design_statement][num_muts][min_target_dist]={method:{'None':'No solutions'}} else: results[design_statement][num_muts][min_target_dist]={method:dpKa_dict.copy()} results=DB.update(results) else: print 'done.' # # All done # print print 'All done - normal exit' print return