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'] = 0.5*np.array([16.18033, 10]) #golden ratio
plt.rcParams['figure.facecolor'] = 'w'
plt.rcParams['figure.dpi'] = 100
plt.rcParams.update({'font.size': 22})
In [23]:
data = pd.read_pickle("/Users/weilu/Research/data/openAWSEM_benchmark.pkl")
data["time_in_hour"] = data["time"] / 3600
from sklearn.linear_model import LinearRegression
data_lammps = data.query("Scheme == 'LAMMPS'")
y = data_lammps.time_in_hour.values
X = data_lammps.Length.values
coefs = np.polynomial.polynomial.polyfit(X, y, 2)
ffit = np.polynomial.polynomial.Polynomial(coefs)
data_openMM = data.query("Scheme == 'openMM'")
y_openMM = data_openMM.time_in_hour.values
X_openMM = data_openMM.Length.values
coefs_openMM = np.polynomial.polynomial.polyfit(X_openMM, y_openMM, 2)
ffit_openMM = np.polynomial.polynomial.Polynomial(coefs_openMM)
In [28]:
x = np.linspace(0, 2000)
plt.scatter(X, y)
plt.plot(x, ffit(x))
plt.plot(x, ffit_openMM(x))
plt.scatter(X_openMM, y_openMM)
# plt.plot(x, 10*x)
plt.yscale("log")
plt.xscale("log")
plt.xlabel("Length")
plt.ylabel("Time(hours)")
plt.legend(["Lammps", "OpenAWSEM"])
plt.title("run 1 million steps")
plt.savefig("/Users/weilu/Dropbox/openAWSEM/figures/benchmark_logscale.png", dpi=300)
In [27]:
x = np.linspace(0, 2000)
plt.scatter(X, y)
plt.plot(x, ffit(x))
plt.plot(x, ffit_openMM(x))
plt.scatter(X_openMM, y_openMM)
# plt.plot(x, 10*x)
plt.xlabel("Length")
plt.ylabel("Time(hour)")
plt.legend(["Lammps", "OpenAWSEM"])
plt.title("run 1 million steps")
plt.tight_layout()
plt.savefig("/Users/weilu/Dropbox/openAWSEM/figures/benchmark.png", dpi=300)
In [73]:
data = pd.read_csv("/Users/weilu/Research/data/openMM/complete_run_without_er_gamma_yesCysCys_12-02.csv", index_col=0)
a = pd.read_csv("/Users/weilu/Research/data/openMM/length_info_12-01.csv", index_col=0)
data = data.merge(a, on="Protein")
In [74]:
memory = 'ho'
filtered_data = data.query(f"memory == '{memory}'").query("k_cys != 'k_10' and k_cys != 'k_20' and k_cys != 'k_1'")
# filtered_data = data.query(f"Protein == '{protein}'").query(f"memory == '{memory}'").query("k_cys != 'k_10' and k_cys != 'k_20'")
Q_max = filtered_data.sort_values('Q').groupby(["k_cys", "Protein"]).tail(1).sort_values(['k_cys', "Q"])
Q_max.Protein = pd.Categorical(Q_max.Protein, a.sort_values("Length").Protein.values)
Q_max.k_cys = pd.Categorical(Q_max.k_cys, ["original", "k_0", "k_1", "k_2", "k_5"])
# Q_max["Annealing Index"] = Q_max.groupby(["Submode"])["Q"].rank(method="first", ascending=False).astype(int)
# last = data.query("Steps > 350 and Folder in ['eighth_2_cys']")
# sns.lineplot("Annealing Index", "Q", markers=True, style="k_cys", data=Q_max, hue="k_cys", dashes=False)
sns.lineplot("Protein", "Q", hue="k_cys", markers=True, data=Q_max.sort_values("Length").reset_index(drop=True), style="k_cys", dashes=False)
plt.ylabel("Best Q")
# _ = plt.xticks(np.arange(1, 21, 1))
plt.title(f"structure prediction results of 5 Disufide rich proteins")
# plt.savefig("/Users/weilu/Dropbox/openAWSEM/figures/k_cys_complete.png", dpi=300)
Out[74]:
In [91]:
Q_max = filtered_data.sort_values('Q').groupby(["k_cys", "Protein", "Run"]).tail(1).sort_values(['k_cys', "Q"])
Q_max.Protein = pd.Categorical(Q_max.Protein, a.sort_values("Length").Protein.values)
Q_max.k_cys = pd.Categorical(Q_max.k_cys, ["k_0", "k_2", "k_5", "original"])
In [97]:
sns.boxenplot("Protein", "Q", data=Q_max, hue="k_cys")
plt.savefig("/Users/weilu/Dropbox/openAWSEM/figures/k_cys_bestQ_from_each_run.png", dpi=300)
In [95]:
Q_last = filtered_data.groupby(["k_cys", "Protein", "Run"]).tail(10).sort_values(['k_cys', "Q"])
Q_last.Protein = pd.Categorical(Q_last.Protein, a.sort_values("Length").Protein.values)
Q_last.k_cys = pd.Categorical(Q_last.k_cys, ["k_0", "k_2", "k_5", "original"])
In [98]:
sns.boxenplot("Protein", "Q", data=Q_last, hue="k_cys")
plt.savefig("/Users/weilu/Dropbox/openAWSEM/figures/k_cys_last10frame_from_each_run.png", dpi=300)
1tcg,6, μ/α Conotoxin-like,Small disulfide-closed loop 1lmm,6 1bpi,6 1fs3,8 1hn4,12,Phospholipase A2
In [99]:
data = pd.read_csv("/Users/weilu/Research/data/openMM/new_old_beta_11-23.csv", index_col=0)
In [100]:
filtered_data = data.query("subfolder != 'no_beta_pap'")
Q_max = filtered_data.sort_values('Q').groupby(["subfolder", "Protein"]).tail(1)
In [109]:
filtered_data = filtered_data.query("Steps > 2491").reset_index(drop=True)
In [111]:
sns.boxenplot("Protein", "Q", data=filtered_data, hue="subfolder")
plt.savefig("/Users/weilu/Dropbox/openAWSEM/figures/new_old_beta_comparison_last_10frames_from_each_run", dpi=300)
In [62]:
# sns.boxenplot("Protein", "Q", data=Q_max, hue="subfolder")
sns.lineplot("Protein", "Q", hue="subfolder", markers=True, data=Q_max, style="subfolder", dashes=False)
plt.ylabel("Best Q")
plt.savefig("/Users/weilu/Dropbox/openAWSEM/figures/new_old_beta_comparison", dpi=300)
In [3]:
data = pd.read_csv("/Users/weilu/Research/data/openMM/second_hybrid_protein_simulation_third_3_12-16.csv", index_col=0)
# length_info = pd.read_csv("/Users/weilu/Research/server/aug_2019/hybrid_protein_simulation/length_info.csv", index_col=0)
length_info = pd.read_csv("/Users/weilu/Research/database/hybrid_prediction_database/length_info.csv", index_col=0)
length_info = length_info.sort_values("Length").reset_index()
pdb_list_sorted_by_length = list(length_info.Protein.unique())
length_info_sorted_by_length = list(length_info.Length.unique())
label_list = []
for p, n in zip(pdb_list_sorted_by_length, length_info_sorted_by_length):
label_list.append(p+f"\n{n}")
# pd.set_option('max_colwidth', 100)
# create label
sub_label_list = []
pdb_list_sorted_by_length = ['2jo1', '4p79', '4a2n', '1py6', '3kp9', '4nv6', '5xpd', '2xov', '5d91', '1u19', '6g7o', '6a93', '5dsg', '1pv6', '6e67A']
length_info_sorted_by_length = length_info["Length"].tolist()
sub_label_list = []
for p, n in zip(pdb_list_sorted_by_length, length_info_sorted_by_length):
sub_label_list.append(p+f"\n{n}")
sub_pdb_list = length_info["Protein"].tolist()
data.Protein = pd.Categorical(data.Protein,
categories=sub_pdb_list)
convert_dic = {"third_3":"hybrid contact", "third":"HE",
"third_1":"contact as in water", "fifth":"no contact", "third_2":"contact as in membrane"}
In [5]:
In [6]:
In [8]:
plt.rcParams['figure.figsize'] = 0.8*np.array([16.18033, 10]) #golden ratio
In [10]:
y = "Q_wat"
d = data.query("Steps > 1500").reset_index(drop=True)
t = d.groupby(["Protein", "Folder"])[y].idxmax().reset_index()
max_Q_mem_data = d.iloc[t[y].to_list()].reset_index(drop=True)
max_Q_mem_data["Scheme"] = max_Q_mem_data["Folder"].apply(lambda x: convert_dic[x])
sub_data = max_Q_mem_data.query("Scheme in ['hybrid contact', 'contact as in water', 'contact as in membrane']")
# sub_data = max_Q_mem_data
ax = sns.lineplot(x="Protein", y=y, markers=True, ms=10, style="Scheme", hue="Scheme", data=sub_data, dashes=False)
_ = ax.set_xticklabels(labels=sub_label_list, rotation=0, ha='center')
plt.savefig("/Users/weilu/Dropbox/openAWSEM/figures/Q_wat_new.png", dpi=300)
In [11]:
y = "Q_mem"
d = data.query("Steps > 1500").reset_index(drop=True)
t = d.groupby(["Protein", "Folder"])[y].idxmax().reset_index()
max_Q_mem_data = d.iloc[t[y].to_list()].reset_index(drop=True)
max_Q_mem_data["Scheme"] = max_Q_mem_data["Folder"].apply(lambda x: convert_dic[x])
sub_data = max_Q_mem_data.query("Scheme in ['hybrid contact', 'contact as in water', 'contact as in membrane']")
# sub_data = max_Q_mem_data
ax = sns.lineplot(x="Protein", y=y, markers=True, ms=10, style="Scheme", hue="Scheme", data=sub_data, dashes=False)
_ = ax.set_xticklabels(labels=sub_label_list, rotation=0, ha='center')
plt.savefig("/Users/weilu/Dropbox/openAWSEM/figures/Q_mem_new.png", dpi=300)
In [65]:
x = np.linspace(0, 20, 100)
In [66]:
x
Out[66]:
In [71]:
y = np.exp(-4*(x))
In [72]:
plt.plot(x, y)
Out[72]:
In [70]:
y
Out[70]:
In [11]:
def convert_simulation_to_iteration_gamma(fromFile, toFile):
a = np.loadtxt(fromFile)
a = -a
with open(toFile, "w") as out:
for i in range(210):
g = a[i][0]
out.write(f"{g}\n")
for i in range(210):
g = a[i+210][0]
out.write(f"{g}\n")
for i in range(210):
g = a[i+210][1]
out.write(f"{g}\n")
In [12]:
pre = "/Users/weilu/Research/server/apr_2020/openAWSEM_archived_data/convert_simulation_to_iteration_gamma/"
fromFile = f"{pre}/gamma.dat"
toFile = f"{pre}/iteration_gamma.dat"
import numpy as np
convert_simulation_to_iteration_gamma(fromFile, toFile)
In [13]:
pre = "/Users/weilu/Research/server/apr_2020/openAWSEM_archived_data/convert_simulation_to_iteration_gamma/"
fromFile = f"{pre}/membrane_gamma.dat"
toFile = f"{pre}/iteration_membrane_gamma.dat"
import numpy as np
convert_simulation_to_iteration_gamma(fromFile, toFile)
In [8]:
pre = "/Users/weilu/Research/server/apr_2020/openAWSEM_archived_data/convert_simulation_to_iteration_gamma/"
fromFile = f"{pre}/gamma.dat"
toFile = f"{pre}/iteration_gamma.dat"
import numpy as np
a = np.loadtxt(fromFile)
a = -a
with open(toFile, "w") as out:
for i in range(210):
g = a[i][0]
out.write(f"{g}\n")
for i in range(210):
g = a[i+210][0]
out.write(f"{g}\n")
for i in range(210):
g = a[i+210][1]
out.write(f"{g}\n")
In [ ]: