-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcompute_energy.py
More file actions
186 lines (154 loc) · 7.22 KB
/
compute_energy.py
File metadata and controls
186 lines (154 loc) · 7.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
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 pathlib import Path
from Bio.PDB.PDBParser import PDBParser
from pyCodeLib import *
from compute_energy_helperFunctions import *
parser = argparse.ArgumentParser(
description="This is a python3 script to\
automatic copy the template file, \
run simulation and analysis")
parser.add_argument("protein", help="The name of the protein")
parser.add_argument("-l", "--label", type=str, default="/Users/weilu/opt/ff_contact/1r69/")
parser.add_argument("-f", "--familyFold", action="store_true", default=False)
parser.add_argument("--membrane", action="store_true", default=False)
parser.add_argument("-g", "--gamma", type=str, default=None)
parser.add_argument("-b", "--burialGamma", type=str, default=None)
parser.add_argument("-m", "--mode", type=int, default=0)
args = parser.parse_args()
if(platform.system() == 'Darwin'):
pre = str(Path.home()) + "/openmmawsem/parameters/"
elif(platform.system() == 'Linux'):
pre = "/projects/pw8/wl45/openawsem/parameters/"
else:
print("system unkown")
# pre = "/Users/weilu/Research/server/sep_2019/saved_gammas/no_mix"
# pre = "/Users/weilu/Research/server/sep_2019/saved_gammas/Sep28_trial_5_cutoff500_impose_Aprime_constraint"
if args.membrane:
gammaFile = f"{pre}/membrane_gamma.dat"
else:
gammaFile = f"{pre}/gamma.dat"
burialGammaFile = f"{pre}/burial_gamma.dat"
if args.gamma is not None:
gammaFile = args.gamma
if args.burialGamma is not None:
burialGammaFile = args.burialGamma
gamma_direct, gamma_mediated = read_gamma(gammaFile)
burial_gamma = np.loadtxt(burialGammaFile).T
gamma_ijm, water_gamma_ijm, protein_gamma_ijm = change_gamma_format(gamma_direct, gamma_mediated)
pdb = (args.protein).split(".")[0]
structure = parse_pdb(pdb)
if False:
e_pap_aph, e_pap_ap = compute_pap1(structure)
e_pap_p = compute_pap2(structure)
print("PAP_APH: ", e_pap_aph, "PAP_AP: ", e_pap_ap, "PAP_P: ", e_pap_p, "PAP_total: ", e_pap_p+e_pap_ap+e_pap_aph)
if False:
e_membrane = compute_membrane(structure)
print("Membrane energy", e_membrane)
# exit()
if False:
e_debye_huckel = compute_debye_huckel(structure)
print("Debye Huckel", e_debye_huckel)
# e_chi = compute_chi(structure)
# print("Chi", e_chi)
if False:
e_mediated = compute_mediated(structure, hasPhosphorylation=True)
e_direct = compute_direct(structure, hasPhosphorylation=True)
e_burial = compute_burial(structure, hasPhosphorylation=True)
if True:
# fastaFile = "/Users/weilu/Research/server/feb_2020/compare_side_chain_with_and_without/native/256_cbd_submode_7_debug/crystal_structure.fasta"
fastaFile = "crystal_structure.fasta"
seq = read_fasta(fastaFile)
e_side_chain = compute_side_chain_energy(structure[0], seq)
print("e_side_chain", e_side_chain)
if True:
# fileLocation='./cbd_cbd_real_contact_symmetric.csv'
fileLocation='/Users/weilu/opt/parameters/side_chain/cbd_cbd_real_contact_symmetric_may02.csv'
e_side_chain = compute_side_chain_exclude_volume_energy(structure, fileLocation=fileLocation)
print("e_side_chain_exclude_volume", e_side_chain)
if False:
e_positive_inside_rule = compute_positive_inside_rule(structure)
print("e_positive_inside_rule", e_positive_inside_rule)
if False:
# shift center, not fix well center
# e_mediated = compute_mediated(structure, protein_gamma_ijm, water_gamma_ijm, hasPhosphorylation=False)
# e_direct = compute_direct(structure, gamma_ijm, hasPhosphorylation=False)
e_mediated = compute_mediated(structure, protein_gamma_ijm, water_gamma_ijm, hasPhosphorylation=False, fixWellCenter=False)
e_direct = compute_direct(structure, gamma_ijm, hasPhosphorylation=False, fixWellCenter=False)
if True:
if args.mode == 0:
e_mediated = compute_mediated(structure, protein_gamma_ijm, water_gamma_ijm, hasPhosphorylation=False)
e_direct = compute_direct(structure, gamma_ijm, hasPhosphorylation=False)
if args.mode == 1:
e_mediated = compute_mediated(structure, protein_gamma_ijm, water_gamma_ijm, hasPhosphorylation=False, fixWellCenter=False)
e_direct = compute_direct(structure, gamma_ijm, hasPhosphorylation=False, fixWellCenter=False)
e_burial = compute_burial(structure, burial_gamma, hasPhosphorylation=False)
# print("Mediated, Direct, Mediated+Direct, Burial, Mediated+Direct+Burial")
if False:
# environment
e_mediated = compute_mediated(structure, protein_gamma_ijm, water_gamma_ijm, hasPhosphorylation=False, fixWellCenter=False)
e_direct = compute_direct(structure, gamma_ijm, hasPhosphorylation=False, fixWellCenter=False, environment=True)
e_burial = compute_burial(structure, burial_gamma, hasPhosphorylation=False)
name_list = "Protein, Mediated, Direct, Mediated+Direct, Burial, Mediated+Direct+Burial".split(",")
out_line = " ".join([f"{i:<20}" for i in name_list])
print(out_line)
# print(e_mediated, e_direct, e_mediated + e_direct, e_burial, e_mediated + e_direct + e_burial)
energy_out_list = [-e_mediated, -e_direct, -(e_mediated+e_direct), -e_burial, -(e_mediated + e_direct + e_burial)]
out_line = " ".join([f"{pdb:<20}"] + ["{0:<20.3f}".format(i) for i in energy_out_list])
print(out_line)
# print(compute_direct_2("8ab.pdb"))
# exit()
if args.familyFold:
pre = args.label
# pre = "/Users/weilu/Research/server/may_2019/family_fold/ff_contact/1r69/"
f_direct = np.loadtxt(f"{pre}/direct.dat")
f_water = np.loadtxt(f"{pre}/water.dat")
f_protein = np.loadtxt(f"{pre}/protein.dat")
f_burial = np.loadtxt(f"{pre}/burial.dat")
e_direct_ff = compute_direct_family_fold(structure, f_direct, kappa=5.0)
e_mediated_ff = compute_mediated_family_fold(structure, f_water, f_protein)
e_burial_ff = compute_burial_family_fold(structure, f_burial)
energy_out_list = [-e_mediated_ff, -e_direct_ff, -(e_direct_ff+e_mediated_ff), -e_burial_ff, -(e_direct_ff+e_mediated_ff+e_burial_ff)]
out_line = " ".join([f"{pdb:<20}"] + ["{0:<20.3f}".format(i) for i in energy_out_list])
print(out_line)
exit()
e_direct_multiLetter = compute_direct_multiLetter(structure)
print(e_direct_multiLetter)
e_mediated_multiLetter = compute_mediated_multiLetter(structure)
print(e_mediated_multiLetter)
e_burial_multiLetter = compute_burial_multiLetter(structure)
print(e_burial_multiLetter)
# kappa = 10.0
# kappa_list = [5.0, 10.0]
# for kappa in kappa_list:
# e_mediated = compute_mediated(structure, kappa=kappa)
# e_direct = compute_direct(structure, kappa=kappa)
# e_burial = compute_burial(structure)
# print(f"kappa: {kappa}", e_mediated, e_direct, e_mediated + e_direct)
print("multiDensity")
e_mediated_multiLetter = compute_mediated_multiDensity(structure)
print(e_mediated_multiLetter)
e_burial_multiLetter = compute_burial_multiDensity(structure)
print(e_burial_multiLetter)