def applyTMAlign(substruct): p_dir_dataset = pathManage.dataset(substruct) l_folder = listdir(p_dir_dataset) for ref_folder in l_folder: if len(ref_folder) != 4: continue l_pdbfile = listdir(p_dir_dataset + ref_folder + "/") p_pdb_ref = pathManage.findPDBRef(p_dir_dataset + ref_folder + "/") for pdbfile in l_pdbfile: # try if PDB not ligand if len(pdbfile.split("_")[0]) != 4 or not search(".pdb", pdbfile): continue # same alignment elif p_dir_dataset + ref_folder + "/" + pdbfile == p_pdb_ref: continue else: p_file_pdb = p_dir_dataset + ref_folder + "/" + pdbfile p_dir_align = pathManage.alignmentOutput( substruct + "/" + p_pdb_ref.split("/")[-1][:-4] + "__" + p_file_pdb.split("/")[-1][:-4]) # superimpose runOtherSoft.runTMalign(p_file_pdb, p_pdb_ref, p_dir_align) return 1
def analysisBS(name_lig, ID_seq='0.0', debug=1): pr_result = pathManage.result(name_lig) pr_out = pathManage.result(name_lig + "/sameBS") # log files p_log_file = pr_out + "log.txt" filout_log = open(p_log_file, "w") # dictionnar with files d_file_BS = {} d_file_BS["global"] = open(pr_out + name_lig + "_", "w") d_file_BS["global"].write( "name_bs\tRMSD_prot\tRMSD_BS_ca\tRMSD_BS_all\tD_max\tl_at_BS\tidentic\n" ) d_file_BS["summary"] = open(pr_out + "summary.txt", "w") pr_dataset = pathManage.dataset(name_lig) l_folder_ref = listdir(pr_result) nb_BS = 0 nb_BS_filtered = 0 nb_same_BS = 0 for PDB_ref in l_folder_ref: if debug: print PDB_ref if len(PDB_ref) != 4: continue p_pdb_ref = pathManage.findPDBRef(pr_dataset + PDB_ref + "/") l_p_query = pathManage.findPDBQueryTransloc( pathManage.result(name_lig) + PDB_ref + "/") if debug: print l_p_query for p_query in l_p_query: # read TM Align if debug: print p_query.split("/")[-1][7:-4] p_TMalign = pathManage.alignmentOutput(name_lig) + p_pdb_ref.split( "/")[-1][0:-4] + "__" + p_query.split("/")[-1][7:-4] + "/RMSD" try: score_align = parseTMalign.parseOutputTMalign(p_TMalign) except: filout_log.write("ERROR TM align " + p_TMalign + "\n") continue nb_BS = nb_BS + 1 if score_align["IDseq"] >= ID_seq: nb_BS_filtered = nb_BS_filtered + 1 l_p_substruct_ref = pathManage.findSubstructRef( pr_dataset + PDB_ref + "/", name_lig) # sub BS for p_substruct_ref in l_p_substruct_ref: struct_substitued = p_substruct_ref.split("_")[-2] # write header if not struct_substitued in d_file_BS.keys(): d_file_BS[struct_substitued] = open( pr_out + name_lig + "_" + struct_substitued + "_", "w") d_file_BS[struct_substitued].write( "name_bs\tRMSD_prot\tRMSD_BS_ca\tRMSD_BS_all\tD_max\tl_at_BS\tidentic\n" ) RMSD_bs = analysis.computeRMSDBS(p_pdb_ref, p_query, p_substruct_ref, pr_out) if RMSD_bs != []: d_file_BS[struct_substitued].write( p_substruct_ref.split("/")[-1][0:-4] + "_*_" + p_query.split("/")[-1][0:-4] + "\t" + str(score_align["RMSD"]) + "\t" + str(RMSD_bs[1]) + "\t" + str(RMSD_bs[0]) + "\t" + str(RMSD_bs[2]) + "\t" + str(RMSD_bs[-2]) + "\t" + str(RMSD_bs[-1]) + "\n") p_ligand_ref = pathManage.findligandRef( pr_dataset + PDB_ref + "/", name_lig) RMSD_bs_lig = analysis.computeRMSDBS(p_pdb_ref, p_query, p_ligand_ref, pr_out) if RMSD_bs_lig != []: d_file_BS["global"].write( p_ligand_ref.split("/")[-1][0:-4] + "_*_" + p_query.split("/")[-1][0:-4] + "\t" + str(score_align["RMSD"]) + "\t" + str(RMSD_bs_lig[1]) + "\t" + str(RMSD_bs_lig[0]) + "\t" + str(RMSD_bs_lig[2]) + "\t" + str(RMSD_bs_lig[-2]) + "\t" + str(RMSD_bs_lig[-1]) + "\n") if RMSD_bs_lig[-1] == 1: nb_same_BS = nb_same_BS + 1 # write summary d_file_BS["summary"].write("BS global: " + str(nb_BS) + "\n") d_file_BS["summary"].write("BS - IDseq " + str(ID_seq) + "%: " + str(nb_BS_filtered) + "\n") d_file_BS["summary"].write("BS - same atom number: " + str(nb_same_BS) + "\n") filout_log.close() # close files and run histograms for k_dico in d_file_BS.keys(): p_file = d_file_BS[k_dico].name d_file_BS[k_dico].close() if name_lig == "ATP": runOtherSoft.RhistogramRMSD(p_file, max_RMSD=5.0) elif name_lig == "ADP": runOtherSoft.RhistogramRMSD(p_file, max_RMSD=4.0) elif name_lig == "AMP": runOtherSoft.RhistogramRMSD(p_file, max_RMSD=4.0) else: runOtherSoft.RhistogramRMSD(p_file, max_RMSD=3.5) return 1