-
Notifications
You must be signed in to change notification settings - Fork 2
/
fixed_draw.py
35 lines (30 loc) · 1.37 KB
/
fixed_draw.py
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
import matplotlib.pyplot as plt
import draw_rna.draw as d
from draw_rna.draw_utils import seq2col
def draw_struct(seq, secstruct, c=None, line=False, large_mode=False,
cmap='viridis', rotation=0, vmin=None, vmax=None, alpha=None, ax=None, file_name="image1"):
'''
Draw sequence with secondary structure.
Inputs:
c (string or array-like). If string, characters must correspond to colors.
If array-like obj, used as mapping for colormap (provided in cmap), or a string.
line (bool): draw secstruct as line.
large_mode: draw outer loop as straight line.
rotation: rotate molecule (in degrees).
'''
if c is not None:
assert len(c) == len(seq)
if isinstance(c[0], float):
d.draw_rna(seq, secstruct, c, line=line, ext_color_file=True, cmap_name = cmap, vmin=vmin, vmax=vmax,
rotation=rotation, large_mode = large_mode, alpha=alpha, ax=ax)
else:
d.draw_rna(seq, secstruct, c, line=line, cmap_name=cmap, large_mode=large_mode, vmin=vmin, vmax=vmax,
rotation=rotation, alpha=alpha, ax=ax)
else:
d.draw_rna(seq, secstruct, seq2col(seq), line=line, cmap_name = cmap, vmin=vmin, vmax=vmax,
large_mode = large_mode, rotation=rotation, alpha=alpha, ax=ax)
plt.savefig(f"temp/{file_name}.png")
#if ax is None:
#
# plt.show()
#return plt.gca()