-
Notifications
You must be signed in to change notification settings - Fork 1
/
rmsd_graph.py
88 lines (78 loc) · 2.84 KB
/
rmsd_graph.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"""RMSD Graph Calculations
Author: Karson Chrispens"""
from pyrosetta import *
from pyrosetta.rosetta.core.scoring import *
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
init()
pdbs = ["1DQJ", "1MHP", "1MLC", "1N8Z", "1VFB", "1YY9", "3GBN",
"4FQY"]
crtsc_scores = []
crtsc_nobb_scores = []
harm_scores = []
unrelaxed_scores = []
no_constraints_scores = []
harm025_scores = []
crtsc_rmsds = []
crtsc_nobb_rmsds = []
harm_rmsds = []
unrelaxed_rmsds = []
no_constraints_rmsds = []
harm025_rmsds = []
sfxn = get_fa_scorefxn()
for pdb in pdbs:
pose = pose_from_pdb(f"./PDBs/{pdb}.pdb")
crtsc = pose_from_pdb(f"./PDBs/{pdb}_crtsc.pdb")
crtsc_nobb = pose_from_pdb(f"./PDBs/{pdb}_clean.pdb")
harm = pose_from_pdb(f"./PDBs/{pdb}_harm.pdb")
unconst = pose_from_pdb(f"./PDBs/{pdb}_unconst.pdb")
harm025 = pose_from_pdb(f"./PDBs/{pdb}_harm_025.pdb")
crtsc_scores.append(sfxn.score(crtsc) / crtsc.total_residue())
crtsc_nobb_scores.append(sfxn.score(crtsc_nobb) /
crtsc_nobb.total_residue())
harm_scores.append(sfxn.score(harm) / harm.total_residue())
unrelaxed_scores.append(sfxn.score(pose) / pose.total_residue())
no_constraints_scores.append(sfxn.score(unconst) / unconst.total_residue())
harm025_scores.append(sfxn.score(harm025) / unconst.total_residue())
crtsc_rmsds.append(all_atom_rmsd(pose, crtsc))
crtsc_nobb_rmsds.append(all_atom_rmsd(pose, crtsc_nobb))
harm_rmsds.append(all_atom_rmsd(pose, harm))
unrelaxed_rmsds.append(0)
no_constraints_rmsds.append(all_atom_rmsd(pose, unconst))
harm025_rmsds.append(all_atom_rmsd(pose, harm025))
per_res_score = pd.DataFrame({
"#PDB": pdbs,
"sidechain_constr": crtsc_nobb_scores,
"constr": crtsc_scores,
"harm": harm_scores,
"unconstr": no_constraints_scores,
"unrelaxed": unrelaxed_scores,
"harm sd 0.25": harm025_scores
})
rmsds = pd.DataFrame({
"#PDB": pdbs,
"sidechain_constr": crtsc_nobb_rmsds,
"constr": crtsc_rmsds,
"harm": harm_rmsds,
"unconstr": no_constraints_rmsds,
"unrelaxed": unrelaxed_rmsds,
"harm sd 0.25": harm025_rmsds
})
df1 = per_res_score.melt(
id_vars=["#PDB"], var_name='Method', value_name='Per Residue Score (REU)')
df2 = rmsds.melt(id_vars=['#PDB'], var_name='Method', value_name='RMSD (Å)')
df1 = df1.set_index(
["#PDB", df1.groupby(["#PDB"]).cumcount()])
df2 = df2.set_index(
["#PDB", df1.groupby(["#PDB"]).cumcount()])
df3 = (pd.concat([df1, df2], axis=1)
.sort_index()
.reset_index())
df3 = df3.T.drop_duplicates().T
print(df3)
plot = sns.scatterplot(x="RMSD (Å)", y="Per Residue Score (REU)",
hue="Method", style="#PDB", data=df3)
plt.legend(bbox_to_anchor=(1, 1), loc='upper left', borderaxespad=0)
plt.savefig("./images/rmsd_plot.png", bbox_inches='tight')