def run_FoldX_AnalyseComplex_And_Agadir(self): GUM.wait_for_grid_engine_job_to_complete(self.solubis_job_prefix, 'all Solubis jobs to finish') self.all_mutants_in_Solubis_path = sorted(glob.glob('./*')) foldx_instance = FoldX() for mutant_in_Solubis_path in self.all_mutants_in_Solubis_path: if os.path.isdir(mutant_in_Solubis_path): mutant_folder_name = mutant_in_Solubis_path.split('/')[-1] os.chdir(mutant_folder_name) self._make_backup_of_runscript() foldx_instance.prepare_for_FoldX_AnalyseComplex( self.RepairPDB_pdb_name) print os.getcwd() # Note: _1_0 is random choice, other two are same. # cwd is Results/pdbname/Runs/Solubis/mutant_name relative_path_of_pdb_to_read = './' relative_path_for_new_fasta_folder_to_write = './' pdb_name_chain_fasta_dict = GUM.extract_pdb_name_fasta_and_chains_from_pdb( self.RepairPDB_pdb_name + '_1_0.pdb', relative_path_of_pdb_to_read) GUM.write_fasta_to_folder( pdb_name_chain_fasta_dict, relative_path_for_new_fasta_folder_to_write) grid_engine_job_name = self.analyze_complex_job_prefix + mutant_folder_name agadir_results_path = os.getcwd() python_script_with_path = self.results_pdb_path + '/../../SourceFiles/Scripts/run_agadir.py ' + \ agadir_results_path self._run_runscript_on_grid_engine(grid_engine_job_name, python_script_with_path) os.chdir('./..') # is this Runs/Solubis folder ? cwd = os.getcwd() # for debugging else: print mutant_in_Solubis_path
def _run_runscript_on_grid_engine(self, grid_engine_job_name, python_script_with_path): no_queue = '' no_max_memory = '' no_cluster = '' using_runscript = True GUM.build_job_q_bash(grid_engine_job_name, no_queue, no_max_memory, no_cluster, using_runscript, self.foldx_path, python_script_with_path) subprocess.call('qsub job.q', shell=True)
def prepare_for_FoldX_BuildModel(self, mutant_name, pdb_name_of_repaired_pdb): path_to_runscript = './' repaired_pdbs = 'RepairPDB_' + pdb_name_of_repaired_pdb + '.pdb' show_sequence_detail = False action = '<BuildModel>#,individual_list.txt' print_networks = False calculate_stability = False GUM.build_runscript_for_pdbs(path_to_runscript, repaired_pdbs, show_sequence_detail, action, print_networks, calculate_stability) individual_list_for_this_mutant_only = open('individual_list.txt', 'w') individual_list_for_this_mutant_only.write(mutant_name + ';\n') individual_list_for_this_mutant_only.close()
def _run_repair_on_grid_engine(self, pdb_name): repair_python_script = 'repair.py' self._print_OptProt_calling_script(repair_python_script) grid_engine_job_name = self.repair_job_prefix + pdb_name no_queue = '' no_max_memory = '' no_cluster = '' using_runscript = False python_script_with_path_and_qsub = self.scripts_path + '/' + repair_python_script + \ self.space + self.qsub_path GUM.build_job_q_bash(grid_engine_job_name, no_queue, no_max_memory, no_cluster, using_runscript, self.foldx_path, python_script_with_path_and_qsub) subprocess.call(self.qsub_path + 'qsub job.q', shell=True) os.chdir(self.start_path)
def _parse_optionfile_for_computations_charge_proteinChains( self, option_file): for line in option_file: if '#' in line: continue if 'Command:' in line: self.command = line.split(':')[-1].strip(';\n').strip() if 'Charge:' in line: self.charge = line.split(':')[-1].strip(';\n').strip() if 'ProteinChains:' in line: self.underscore_separated_proteinChains = [] protein_chains_option = line.split(':')[-1].strip(';\n') if protein_chains_option == 'All': for pdb in self.pdb_list: protein_chains_list = GUM.extract_all_chains_from_pdb( pdb, './PDBs/') self.underscore_separated_proteinChains = '_'.join( protein_chains_list) self.pdb_protein_chains_dict = { pdb: self.underscore_separated_proteinChains } elif ',' in protein_chains_option: protein_chains_list = protein_chains_option.split(',') protein_chains_list_stripped = [] for protein_chain in protein_chains_list: protein_chains_list_stripped.append( protein_chain.strip()) self.underscore_separated_proteinChains = '_'.join( protein_chains_list_stripped) else: self.underscore_separated_proteinChains = protein_chains_option print 'Command to be executed:\t\t' + self.command print 'Protein chains to be considered:\t' + self.underscore_separated_proteinChains
def prepare_for_FoldX_AnalyseComplex(self, repair_pdb_name): _0_1_2_pdbs = ['0.pdb,', '1.pdb,', '2.pdb,'] repair_pdb_name_1_ = repair_pdb_name + '_1_' wt_repair_pdb_name_1_ = 'WT_' + repair_pdb_name_1_ path_to_runscript = './' pdbs_to_analyse = repair_pdb_name_1_ + _0_1_2_pdbs[0] + \ repair_pdb_name_1_ + _0_1_2_pdbs[1] + \ repair_pdb_name_1_ + _0_1_2_pdbs[2] + \ wt_repair_pdb_name_1_ + _0_1_2_pdbs[0] + \ wt_repair_pdb_name_1_ + _0_1_2_pdbs[1] + \ wt_repair_pdb_name_1_ + _0_1_2_pdbs[2] show_sequence_detail = False action = '<AnalyseComplex>#' print_networks = False calculate_stability = False GUM.build_runscript_for_pdbs(path_to_runscript, pdbs_to_analyse, show_sequence_detail, action, print_networks, calculate_stability)
def run_yasara_agadir_repair(self): if not os.path.exists('Results'): os.makedirs('Results') for pdb in self.pdb_list: pdb_name = pdb.split('.')[0] self._build_results_directory_tree_for_each(pdb) # current directory Results/pdb # self._run_yasara_to_organise_pdb(pdb, pdb_name) self._copy_pdb_foldx_agadir_files_to_new_subdirectories(pdb) relative_path_of_pdb_to_read = './PDBs/' relative_path_for_new_fasta_folder_to_write = './' pdb_name_chain_fasta_dict = GUM.extract_pdb_name_fasta_and_chains_from_pdb( pdb, relative_path_of_pdb_to_read) GUM.write_fasta_to_folder( pdb_name_chain_fasta_dict, relative_path_for_new_fasta_folder_to_write) agadir_results_path = self.start_path + '/Results/' + pdb_name agadir_instance = Agadir(agadir_results_path) agadir_instance.run_agadir_with_fasta_files('./') self._run_repair_on_grid_engine(pdb_name) message_to_print = 'PDBs to be repaired' GUM.wait_for_grid_engine_job_to_complete(self.repair_job_prefix, message_to_print)
def write_summary_solubis_file(self): GUM.wait_for_grid_engine_job_to_complete( self.analyze_complex_job_prefix, 'all AnalyseComplex jobs to finish') os.chdir(self.results_pdb_path) solubis_summary_file = open('SummarySolubis.txt', 'w') solubis_summary_file.write( 'Mutation\tProteinChahin\tddG\tdTANGO\tComplexSum\t') has_I_AC_fxout_file_for_repair_pdb = False if os.path.isfile('./Repair/' + self.Int_AnalyComp + self.RepairPDB_pdb_name + '.fxout'): # use absolute path? has_I_AC_fxout_file_for_repair_pdb = True interact_ac_pdb_fxout_file = open('./Repair/' + self.Int_AnalyComp + self.RepairPDB_pdb_name + '.fxout').readlines() protein_chain_complexes = [] for line in interact_ac_pdb_fxout_file[9:]: protein_chain_1 = line.split('\t')[1] protein_chain_2 = line.split('\t')[2] protein_chain_complex = 'Complex_' + protein_chain_1 + '_' + protein_chain_2 protein_chain_complexes.append(protein_chain_complex) tab_separated_protein_chain_complexes = "\t".join( protein_chain_complexes) solubis_summary_file.write(tab_separated_protein_chain_complexes + '\n') else: solubis_summary_file.write('\n') all_agadir_outputs_wt_pdb_chains = glob.glob( './Agadir/*') # use the absolute path here TangoWT = 0 for agadir_outputs_wt_pdb_chain in all_agadir_outputs_wt_pdb_chains: # agadir_outputs_pdb_chains if os.path.isdir(agadir_outputs_wt_pdb_chain): print agadir_outputs_wt_pdb_chain f = open(agadir_outputs_wt_pdb_chain + '/PSX_globaltotal.out', 'r').readlines() TangoWT += float(f[1].split()[2]) print 'Tango GlobalTotal score for WT protein = ' + str(TangoWT) os.chdir(self.results_pdb_Runs_Solubis_path) for solubis_mutant_folder_path in self.all_mutants_in_Solubis_path: if os.path.isdir(solubis_mutant_folder_path): f = open( solubis_mutant_folder_path + '/Average_BuildModel_' + self.RepairPDB_pdb_name + '.fxout', 'r').readlines() # # THIS IS THE FOLDX STABILITY VALUE # # ddG = f[9].split()[2] agadir_output_files_for_this_mutant_chain_paths = glob.glob( solubis_mutant_folder_path + '/Agadir/*') TangoMut = 0 for agadir_output_files_for_this_mutant_chain_path in agadir_output_files_for_this_mutant_chain_paths: if os.path.isdir( agadir_output_files_for_this_mutant_chain_path): # redundant ? path_agad_list is obtained line above by getting everything in Agadir folder # def get_globalTango_from_PSX_globaltotalout_file(path): f = open( agadir_output_files_for_this_mutant_chain_path + '/PSX_globaltotal.out', 'r').readlines() # globalTango_file TangoMut += float(f[1].split()[2]) path_agad = agadir_output_files_for_this_mutant_chain_path # ./Runs/Solubis/AH92R/Agadir/RepairPDB_Ab82b0sLigand_H print 'Tango GlobalTotal score for mutant protein = ' + str( TangoMut) print path_agad # don't understand. Goes through all chains but only stores last one to open the tango file below f = open( path_agad + '/PSX_globaltotal.out', 'r').readlines() # opening the globalTango file again ? print f[ 1] # which it then just prints and doesn't use ? - is this leftover from debugging if has_I_AC_fxout_file_for_repair_pdb: repair_pdb_name_1_ = self.RepairPDB_pdb_name + '_1_' wt_repair_pdb_name_1_ = 'WT_' + repair_pdb_name_1_ path_I_AC_repair_pdb_name_1_ = solubis_mutant_folder_path + '/' + self.Int_AnalyComp + repair_pdb_name_1_ path_I_AC_wt_repair_pdb_name_1_ = solubis_mutant_folder_path + '/' + self.Int_AnalyComp + wt_repair_pdb_name_1_ _0_1_2_fxout = ['0.fxout', '1.fxout', '2.fxout'] # for fxout in _0_1_2_fxout: # _get_interaction_energies_from_I_AC_file(path_IAC_repair_pdb_name_1_ + fxout) # complex_Mut1 = _get_interaction_energies_from_I_AC_file(path_IAC_repair_pdb_name_1_ + _0_1_2_fxout[0]) f = open(path_I_AC_repair_pdb_name_1_ + _0_1_2_fxout[0], 'r').readlines() complex_Mut1 = [] for line in f[9:]: complex_Mut1.append(float(line.split()[5])) f = open(path_I_AC_repair_pdb_name_1_ + _0_1_2_fxout[1], 'r').readlines() complex_Mut2 = [] for line in f[9:]: complex_Mut2.append(float(line.split()[5])) f = open(path_I_AC_repair_pdb_name_1_ + _0_1_2_fxout[2], 'r').readlines() complex_Mut3 = [] for line in f[9:]: complex_Mut3.append(float(line.split()[5])) f = open(path_I_AC_wt_repair_pdb_name_1_ + _0_1_2_fxout[0], 'r').readlines() complex_WT1 = [] for line in f[9:]: complex_WT1.append(float(line.split()[5])) f = open(path_I_AC_wt_repair_pdb_name_1_ + _0_1_2_fxout[1], 'r').readlines() complex_WT2 = [] for line in f[9:]: complex_WT2.append(float(line.split()[5])) f = open(path_I_AC_wt_repair_pdb_name_1_ + _0_1_2_fxout[2], 'r').readlines() complex_WT3 = [] for line in f[9:]: complex_WT3.append(float(line.split()[5])) dInteractionEnergies_per_complex_list = [] dInteractionEnergies_all_complexes_summed = 0 for x, line in enumerate(f[9:]): average_interaction_energy_per_complex_WT = float( (complex_WT1[x] + complex_WT2[x] + complex_WT3[x]) / 3) average_interaction_energy_per_complex_Mut = float( (complex_Mut1[x] + complex_Mut2[x] + complex_Mut3[x]) / 3) dInteractionEnergies_for_each_complex = average_interaction_energy_per_complex_Mut - average_interaction_energy_per_complex_WT dInteractionEnergies_all_complexes_summed += dInteractionEnergies_for_each_complex dInteractionEnergies_per_complex_list.append( str(dInteractionEnergies_for_each_complex)) dInteractionEnergies_per_complex = "\t".join( dInteractionEnergies_per_complex_list) else: dInteractionEnergies_per_complex = "" dInteractionEnergies_all_complexes_summed = 0 dTango = float(TangoMut) - float(TangoWT) mutation_name = solubis_mutant_folder_path.split('/')[-1] protein_chain = mutation_name[ 1] # Does this give same as above two lines? row_of_values_per_mutation = mutation_name + '\t' + protein_chain + '\t' + ddG + '\t' + str(dTango) + '\t' + \ str(dInteractionEnergies_all_complexes_summed) + '\t' + \ dInteractionEnergies_per_complex + '\n' solubis_summary_file.write(row_of_values_per_mutation) solubis_summary_file.close()