def get_edit_distance(seq_x, seq_y, scoring_matrix): ''' compute the seq_x and seq_y global alignment with scoring matrix return the edit distance can be expressed in term of: |x| + |y| - score(x, y) ''' alignment_matrix = compute_alignment_matrix(seq_x, seq_y, scoring_matrix, True) score, align_x, align_y = compute_global_alignment(seq_x, seq_y, scoring_matrix, alignment_matrix) return len(seq_x) + len(seq_y) - score
def dosomething(t): seq_x, seq_y, scoring_matrix=t[0],t[1],t[2] # seq_x_1=list(seq_x) # random.shuffle(seq_x_1) # seq_x=''.join(seq_x_1) seq_y_1=list(seq_y) random.shuffle(seq_y_1) seq_y=''.join(seq_y_1) ss=fiel1.compute_alignment_matrix(seq_x,seq_y,scoring_matrix,False) s=fiel1.compute_local_alignment(seq_x, seq_y, scoring_matrix, ss) return s[0]
plt1=plt.bar(x, y_1, alpha = 0.5, color = 'g',width = 0.8,align="center") ax=plt.gca() plt.xticks(x,x) # ax.set_xticklabels( list(range(100))) # plt2,=plt.plot( x, f2, 'b',linewidth=2,label='hierarchical clustering') # plt3,=plt.plot( x, f3, 'g', linewidth=2,label='13') # print 'a' # plt.axis([-4, 4, -0.5, 8]) # plt.text(1, 7.5, r'$10^x$', ) # plt.text(2.2, 7.5, r'$e^x$') # plt.text(3.2, 7.5, r'$2^x$') # plt.legend([plt1,plt2], ["k-means",'hierarchical clustering'],loc=1) plt.legend([plt1], ["ratio"],loc=1) plt.xlabel('the ratio') plt.xlabel('score') plt.title('normalized version of this distribution') plt.show() import math mu=float(sum(result))/len(result) s=0 for x in result: s+=(x-mu)*(x-mu) # s+=(x-mu)**(2) sigma=math.sqrt(s/len(result)) print mu,sigma m=fiel1.compute_alignment_matrix(alg_HumanEyelessProtein,alg_FruitflyEyelessProtein,get_sc(),False) s=fiel1.compute_local_alignment(alg_HumanEyelessProtein,alg_FruitflyEyelessProtein,get_sc(),m) print (s[0]-mu)/sigma