In [1]:
from pyCodeLib import *
import warnings
import glob
import re
import numpy as np
warnings.filterwarnings('ignore')
# sys.path.insert(0, MYHOME)
%load_ext autoreload
%autoreload 2
In [51]:
pre = "/Users/weilu/Research/server/jan_2019/optimization/gammas_dec30/"
gamma_file = "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_gamma"
gamma_location = pre + gamma_file
gamma = np.loadtxt(gamma_location)
plot_contact_well(gamma[:210], inferBound=True)
In [53]:
plot_contact_well(gamma[210:420], inferBound=True)
In [59]:
plot_contact_well(gamma[420:], inferBound=True)
In [57]:
pre = "/Users/weilu/Research/server/jan_2019/optimization/gammas_dec30/"
gamma_file = "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_gamma_filtered"
gamma_location = pre + gamma_file
# gamma = np.loadtxt(gamma_location)
gamma_filtered = np.loadtxt(gamma_location, dtype=complex, converters={
0: lambda s: complex(s.decode().replace('+-', '-'))})
plot_contact_well(gamma_filtered[:210], inferBound=True)
In [58]:
plot_contact_well(gamma_filtered[210:420], inferBound=True)
In [61]:
plot_contact_well(gamma_filtered[420:], inferBound=True)
In [48]:
gamma_iter1_location = "/Users/weilu/Research/server/feb_2019/optimization_iter1/gammas/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.0_gamma"
gamma_iter1 = np.loadtxt(gamma_iter1_location)
plot_contact_well(gamma_iter1[:210], inferBound=True)
In [50]:
gamma_iter1_location = "/Users/weilu/Research/server/feb_2019/optimization_iter1/gammas/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.0_gamma_filtered"
gamma_iter1 = np.loadtxt(gamma_iter1_location, dtype=complex, converters={
0: lambda s: complex(s.decode().replace('+-', '-'))})
plot_contact_well(gamma_iter1[:210], inferBound=True)
In [62]:
plot_contact_well(gamma_iter1[210:420], inferBound=True)
In [63]:
plot_contact_well(gamma_iter1[420:], inferBound=True)
In [52]:
plot_contact_well((0.5*(gamma+gamma_iter1))[:210], inferBound=True)
In [54]:
plot_contact_well((0.5*(gamma+gamma_iter1))[210:420], inferBound=True)
In [64]:
plot_contact_well((0.5*(gamma+gamma_iter1))[420:], inferBound=True)
In [29]:
gamma_iter2_location = "/Users/weilu/Research/server/feb_2019/optimization_iter2/gammas/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.0_gamma"
gamma_iter2 = np.loadtxt(gamma_iter2_location)
In [30]:
gamma_iter2.shape
Out[30]:
In [6]:
gamma_iter1.shape
Out[6]:
In [4]:
gamma.shape
Out[4]:
In [ ]:
In [70]:
alpha = 0.5
new_gamma = (alpha*gamma + (1-alpha)*gamma_iter1).astype(float)
In [71]:
gamma_for_simulation = "/Users/weilu/Research/server/feb_2019/optimization_iter1/iteration_gamma.dat"
gamma_format_convertion_iteration_to_simulation(new_gamma, gamma_for_simulation)
In [32]:
alpha = 0.5
new_gamma_iter2 = alpha*new_gamma + (1-alpha)*gamma_iter2
In [8]:
def gamma_format_convertion_iteration_to_simulation(iteration_gamma, gamma_for_simulation):
# gamma_location = "/Users/weilu/Research/server_backup/jan_2019/optimization/gammas_dec30/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_gamma"
# gamma_for_simulation = "/Users/weilu/Research/server_backup/jan_2019/optimization/iteration_gamma.dat"
gamma = iteration_gamma
gamma = -gamma # caused by tradition.
# convert gamma to gamma used by simulation
with open(gamma_for_simulation, "w") as out:
c = 0
for i in range(20):
for j in range(i, 20):
out.write(f"{gamma[c]:<.5f} {gamma[c]:10.5f}\n")
c += 1
out.write("\n")
for i in range(20):
for j in range(i, 20):
# protein, water
out.write(f"{gamma[c]:<.5f} {gamma[c+210]:10.5f}\n")
c += 1
In [34]:
gamma_for_simulation = "/Users/weilu/Research/server/feb_2019/optimization_iter2/iteration_gamma.dat"
gamma_format_convertion_iteration_to_simulation(new_gamma_iter2, gamma_for_simulation)
In [21]:
sum(abs(gamma))
Out[21]:
In [37]:
sum(new_gamma)
Out[37]:
In [36]:
sum(new_gamma_iter2)
Out[36]:
In [38]:
sum(abs(new_gamma))
Out[38]:
In [31]:
sum(abs(gamma_iter2))
Out[31]:
In [22]:
sum(abs(gamma_iter1))
Out[22]:
In [27]:
sum(abs(new_gamma))
Out[27]:
In [ ]:
pre = "/Users/weilu/Research/server/feb_2019/optimization_iter1/"
os.chdir(pre)
z_scores, e_natives, e_mgs, e_mg_stds = validate_hamiltonian_wei(
hamiltonian='phi_list.txt', gamma_file_name="gammas/original_gamma.dat",
training_set_file=pre+"proteins_name_list.txt",
training_decoy_method='lammps', num_decoys=20, use_filtered_gammas=False)
os.chdir('/Users/weilu/opt/notebook/Optimization')
In [83]:
pre = "/Users/weilu/Research/server/feb_2019/optimization_iter1/"
os.chdir(pre)
z_scores, e_natives, e_mgs, e_mg_stds = validate_hamiltonian_wei(
hamiltonian='phi_list.txt', gamma_file_name="gammas/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.0_gamma_filtered",
training_set_file=pre+"proteins_name_list.txt",
training_decoy_method='lammps', num_decoys=20, use_filtered_gammas=True)
os.chdir('/Users/weilu/opt/notebook/Optimization')
In [84]:
z_scores
Out[84]:
In [79]:
z_scores
Out[79]:
In [74]:
plt.hist(z_scores, bins=50)
# plt.hist(-origin_z_scores, bins=50, alpha=0.5)
Out[74]:
In [75]:
z_scores
Out[75]:
In [ ]: