In [11]:
import prody as pd
import numpy as np
from matplotlib import pyplot as plt
from scipy.stats import spearmanr, pearsonr
In [31]:
prot = pd.parsePDB('3q6y')
prot_clear = pd.parsePDB('5RCQ')
prot, prot_clear
@> PDB file is found in working directory (3q6y.pdb.gz).
@> 2482 atoms and 1 coordinate set(s) were parsed in 0.04s.
@> Connecting wwPDB FTP server RCSB PDB (USA).
@> 5rcq downloaded (5rcq.pdb.gz)
@> PDB download via FTP completed (1 downloaded, 0 failed).
@> 2541 atoms and 1 coordinate set(s) were parsed in 0.04s.
Out[31]:
(<AtomGroup: 3q6y (2482 atoms)>, <AtomGroup: 5RCQ (2541 atoms)>)

Задание 1

In [32]:
def get_betas_for_prot(prot):
    all_betas = list()
    for res in prot.iterResidues():
        if 'CA' in res.getNames():
            beta = np.mean(res.getBetas())
            all_betas.append([res, beta])
    all_betas.sort(key=lambda x: x[1])
    return all_betas
In [33]:
betas_prot = get_betas_for_prot(prot)
betas_prot_clear = get_betas_for_prot(prot_clear)
print("Белок с лигандом:")
print(betas_prot[0])
print(betas_prot[-1])

print("Чистый белок:")
print(betas_prot_clear[0])
print(betas_prot_clear[-1])
Белок с лигандом:
[<Residue: GLY 306 from Chain A from 3q6y (4 atoms)>, 6.612500000000001]
[<Residue: ASP 54 from Chain A from 3q6y (5 atoms)>, 59.886]
Чистый белок:
[<Residue: LEU 325 from Chain A from 5RCQ (8 atoms)>, 12.9625]
[<Residue: ASP 81 from Chain A from 5RCQ (8 atoms)>, 34.618750000000006]

Задание 2

In [34]:
prot_mass_center = pd.calcCenter(prot, weights=prot.getMasses())
print("Центр масс белка:", ', '.join(map(lambda x: str(round(x,3)), prot_mass_center)))
Центр масс белка: 4.843, -0.135, 4.693
In [5]:
betas = list()
dists = list()

for res in prot.iterResidues():
    if 'CA' in res.getNames():
        beta = np.mean(res.getBetas())
        betas.append(beta)
        
        res_mass_center = pd.calcCenter(res, weights=res.getMasses())
        dist = pd.calcDistance(res_mass_center, prot_mass_center)
        dists.append(dist)    
In [29]:
fig, ax = plt.subplots()
ax.scatter(dists, betas, s=1)
ax.set_xlabel("Расстояние от центра масс, Å")
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 [9]:
spearmanr(dists, betas)
Out[9]:
SpearmanrResult(correlation=0.5946043738272592, pvalue=1.5123973591121564e-30)
In [12]:
pearsonr(dists, betas)
Out[12]:
(0.42726534921574194, 5.773223051854123e-15)