import prody as pd
import numpy as np
from matplotlib import pyplot as plt
from scipy.stats import spearmanr, pearsonr
prot = pd.parsePDB('3q6y')
prot_clear = pd.parsePDB('5RCQ')
prot, prot_clear
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
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])
prot_mass_center = pd.calcCenter(prot, weights=prot.getMasses())
print("Центр масс белка:", ', '.join(map(lambda x: str(round(x,3)), prot_mass_center)))
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)
fig, ax = plt.subplots()
ax.scatter(dists, betas, s=1)
ax.set_xlabel("Расстояние от центра масс, Å")
ax.set_ylabel("Средний B-фактор остатка")
ax.set_ylim([5,40])
fig.show()
spearmanr(dists, betas)
pearsonr(dists, betas)