def calculIdenticNeedleCross(l_p_fasta, pr_alignement): """ Calcul identity structure args: -> list of fasta files return: -> dictionary with identity """ if len(l_p_fasta) == 1: return [] dico_out = {} if len(l_p_fasta) == 2: first_key = l_p_fasta[0].split("/")[-1][0:-6] dico_out[first_key] = {} if not path.exists(pr_alignement + first_key + "_" + l_p_fasta[1].split("/")[-1][0:-6] + ".needle"): path_file_needle = runOtherSoft.needle( l_p_fasta[0], l_p_fasta[1], pr_alignement + first_key + "_" + l_p_fasta[1].split("/")[-1][0:-6] + ".needle") else: path_file_needle = pr_alignement + first_key + "_" + l_p_fasta[ 1].split("/")[-1][0:-6] + ".needle" dico_out[first_key][l_p_fasta[1].split( "/")[-1][0:-6]] = parseEMBOSS.embossFile(path_file_needle)[3] else: nb_fasta = len(l_p_fasta) i = 0 while i < nb_fasta - 1: first_key = l_p_fasta[i].split("/")[-1][0:-6] dico_out[first_key] = {} j = i + 1 while j < nb_fasta: if not path.exists(pr_alignement + first_key + "_" + l_p_fasta[j].split("/")[-1][0:-6] + ".needle"): path_file_needle = runOtherSoft.needle( l_p_fasta[i], l_p_fasta[j], pr_alignement + first_key + "_" + l_p_fasta[j].split("/")[-1][0:-6] + ".needle") if path.exists(pr_alignement + first_key + "_" + l_p_fasta[j].split("/")[-1][0:-6] + ".needle"): # case DNA sequence in fasta dico_out[first_key][l_p_fasta[j].split( "/")[-1][0:-6]] = parseEMBOSS.embossFile( pr_alignement + first_key + "_" + l_p_fasta[j].split("/")[-1][0:-6] + ".needle")[3] j = j + 1 i = i + 1 # for i in dico_out.keys () : # print dico_out[i] return dico_out
def calculIdenticNeedleCross(l_p_fasta, pr_alignement) : """ Calcul identity structure args: -> list of fasta files return: -> dictionary with identity """ if len (l_p_fasta) == 1 : return [] dico_out = {} if len (l_p_fasta) == 2 : first_key = l_p_fasta[0].split("/")[-1][0:-6] dico_out[first_key] = {} if not path.exists( pr_alignement + first_key + "_" + l_p_fasta[1].split("/")[-1][0:-6] + ".needle") : path_file_needle = runOtherSoft.needle(l_p_fasta[0], l_p_fasta[1], pr_alignement + first_key + "_" + l_p_fasta[1].split("/")[-1][0:-6] + ".needle") else : path_file_needle = pr_alignement + first_key + "_" + l_p_fasta[1].split("/")[-1][0:-6] + ".needle" dico_out[first_key] [l_p_fasta[1].split("/")[-1][0:-6]] = parseEMBOSS.embossFile(path_file_needle)[3] else : nb_fasta = len (l_p_fasta) i = 0 while i < nb_fasta-1 : first_key = l_p_fasta[i].split("/")[-1][0:-6] dico_out[first_key] = {} j = i + 1 while j < nb_fasta : if not path.exists( pr_alignement + first_key + "_" + l_p_fasta[j].split("/")[-1][0:-6] + ".needle") : path_file_needle = runOtherSoft.needle(l_p_fasta[i], l_p_fasta[j], pr_alignement + first_key + "_" + l_p_fasta[j].split("/")[-1][0:-6] + ".needle") if path.exists( pr_alignement + first_key + "_" + l_p_fasta[j].split("/")[-1][0:-6] + ".needle") : # case DNA sequence in fasta dico_out[first_key] [l_p_fasta[j].split("/")[-1][0:-6]] = parseEMBOSS.embossFile(pr_alignement + first_key + "_" + l_p_fasta[j].split("/")[-1][0:-6] + ".needle")[3] j = j + 1 i = i + 1 # for i in dico_out.keys () : # print dico_out[i] return dico_out
def applyNeedleList(l_file_fasta, pr_out): nb_pr_ref = len(l_file_fasta) d_out = {} i = 0 while i < nb_pr_ref: j = i + 1 PDB1 = l_file_fasta[i].split("/")[-1][0:4] # print PDB1 while j < nb_pr_ref: PDB2 = l_file_fasta[j].split("/")[-1][0:4] # folder TM align p_outfile = runOtherSoft.needle( l_file_fasta[i], l_file_fasta[j], pr_out + PDB1 + "__" + PDB2 + ".needle") out = parseEMBOSS.embossFile(p_outfile) # list 0-> seq1, 1-> seq2, 2-> similarity, 3->identity # print out[2:] # parse result if not PDB1 in d_out.keys(): if not PDB2 in d_out.keys(): d_out[PDB1] = {} d_out[PDB1][PDB2] = {} d_out[PDB1][PDB2]["identity"] = out[3].replace("%", "") d_out[PDB1][PDB2]["similarity"] = out[2].replace("%", "") else: d_out[PDB2][PDB1] = {} d_out[PDB2][PDB1]["identity"] = out[3].replace("%", "") d_out[PDB2][PDB1]["similarity"] = out[2].replace("%", "") else: d_out[PDB1][PDB2] = {} d_out[PDB1][PDB2]["identity"] = out[3].replace("%", "") d_out[PDB1][PDB2]["similarity"] = out[2].replace("%", "") j = j + 1 i = i + 1 return d_out
def applyNeedleList (l_file_fasta, pr_out): nb_pr_ref = len (l_file_fasta) d_out = {} i = 0 while i < nb_pr_ref : j = i + 1 PDB1 = l_file_fasta[i].split ("/")[-1][0:4] # print PDB1 while j < nb_pr_ref : PDB2 = l_file_fasta[j].split ("/")[-1][0:4] # folder TM align p_outfile = runOtherSoft.needle (l_file_fasta[i], l_file_fasta[j], pr_out + PDB1 + "__" + PDB2 + ".needle") out = parseEMBOSS.embossFile(p_outfile) # list 0-> seq1, 1-> seq2, 2-> similarity, 3->identity # print out[2:] # parse result if not PDB1 in d_out.keys () : if not PDB2 in d_out.keys () : d_out[PDB1] = {} d_out[PDB1][PDB2] = {} d_out[PDB1][PDB2]["identity"] = out[3].replace ("%", "") d_out[PDB1][PDB2]["similarity"] = out[2].replace ("%", "") else : d_out[PDB2][PDB1] = {} d_out[PDB2][PDB1]["identity"] = out[3].replace ("%", "") d_out[PDB2][PDB1]["similarity"] = out[2].replace ("%", "") else : d_out[PDB1][PDB2] = {} d_out[PDB1][PDB2]["identity"] = out[3].replace ("%", "") d_out[PDB1][PDB2]["similarity"] = out[2].replace ("%", "") j = j + 1 i = i + 1 return d_out