Задание 2. RMSF и B-фактор

In [1]:
import prody as pd
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import spearmanr, pearsonr

nmr = pd.parsePDB('1g90')
rsa = pd.parsePDB('1bxw')
@> PDB file is found in working directory (1g90.pdb.gz).
@> 2610 atoms and 10 coordinate set(s) were parsed in 0.14s.
@> PDB file is found in working directory (1bxw.pdb).
@> 1390 atoms and 1 coordinate set(s) were parsed in 0.04s.
In [2]:
nmr_residues = list(nmr.iterResidues())
rsa_residues = list(rsa.iterResidues())[1:]

nmr_filtered = list()
rsa_filtered = list()

for n, r in zip(nmr_residues, rsa_residues):
    if str(n) == str(r):
        nmr_filtered.append(n)
        rsa_filtered.append(r)
    else:
        print(n, r)
PHE 15 TRP 15
PHE 23 LEU 23
GLN 34 LYS 34
PHE 57 TRP 57
PHE 102 TRP 102
LYS 107 TYR 107
PHE 143 TRP 143
GLN 172 C8E 172
GLY 173 HOH 173
GLU 174 HOH 174
ALA 175 HOH 175
ALA 176 HOH 176
In [3]:
RMSFs = [np.mean(pd.calcRMSF(res)) for res in nmr_filtered]
betas = [np.mean(res.getBetas()) for res in rsa_filtered]
In [4]:
fig, ax = plt.subplots()
ax.scatter(RMSFs, betas, s=1)
ax.set_xlabel("RMSF")
ax.set_ylabel("B-фактор")
#ax.set_ylim([5,40])
fig.show()
/usr/lib/python3/dist-packages/ipykernel_launcher.py:6: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.
  
In [5]:
RMSFs_filtered = list()
betas_filtered = list()

for r, b in zip(RMSFs, betas):
    if b != 20:
        RMSFs_filtered.append(r)
        betas_filtered.append(b)
In [6]:
fig, ax = plt.subplots()
ax.scatter(RMSFs_filtered, betas_filtered, s=1)
ax.set_xlabel("RMSF")
ax.set_ylabel("B-фактор")
fig.show()
/usr/lib/python3/dist-packages/ipykernel_launcher.py:5: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.
  """
In [7]:
spearmanr(RMSFs_filtered, betas_filtered)
Out[7]:
SpearmanrResult(correlation=0.8213130765947666, pvalue=3.4693934476226695e-36)
In [8]:
pearsonr(RMSFs_filtered, betas_filtered)
Out[8]:
(0.7810213153251039, 1.2661332848663587e-30)
In [9]:
fig, ax = plt.subplots()
ax.scatter(RMSFs_filtered, betas_filtered, s=1)
ax.set_xlabel("RMSF")
ax.set_ylabel("B-фактор")
ax.set_ylim([20,80])
ax.set_xlim([0,4])
fig.show()
/usr/lib/python3/dist-packages/ipykernel_launcher.py:7: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.
  import sys