Custom Energy Function

[1]:
import chilife as xl
import pickle
import matplotlib.pyplot as plt
import numpy as np
plt.style.use('chiLife')
C:\Program Files\Python310\lib\site-packages\tqdm\auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
C:\Program Files\Python310\lib\site-packages\Bio\pairwise2.py:278: BiopythonDeprecationWarning: Bio.pairwise2 has been deprecated, and we intend to remove it in a future release of Biopython. As an alternative, please consider using Bio.Align.PairwiseAligner as a replacement, and contact the Biopython developers if you still need the Bio.pairwise2 module.
  warnings.warn(
[2]:
with open('R1_Data.pkl', 'rb') as f:
    data = pickle.load(f)
omp = xl.fetch('1omp')
anf = xl.fetch('1anf')
[3]:
def my_sfxn(rotlib):
    weight = 0.078
    f = 0.94
    lj_E = xl.get_lj_energy(rotlib, forgive=f)
    SASA = rotlib.get_sasa()
    return lj_E - weight * SASA

SL1 = xl.SpinLabel('R1M', 41, anf, energy_func=my_sfxn)
SL2 = xl.SpinLabel('R1M', 238, anf, energy_func=my_sfxn)
SL2 = xl.SpinLabel('R1M', 345, anf, energy_func=my_sfxn)
[6]:
labels = ('Custom Score Function', 'Default Score Function')
fig, axs = plt.subplots(2)
for ax, cstruct in zip(axs, (("41", "238", 'Holo'), ("238", "345", 'Holo'))):
    exp = data[cstruct]
    ax.plot(exp.r, exp.P, color='k', label='Exp')
    ax.fill_between(exp.r, *exp.P95, color='k', alpha=0.5, label='95% CI')

    for i, efunc in enumerate((my_sfxn, xl.get_lj_scwrl)):
        SL1 = xl.SpinLabel('R1M', cstruct[0], anf, energy_func = efunc)
        SL2 = xl.SpinLabel('R1M', cstruct[1], anf, energy_func = efunc)
        dd = xl.distance_distribution(SL1, SL2, exp.r)
        ax.plot(exp.r, dd, label=labels[i])

    ax.set_yticks([])
    ax.set_xlim(15, 65)
    for spine in ['left', 'top', 'right']:
        ax.spines[spine].set_visible(False)

axs[0].set_title('MBP D41R1 S238R1 Holo')
axs[1].set_title('MBP S238R1 T345R1 Holo')

axs[0].legend(frameon=False)
axs[1].set_xlabel(r'distance ($\rm\AA$)')

plt.tight_layout()
plt.show()



../_images/gallery_07-Custom_Energy_Function_4_0.png