-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelper_functions.py
More file actions
59 lines (42 loc) · 1.71 KB
/
Copy pathhelper_functions.py
File metadata and controls
59 lines (42 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import matplotlib.pyplot as plt
import seaborn as sns
def select_substitution_matrix(integer):
subs_dict = {1:'blosum62.csv',2:'blosum50.csv',3:'pam100.csv',4:'pam250.csv'}
if integer in subs_dict:
return subs_dict[integer]
else:
print('Input error!')
def conv_list2str(list_obj) :
""" Helper function to obtain alignment sequence """
string = ''
return string.join(list_obj)
def plot_align_matrix(M,seq1,seq2,Global):
""" Plot the Global Alignment scores matrix """
fig = plt.figure(figsize=(30,26),dpi=65)
ax = fig.add_axes([0.1,0.1,0.8,0.8])
sns.heatmap(M,linewidth=0.9,ax=ax,annot=True,cmap='magma',fmt='.3g')
if Global == True:
ax.set_title('Global Alignment Score Matrix')
else :
ax.set_title('Local Alignment Score Matrix')
ax.set_xticklabels(['Gap']+[letter for letter in seq2],fontsize=10)
ax.set_xlabel('Sequence 2',fontsize=16)
ax.xaxis.tick_top()
ax.set_yticklabels(['Gap']+[letter for letter in seq1],fontsize=10, rotation=45)
ax.set_ylabel('Sequence 1',fontsize=16)
return ax
def plot_tracer(T,seq1,seq2,Global):
""" Plot the traceback route """
fig = plt.figure(figsize=(30,26))
ax = fig.add_axes([0.1,0.1,0.8,0.8])
sns.heatmap(T,linewidth=0.9,ax=ax, cmap='coolwarm',cbar=False)
if Global == True:
ax.set_title('Global Alignment Traceback')
else :
ax.set_title('Local Alignment Traceback')
ax.set_xticklabels(['Gap']+[letter for letter in seq2],fontsize=10)
ax.set_xlabel('Sequence 2',fontsize=16)
ax.xaxis.tick_top()
ax.set_yticklabels(['Gap']+[letter for letter in seq1],fontsize=10, rotation=45)
ax.set_ylabel('Sequence 1',fontsize=16)
return ax