In [1]:
import os
import sys
import random
import time
from random import seed, randint
import argparse
import platform
from datetime import datetime
import imp
import numpy as np
import fileinput
from itertools import product
import pandas as pd
from scipy.interpolate import griddata
from scipy.interpolate import interp2d
import seaborn as sns
from os import listdir

import matplotlib.pyplot as plt
import seaborn as sns
from scipy.interpolate import griddata
import matplotlib as mpl
# sys.path.insert(0,'..')
# from notebookFunctions import *
# from .. import notebookFunctions
from Bio.PDB.Polypeptide import one_to_three
from Bio.PDB.Polypeptide import three_to_one
from Bio.PDB.PDBParser import PDBParser
from pyCodeLib import *
# from small_script.myFunctions import *
sys.path.insert(0, "/Users/weilu/openmmawsem")
from helperFunctions.myFunctions import *
from collections import defaultdict
%matplotlib inline
# plt.rcParams['figure.figsize'] = (10,6.180)    #golden ratio
# %matplotlib notebook
%load_ext autoreload
%autoreload 2

In [2]:
plt.rcParams['figure.figsize'] = np.array([16.18033, 10])    #golden ratio
plt.rcParams['figure.facecolor'] = 'w'
plt.rcParams['figure.dpi'] = 100
plt.rcParams.update({'font.size': 22})

In [3]:
# pre = "/Users/weilu/Research/server_backup/feb_2019/jan_optimization/gammas/"
# pre = "/Users/weilu/Research/server/april_2019/optimization_test/gammas/"
pre = "/Users/weilu/Research/server/sep_2019/peptide_optimization_trial_2/optimization/gammas/"
# pp = "cath-dataset-nonredundant-S20Clean_phi_pairwise_contact_well4.5_6.5_5.0_10phi_density_mediated_contact_well6.5_9.5_5.0_10_2.6_7.0"
# pp = "proteins_name_list_phi_pairwise_contact_well4.5_6.5_5.0_10phi_density_mediated_contact_well6.5_9.5_5.0_10_2.6_7.0phi_burial_well4.0"
pp = f"protein_list_phi_pairwise_contact_well4.5_6.5_5.0_10phi_density_mediated_contact_well6.5_9.5_5.0_10_2.6_7.0phi_burial_well4.0"

A_name = pp + "_A"
B_name = pp + "_B"
B_filtered_name = pp + "_B_filtered"
P_name = pp + "_P"
Gamma_name = pp + "_gamma"
Gamma_filtered_name = pp + "_gamma_filtered"
Lamb_name = pp + "_lamb"
Lamb_filtered_name = pp + "_lamb_filtered"

A = np.loadtxt(pre+A_name)
B = np.loadtxt(pre+B_name)
B_filtered = np.loadtxt(pre+B_filtered_name, dtype=complex, converters={
                           0: lambda s: complex(s.decode().replace('+-', '-'))})
Gamma = np.loadtxt(pre+Gamma_name)
Gamma_filtered = np.loadtxt(pre+Gamma_filtered_name, dtype=complex, converters={
                           0: lambda s: complex(s.decode().replace('+-', '-'))})
Lamb = np.loadtxt(pre+Lamb_name, dtype=complex, converters={
                           0: lambda s: complex(s.decode().replace('+-', '-'))})
Lamb_filtered = np.loadtxt(pre+Lamb_filtered_name, dtype=complex, converters={
                           0: lambda s: complex(s.decode().replace('+-', '-'))})

half_B_name = pp + "_half_B"
half_B = np.loadtxt(pre+half_B_name)
other_half_B_name = pp + "_other_half_B"
other_half_B = np.loadtxt(pre+other_half_B_name)
std_half_B_name = pp + "_std_half_B"
std_half_B = np.loadtxt(pre+std_half_B_name)


# pre = "/Users/weilu/Research/server/april_2019/"
location = pre + "../../phis/protein_list_phi_pairwise_contact_well4.5_6.5_5.0_10phi_density_mediated_contact_well6.5_9.5_5.0_10_2.6_7.0phi_burial_well4.0_phi_decoy_summary.txt"
A_prime = np.loadtxt(location)

In [4]:
plt.plot(Lamb)
plt.yscale("log")


/Users/weilu/anaconda3/envs/py36/lib/python3.6/site-packages/numpy/core/numeric.py:501: ComplexWarning: Casting complex values to real discards the imaginary part
  return array(a, dtype, copy=False, order=order)

In [10]:
lamb, P = np.linalg.eig(B)
lamb, P = sort_eigenvalues_and_eigenvectors(lamb, P)
filtered_lamb = np.copy(lamb)
cutoff_mode = 400
filtered_B_inv, filtered_lamb, P = get_filtered_B_inv_lambda_and_P(filtered_lamb, 
                                                                   cutoff_mode, P)
filtered_gamma = np.dot(filtered_B_inv, A)
filtered_B = np.linalg.inv(filtered_B_inv)
plot_contact_well(filtered_gamma[:210], inferBound=True)
plot_contact_well(filtered_gamma[210:420], inferBound=True)
plot_contact_well(filtered_gamma[420:], inferBound=True)



In [6]:
# maximum difference between loaded and computed is 1e-5.
max(lamb-Lamb)


Out[6]:
(1.5403101476740844e-05+0j)

In [11]:
save_gamma_pre = "/Users/weilu/Research/server/sep_2019/saved_gammas/"
np.savetxt(f"{save_gamma_pre}/trial_2_cutoff400", filtered_gamma)

In [107]:
os.chdir('/Users/weilu/opt/notebook/Optimization')


Out[107]:
'/Users/weilu/opt/notebook/Optimization'

In [14]:
os.chdir("/Users/weilu/Research/server/sep_2019/peptide_optimization_trial_2/optimization/")
# gamma_file_name = "gamma_iter1_combined_mar06.dat"
gamma_file_name = "/Users/weilu/Research/server/sep_2019/peptide_optimization/saved_gammas/cutoff100"
data = validate_hamiltonian_wei("phi_list.txt", "protein_list_small", gamma_file_name, "shuffle", 1000, mode=0)
data


210
420
60
0 3.8340531662409814
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
Out[14]:
Protein Z_scores E_native E_mgs Std_mg
0 1BD2_1 3.834053 -1091.522839 -9.338132 282.256051
1 6BJ8_1 4.115412 -2110.009245 -812.790146 315.210016
2 2JCC_1 3.745693 -922.515254 149.727164 286.260117
3 1AO7_1 3.806062 -1753.590663 -575.699559 309.477634
4 1LP9_1 3.944508 -920.931994 163.036214 274.804438
5 3QDJ_1 4.085536 -1782.495837 -490.495793 316.237590
6 3GSN_1 3.709800 -1900.434238 -753.721660 309.103604
7 1QRN_1 4.164756 -1712.503201 -527.714693 284.479679
8 3PWP_1 3.889196 -1460.943615 -319.651538 293.451918
9 5W1W_1 3.914030 -700.985851 428.268456 288.514471
10 1QSE_1 3.732709 -1716.888053 -616.997651 294.662787
11 4EUP_1 3.768051 -1483.163001 -360.029803 298.067414
12 5TEZ_1 3.642150 -1519.094431 -585.955647 256.205452
13 3D39_1 3.430565 -1648.903714 -582.649212 310.810205
14 6EQA_1 3.060139 -1403.253274 -398.982295 328.178211
15 2BNR_1 3.874194 -1704.803904 -577.879936 290.879614
16 6BJ2_1 3.849727 -1664.218888 -458.193805 313.275509
17 6BJ3_1 4.147049 -2014.495647 -825.600001 286.684707
18 5NME_1 3.448995 -1401.199554 -315.630916 314.749227
19 5MEN_1 3.883324 -1612.198812 -556.388894 271.883047
20 2VLJ_1 3.556692 -1174.475465 -143.948172 289.743225
21 2VLK_1 4.097878 -1391.214148 -203.154042 289.920829
22 2J8U_1 3.867065 -905.136654 164.735010 276.662461
23 2GJ6_1 3.879977 -1928.417980 -706.808902 314.849543
24 1OGA_1 4.578397 -1432.955561 -157.199781 278.646829
25 2F54_1 3.943001 -1797.814121 -683.673024 282.561697
26 5D2L_1 3.600108 -1346.186653 -264.050877 300.584287
27 2F53_1 3.459582 -1368.420767 -329.770020 300.224321
28 3QEQ_1 3.377197 -1726.197571 -613.399463 329.503471
29 1QSF_1 3.594095 -1594.671282 -517.028259 299.837071
30 2UWE_1 2.841172 -699.203977 91.916879 278.448733
31 5EUO_1 3.880985 -1474.338340 -296.470990 303.497025
32 3H9S_1 3.958820 -1884.030529 -679.597102 304.240492
33 3D3V_1 3.360240 -1713.535477 -624.402686 324.123553
34 2BNQ_1 5.651049 -3008.457623 -1266.073497 308.329333
35 4FTV_1 3.749797 -1490.902546 -412.216998 287.665028

In [15]:
os.chdir("/Users/weilu/Research/server/sep_2019/peptide_optimization_trial_2/optimization/")
# gamma_file_name = "gamma_iter1_combined_mar06.dat"
gamma_file_name = "/Users/weilu/Research/server/sep_2019/saved_gammas/trial_2_cutoff400"
data = validate_hamiltonian_wei("phi_list.txt", "protein_list_small", gamma_file_name, "shuffle", 1000, mode=0)
data


210
420
60
0 22.100828450470825
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
Out[15]:
Protein Z_scores E_native E_mgs Std_mg
0 1BD2_1 22.100828 -425.944208 -19.039485 18.411288
1 6BJ8_1 18.234455 -583.705104 -187.090418 21.750838
2 2JCC_1 23.091225 -609.090184 -224.970073 16.634896
3 1AO7_1 21.665218 -552.214494 -167.905076 17.738544
4 1LP9_1 22.983383 -523.716471 -155.334523 16.028187
5 3QDJ_1 19.865607 -580.766858 -163.052759 21.026999
6 3GSN_1 22.184385 -410.258265 -61.283660 15.730641
7 1QRN_1 27.800921 -614.034462 -215.165011 14.347347
8 3PWP_1 27.572172 -611.500391 -211.485674 14.507915
9 5W1W_1 20.096043 -445.859601 -37.667697 20.312054
10 1QSE_1 23.340974 -603.070419 -186.338174 17.854107
11 4EUP_1 18.239404 -466.982175 -106.293743 19.775231
12 5TEZ_1 11.864662 -252.121139 -68.540749 15.472872
13 3D39_1 22.409665 -561.211537 -161.282695 17.846266
14 6EQA_1 14.613196 -414.766125 -60.787924 24.223189
15 2BNR_1 24.468354 -542.998945 -150.044647 16.059695
16 6BJ2_1 30.525660 -526.321122 -114.284889 13.498029
17 6BJ3_1 27.772542 -596.154343 -183.180723 14.869853
18 5NME_1 29.512753 -608.340154 -181.042832 14.478396
19 5MEN_1 27.623379 -505.243392 -146.431711 12.989421
20 2VLJ_1 20.092340 -487.017981 -112.575079 18.636102
21 2VLK_1 28.021486 -503.976124 -86.384478 14.902552
22 2J8U_1 22.794303 -505.975871 -148.746003 15.671893
23 2GJ6_1 23.066179 -646.109938 -217.962704 18.561689
24 1OGA_1 25.588701 -477.243840 -72.900548 15.801634
25 2F54_1 24.805781 -562.744899 -197.087611 14.740809
26 5D2L_1 19.102887 -403.100802 -28.129608 19.629032
27 2F53_1 21.095925 -508.036797 -119.429501 18.420965
28 3QEQ_1 20.391355 -463.013024 -32.820730 21.096797
29 1QSF_1 22.186445 -506.295432 -156.327369 15.773959
30 2UWE_1 19.715181 -445.946516 -128.822900 16.085250
31 5EUO_1 25.187256 -427.553686 0.675697 17.001827
32 3H9S_1 21.062154 -644.985289 -211.998716 20.557564
33 3D3V_1 24.753662 -767.277656 -293.136232 19.154395
34 2BNQ_1 8.525074 -378.045961 -223.890146 18.082637
35 4FTV_1 20.488735 -545.045406 -156.076909 18.984506

In [16]:
os.chdir("/Users/weilu/Research/server/sep_2019/peptide_optimization_trial_2/optimization/")
# gamma_file_name = "gamma_iter1_combined_mar06.dat"
# gamma_file_name = "/Users/weilu/Research/server/sep_2019/peptide_optimization/saved_gammas/cutoff100"
gamma_file_name = "/Users/weilu/Research/server/sep_2019/saved_gammas/original_gamma"

data = validate_hamiltonian_wei("phi_list.txt", "protein_list_small", gamma_file_name, "shuffle", 1000, mode=0)
data


210
420
60
0 0.9003155450024992
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
Out[16]:
Protein Z_scores E_native E_mgs Std_mg
0 1BD2_1 0.900316 -565.363569 -558.334725 7.807089
1 6BJ8_1 0.340620 -559.377083 -556.341055 8.913235
2 2JCC_1 0.151485 -578.632012 -577.373781 8.305978
3 1AO7_1 0.549733 -554.882868 -549.744350 9.347298
4 1LP9_1 0.018086 -572.456799 -572.294553 8.970942
5 3QDJ_1 0.571400 -548.835394 -544.666126 7.296581
6 3GSN_1 0.721878 -546.292261 -539.487997 9.425782
7 1QRN_1 0.039428 -555.365484 -555.071793 7.448888
8 3PWP_1 0.253560 -570.922191 -568.716016 8.700786
9 5W1W_1 0.751747 -563.412353 -557.502728 7.861194
10 1QSE_1 0.578690 -559.544033 -554.102176 9.403750
11 4EUP_1 0.015861 -563.958000 -563.817637 8.849680
12 5TEZ_1 0.454085 -579.688507 -576.275882 7.515384
13 3D39_1 0.913302 -569.280411 -560.054925 10.101248
14 6EQA_1 0.607607 -559.131031 -553.943662 8.537371
15 2BNR_1 0.702593 -570.397373 -563.957349 9.166085
16 6BJ2_1 0.468335 -556.645981 -552.711043 8.401973
17 6BJ3_1 -0.096069 -563.400937 -564.108460 7.364763
18 5NME_1 0.644450 -558.065141 -552.460955 8.696081
19 5MEN_1 0.314084 -550.918059 -548.400112 8.016793
20 2VLJ_1 0.322381 -542.011146 -539.421195 8.033830
21 2VLK_1 0.350059 -542.555997 -539.493606 8.748207
22 2J8U_1 -0.288170 -574.485025 -576.761867 7.901027
23 2GJ6_1 0.356224 -570.758928 -567.118995 10.218105
24 1OGA_1 0.236676 -552.479891 -550.437823 8.628107
25 2F54_1 0.103204 -548.348960 -547.472613 8.491401
26 5D2L_1 0.565962 -558.635666 -553.753495 8.626318
27 2F53_1 0.606024 -562.123693 -556.408688 9.430324
28 3QEQ_1 0.621955 -551.620007 -545.238092 10.261056
29 1QSF_1 0.481709 -566.452834 -562.124111 8.986185
30 2UWE_1 0.876791 -586.309550 -579.238061 8.065195
31 5EUO_1 0.136994 -550.526436 -549.302675 8.932927
32 3H9S_1 0.546885 -555.893794 -551.095308 8.774218
33 3D3V_1 0.610284 -542.475441 -536.054752 10.520817
34 2BNQ_1 0.285020 -563.839068 -561.332622 8.793945
35 4FTV_1 -0.401177 -539.158902 -542.377129 8.021968

In [17]:
gamma_file_name = "/Users/weilu/Research/server/sep_2019/peptide_optimization/saved_gammas/original_gamma"
original_gamma = np.loadtxt(gamma_file_name)

In [18]:
np.dot(A_prime, original_gamma)


Out[18]:
-559.5053481482374

In [19]:
# we want to impose additional contraint so that A' * gamma = constnat.(-562.23)
c = np.dot(A_prime, original_gamma)
B_inv = filtered_B_inv
lambda_2 = (A_prime.dot(B_inv).dot(A) - c) / (A_prime.dot(B_inv).dot(A_prime) )
gamma_new = B_inv.dot(A-A_prime*lambda_2)

In [20]:
np.dot(A_prime, gamma_new)


Out[20]:
-559.5053481482375

In [21]:
plot_contact_well(filtered_gamma[:210], inferBound=True)
plot_contact_well(filtered_gamma[210:420], inferBound=True)
plot_contact_well(filtered_gamma[420:], inferBound=True)



In [22]:
# impose A'gamma
save_gamma_pre = "/Users/weilu/Research/server/sep_2019/saved_gammas/"
np.savetxt(f"{save_gamma_pre}/trial_2_cutoff400_impose_Aprime_constraint", gamma_new)

In [23]:
os.chdir("/Users/weilu/Research/server/sep_2019/peptide_optimization_trial_2/optimization/")
# gamma_file_name = "gamma_iter1_combined_mar06.dat"
# gamma_file_name = "/Users/weilu/Research/server/sep_2019/peptide_optimization/saved_gammas/cutoff100"
gamma_file_name = "/Users/weilu/Research/server/sep_2019/saved_gammas/trial_2_cutoff400_impose_Aprime_constraint"

data = validate_hamiltonian_wei("phi_list.txt", "protein_list_small", gamma_file_name, "shuffle", 1000, mode=0)
data


210
420
60
0 22.073925622758694
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
Out[23]:
Protein Z_scores E_native E_mgs Std_mg
0 1BD2_1 22.073926 -846.030533 -438.667301 18.454499
1 6BJ8_1 18.269852 -1004.324453 -607.371078 21.727235
2 2JCC_1 23.133333 -1026.405787 -641.641369 16.632468
3 1AO7_1 21.629690 -971.717108 -586.869112 17.792580
4 1LP9_1 22.944863 -936.668865 -567.127738 16.105615
5 3QDJ_1 19.845226 -1007.446393 -588.950991 21.087964
6 3GSN_1 22.129463 -837.829729 -487.799204 15.817398
7 1QRN_1 27.795110 -1026.020277 -627.234270 14.347344
8 3PWP_1 27.632642 -1032.733486 -632.118083 14.497904
9 5W1W_1 20.072665 -856.575032 -448.143370 20.347655
10 1QSE_1 23.371117 -1018.295010 -600.899603 17.859455
11 4EUP_1 18.325557 -890.530313 -528.297996 19.766511
12 5TEZ_1 11.855886 -687.641483 -503.628007 15.520855
13 3D39_1 22.346258 -980.784498 -580.562575 17.910020
14 6EQA_1 14.594050 -829.305617 -474.451029 24.315019
15 2BNR_1 24.357313 -963.355060 -569.978428 16.150247
16 6BJ2_1 30.537376 -946.093890 -534.483718 13.478898
17 6BJ3_1 27.856648 -1006.868700 -593.676790 14.832794
18 5NME_1 29.386987 -1015.480976 -588.523592 14.528791
19 5MEN_1 27.623747 -913.184944 -554.009438 13.002418
20 2VLJ_1 20.065531 -910.995357 -537.330064 18.622248
21 2VLK_1 28.080716 -932.193789 -513.992499 14.892828
22 2J8U_1 22.787025 -915.677426 -558.047803 15.694441
23 2GJ6_1 23.161212 -1075.112165 -646.521563 18.504671
24 1OGA_1 25.406534 -905.543221 -501.006555 15.922544
25 2F54_1 24.858985 -986.202557 -619.818468 14.738497
26 5D2L_1 19.145154 -813.804751 -438.401893 19.608244
27 2F53_1 21.067683 -922.057320 -533.515113 18.442570
28 3QEQ_1 20.443343 -879.863290 -449.370077 21.057868
29 1QSF_1 22.192253 -925.050350 -575.433941 15.753985
30 2UWE_1 19.732309 -858.644498 -541.158389 16.089659
31 5EUO_1 25.208530 -858.235951 -429.634635 17.002234
32 3H9S_1 21.073720 -1067.144269 -634.043254 20.551712
33 3D3V_1 24.720721 -1191.861747 -717.461272 19.190398
34 2BNQ_1 8.570268 -819.975942 -664.848094 18.100699
35 4FTV_1 20.439400 -966.238074 -577.156020 19.035884

In [26]:
# mix gammas so that we don't overfitting too much.
gamma_file_name = "/Users/weilu/Research/server/sep_2019/saved_gammas/original_gamma"
original_gamma = np.loadtxt(gamma_file_name)
gamma_file_name = "/Users/weilu/Research/server/sep_2019/saved_gammas/trial_2_cutoff400_impose_Aprime_constraint"
gamma_new = np.loadtxt(gamma_file_name)

alpha = 0.9
alpha_percent = int(alpha*100)
mixed_gamma = alpha*original_gamma + (1-alpha)*gamma_new
save_gamma_pre = "/Users/weilu/Research/server/sep_2019/saved_gammas/"
np.savetxt(f"{save_gamma_pre}/trial_2_mixed_original_and_cutoff400_impose_Aprime_constraint_{alpha_percent}", mixed_gamma)

In [25]:
os.chdir("/Users/weilu/Research/server/sep_2019/peptide_optimization_trial_2/optimization/")
# gamma_file_name = "gamma_iter1_combined_mar06.dat"
# gamma_file_name = "/Users/weilu/Research/server/sep_2019/peptide_optimization/saved_gammas/cutoff100"
gamma_file_name = "/Users/weilu/Research/server/sep_2019/saved_gammas/trial_2_mixed_original_and_cutoff400_impose_Aprime_constraint_90"

data = validate_hamiltonian_wei("phi_list.txt", "protein_list_small", gamma_file_name, "shuffle", 1000, mode=0)
data


210
420
60
0 3.61317979615153
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
Out[25]:
Protein Z_scores E_native E_mgs Std_mg
0 1BD2_1 3.613180 -579.396917 -552.351354 7.485252
1 6BJ8_1 2.699095 -581.624451 -558.892556 8.422044
2 2JCC_1 2.582660 -601.020701 -580.587160 7.911820
3 1AO7_1 2.728040 -575.724580 -551.600588 8.842975
4 1LP9_1 2.213663 -590.667403 -572.036213 8.416452
5 3QDJ_1 3.590370 -571.765944 -546.880369 6.931201
6 3GSN_1 2.660365 -560.869135 -536.903557 9.008381
7 1QRN_1 2.839146 -578.898224 -558.679917 7.121263
8 3PWP_1 2.654854 -594.012756 -571.886119 8.334407
9 5W1W_1 3.460066 -578.070487 -552.034760 7.524634
10 1QSE_1 2.924239 -582.481582 -556.442048 8.904721
11 4EUP_1 2.148802 -580.286616 -562.041655 8.490758
12 5TEZ_1 1.749300 -585.086156 -572.643489 7.112940
13 3D39_1 2.981009 -589.855615 -561.080308 9.652874
14 6EQA_1 2.772029 -572.639760 -549.969031 8.178387
15 2BNR_1 2.898548 -590.045257 -564.258403 8.896472
16 6BJ2_1 3.051761 -576.118376 -551.799677 7.968743
17 6BJ3_1 2.817729 -585.574325 -565.586877 7.093460
18 5NME_1 3.195944 -580.935932 -554.264087 8.345530
19 5MEN_1 2.629798 -569.031403 -548.680578 7.738549
20 2VLJ_1 2.720131 -560.460357 -539.316638 7.773052
21 2VLK_1 2.829503 -562.037886 -538.218551 8.418204
22 2J8U_1 2.093933 -591.544645 -575.826164 7.506677
23 2GJ6_1 2.567402 -595.976589 -571.089123 9.693639
24 1OGA_1 2.678189 -570.133057 -547.966259 8.276785
25 2F54_1 2.359889 -570.241639 -551.089906 8.115524
26 5D2L_1 2.818430 -571.394120 -547.985915 8.305406
27 2F53_1 2.706106 -580.120374 -555.264009 9.185288
28 3QEQ_1 2.789457 -568.032172 -540.444691 9.889911
29 1QSF_1 2.525277 -584.382710 -562.789602 8.550789
30 2UWE_1 2.928198 -599.926297 -577.334078 7.715401
31 5EUO_1 2.611929 -565.911912 -543.319273 8.649790
32 3H9S_1 3.121284 -581.456318 -555.242705 8.398342
33 3D3V_1 2.983337 -574.944756 -545.125078 9.995410
34 2BNQ_1 1.183088 -576.645912 -566.508396 8.568690
35 4FTV_1 2.155122 -560.512860 -544.116074 7.608287

In [27]:
os.chdir("/Users/weilu/Research/server/sep_2019/peptide_optimization_trial_2/optimization/")
# gamma_file_name = "gamma_iter1_combined_mar06.dat"
# gamma_file_name = "/Users/weilu/Research/server/sep_2019/peptide_optimization/saved_gammas/cutoff100"
gamma_file_name = "/Users/weilu/Research/server/sep_2019/saved_gammas/trial_2_mixed_original_and_cutoff400_impose_Aprime_constraint_90"

data = validate_hamiltonian_wei("phi_list.txt", "protein_list_small", gamma_file_name, "shuffle", 1000, mode=0)
data


210
420
60
0 6.4585874724654575
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
210
420
60
Out[27]:
Protein Z_scores E_native E_mgs Std_mg
0 1BD2_1 6.458587 -593.430265 -546.367982 7.286776
1 6BJ8_1 5.247254 -603.871820 -561.444057 8.085708
2 2JCC_1 5.202229 -623.409390 -583.800540 7.613823
3 1AO7_1 5.109089 -596.566292 -553.456826 8.437798
4 1LP9_1 4.668548 -608.878006 -571.777872 7.946825
5 3QDJ_1 6.764150 -594.696494 -549.094613 6.741702
6 3GSN_1 4.745268 -575.446008 -534.319118 8.666926
7 1QRN_1 5.841006 -602.430963 -562.288040 6.872604
8 3PWP_1 5.231997 -617.103320 -575.056223 8.036529
9 5W1W_1 6.291112 -592.728621 -546.566792 7.337627
10 1QSE_1 5.483596 -605.419130 -558.781919 8.504859
11 4EUP_1 4.402582 -596.615231 -560.265673 8.256418
12 5TEZ_1 3.155803 -590.483805 -569.011095 6.804199
13 3D39_1 5.198826 -610.430820 -562.105690 9.295393
14 6EQA_1 5.009679 -586.148490 -545.994399 8.015301
15 2BNR_1 5.186734 -609.693141 -564.559457 8.701754
16 6BJ2_1 5.882931 -595.590772 -550.888310 7.598672
17 6BJ3_1 5.891674 -607.747713 -567.065293 6.905070
18 5NME_1 5.920641 -603.806724 -556.067219 8.063232
19 5MEN_1 5.079241 -587.144747 -548.961045 7.517600
20 2VLJ_1 5.202782 -578.909567 -539.212082 7.630050
21 2VLK_1 5.463745 -581.519776 -536.943496 8.158559
22 2J8U_1 4.680595 -608.604265 -574.890461 7.202888
23 2GJ6_1 4.978468 -621.194251 -575.059252 9.266908
24 1OGA_1 5.280923 -587.786224 -545.494696 8.008359
25 2F54_1 4.790465 -592.134319 -554.707199 7.812837
26 5D2L_1 5.171549 -584.152575 -542.218335 8.108643
27 2F53_1 4.870324 -598.117056 -554.119330 9.033840
28 3QEQ_1 5.062370 -584.444336 -535.651290 9.638381
29 1QSF_1 4.741348 -602.312586 -563.455094 8.195453
30 2UWE_1 5.110947 -613.543044 -575.430094 7.457122
31 5EUO_1 5.200232 -581.297388 -537.335871 8.453760
32 3H9S_1 5.837334 -607.018842 -559.390102 8.159331
33 3D3V_1 5.559947 -607.414072 -554.195404 9.571794
34 2BNQ_1 2.105181 -589.452756 -571.684169 8.440409
35 4FTV_1 4.915665 -581.866819 -545.855018 7.325927

In [ ]: