-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPAE_plotter.py
More file actions
executable file
·52 lines (40 loc) · 1.43 KB
/
PAE_plotter.py
File metadata and controls
executable file
·52 lines (40 loc) · 1.43 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
#!/usr/bin/env python3
"""
Plot PAE from alphafold .json files
"""
import json
import matplotlib.pyplot as plt
from pathlib import Path
path = Path(".")
for entry in path.iterdir():
if entry.is_file():
with entry.open("r") as f:
data = json.load(f)
# pae = data["predicted_aligned_error"]
pae = data["pae"]
# set subplots
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
# autocomplete does not work with this shortened syntax:
# fig, ax = plt.subplots()
# create heatmap
im = ax.imshow(pae, cmap="Greens_r", vmin=0, aspect="equal")
# configure colour bar
fig.colorbar(im, ax=ax, label="Predicted Aligned Error (Å)")
# labels
ax.set_xlabel("Scored residue")
ax.set_ylabel("Aligned residue")
# move x axis to top
ax.tick_params(top=True, labeltop=True, bottom=False, labelbottom=False)
ax.xaxis.set_label_position("top")
# make tick numbers equal on each axis
ax.set_xticks(range(0, len(pae), 500))
ax.set_yticks(range(0, len(pae), 500))
# ax.set_xticks(range(0, len(pae), len(pae) - 1))
# ax.set_yticks(range(0, len(pae), len(pae) - 1))
# ax.set_xticks([])
# ax.set_yticks([])
# saving figures
plt.savefig(f"./PAE_plots/{entry}.png", format="png", dpi=300, transparent=True)
plt.close()
# plt.show()