-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_rmsf.py
executable file
·60 lines (51 loc) · 2.45 KB
/
plot_rmsf.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
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import MDAnalysis as mda
from MDAnalysis.analysis import rms, align
import argparse
def main():
parser = argparse.ArgumentParser(description='')
parser.add_argument('-sys', '--system', type=str, required=True, help='')
args = parser.parse_args()
system = args.system
sns.set_theme()
holo = mda.Universe('ABL1_cidi_AF_superposed_2f4j_lig_xtalwat_prep.prmtop', 'ABL1_cidi_AF_superposed_2f4j_lig_xtalwat_prep_prod.nc')
apo = mda.Universe('../ABL1_cidi_AF_superposed_apo_prep.prmtop', '../ABL1_cidi_AF_superposed_apo_prep_prod.nc')
ref = mda.Universe('ABL1_cidi_AF_superposed_2f4j_lig_xtalwat_prep.prmtop', 'ABL1_cidi_AF_superposed_2f4j_lig_xtalwat_prep.inpcrd')
# Compute rmsf
protein = 'protein'
aligner = align.AlignTraj(holo, ref,
select='not resname ACE and not resname NME and protein and name CA',
in_memory=True).run()
c_alphas = holo.select_atoms('not resname ACE and not resname NME and protein and name CA')
R_holo = rms.RMSF(c_alphas).run()
aligner = align.AlignTraj(apo, ref,
select='not resname ACE and not resname NME and protein and name CA',
in_memory=True).run()
c_alphas = apo.select_atoms('not resname ACE and not resname NME and protein and name CA')
R_apo = rms.RMSF(c_alphas).run()
# Adjust the residue numbering
resids = c_alphas.resids+240
df = pd.DataFrame()
df['RMSF'] = np.concatenate((R_holo.results.rmsf,R_apo.results.rmsf))
apo_label = ['ABL1 AF2 Apo']*len(R_apo.results.rmsf)
holo_label = ['ABL1 AF2 Holo']*len(R_holo.results.rmsf)
df['System'] = holo_label + apo_label
df['Resnum'] = np.concatenate((resids, resids))
df.to_pickle('ABL1_cidi_AF_RMSF.pkl')
# plot
plt.title('ABL1 AF2 MD simulations backbone RMSF')
sns.lineplot(data=df, x='Resnum', y='RMSF', hue='System')
plt.xlabel('Residue number')
plt.ylabel('RMSF ($\AA$)')
plt.savefig(system+'_rmsf.png')
# make pdb with rmsf at b-factor for rendering
holo.add_TopologyAttr('tempfactors') # add empty attribute for all atoms
protein = holo.select_atoms('protein') # select protein atoms
for residue, r_value in zip(protein.residues, R_holo.rmsf):
residue.atoms.tempfactors = r_value
holo.atoms.write('rmsf_tempfactors.pdb')
if __name__ == '__main__':
main()