-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsample_script.py
117 lines (96 loc) · 5.45 KB
/
sample_script.py
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
"""
This is a sample script to run eisd with N-terminal drk SH3 data that is provided in the data directory.
"""
import numpy as np
np.random.seed(91)
import os
import pandas as pd
from eisd.utils import meta_data
from eisd.parser import read_data
from eisd.utils import make_pairs
from eisd.optimizer import main
if __name__ == '__main__':
# parameters
data_path = "data/" # path to experimental data and structure pools
structure = 'ensemble' # ['trades_uf', 'mixed', 'ensemble'], trades_uf refers to the Random pool
# run_mode: How do you want to run the eisd optimizer?
# - all: optimize on all experimental observables together
# - single: optimize on individual experimental observable
# - dual: optimize on pairs of experimental observables
run_mode = 'all'
opt_type = 'max' # optimization type: 'max', 'mc', None
beta = 0.1 # hyperparameter for 'mc' opt_type (Metropolis Monte Carlo)
# run_mode = 'pre_indices'
# pre_indices_mode = 'all' # 'dual' or 'signle'
# pre_indices_path = 'local/newrun_2020/new_prop_errors2/positive_mc/%s/single_mode/opt_%s/'%(structure,str(opt_type))
# pre_indices_path = 'local/newrun_2020/new_prop_errors2/positive_mc/%s/dual_mode/opt_%s/'%(structure,str(opt_type))
# pre_indices_path = 'local/ensemble_1700/'
# read files: meta_data and read_data functions provide all required info to reproduce our published results
filenames = meta_data(data_path)
exp_data = read_data(filenames['exp'], mode='exp')
bc_data = read_data(filenames[structure], mode=structure)
# run_mode: all
if run_mode == 'all':
if opt_type == 'mc':
abs_output = "local/newrun_2021/%s/all_mode/opt_%s_b%s"%(structure,str(opt_type), str(beta))
else:
abs_output = "local/newrun_2021/%s/all_mode/opt_%s"%(structure,str(opt_type))
if not os.path.exists(abs_output):
os.makedirs(abs_output)
# main(exp_data, bc_data, epochs=1000, mode='all', optimization=True, output_dir=abs_output, verbose=False)
main(exp_data, bc_data, epochs=1000, mode='all', beta=beta, opt_type=opt_type, output_dir=abs_output, verbose=False)
# run_mode: dual
elif run_mode == 'dual':
pairs = make_pairs()
# pairs = [['saxs', 'jc'],['cs', 'jc'], ['fret', 'jc'],['jc', 'noe'],['jc', 'pre'],['jc', 'rdc'],['jc', 'rh']]
# pairs = [['fret', 'noe'], ['fret', 'pre'], ['fret', 'rdc'], ['fret', 'rh']]
for pair in pairs:
if opt_type == 'mc':
abs_output = "local/newrun_2020/new_prop_errors2/positive_mc/%s/dual_mode/opt_%s_b%s/%s_%s"%(structure, str(opt_type), str(beta) ,pair[0], pair[1])
else:
abs_output = "local/newrun_2020/new_prop_errors2/positive_mc/%s/dual_mode/opt_%s/%s_%s"%(structure, str(opt_type),pair[0], pair[1])
if not os.path.exists(abs_output):
os.makedirs(abs_output)
main(exp_data, bc_data, epochs=1000, mode=pair, beta=beta, opt_type=opt_type, output_dir=abs_output, verbose=False)
# run_mode: single
elif run_mode == 'single':
single_modes = ['saxs', 'cs', 'fret', 'jc', 'noe', 'pre', 'rdc', 'rh']
# single_modes = ['saxs', 'cs', 'fret']
for mode in single_modes:
if opt_type == 'mc':
abs_output = "local/newrun_2020/new_prop_errors2/positive_mc/%s/single_mode/opt_%s_b%s/%s"%(structure, str(opt_type),str(beta),mode)
else:
abs_output = "local/newrun_2020/new_prop_errors2/positive_mc/%s/single_mode/opt_%s/%s"%(structure, str(opt_type), mode)
if not os.path.exists(abs_output):
os.makedirs(abs_output)
main(exp_data, bc_data, epochs=1000, mode=mode, beta=beta, opt_type=opt_type, output_dir=abs_output, verbose=True)
"""
# run_mode: pre_indices; to calculate scores/RMSDs for the remaining unoptimized properties
elif run_mode == 'pre_indices':
if pre_indices_mode == 'single':
for prop in ['saxs', 'cs', 'jc', 'fret', 'noe', 'pre', 'rh', 'rdc']:
ind_path = os.path.join(pre_indices_path, prop, 'indices.csv')
pre_indices = pd.read_csv(ind_path, header=None).values
abs_output = os.path.join(pre_indices_path, prop, 'all_processed')
print(abs_output)
if not os.path.exists(abs_output):
os.makedirs(abs_output)
main(exp_data, bc_data, pre_indices=pre_indices, output_dir=abs_output)
elif pre_indices_mode == 'dual':
pairs = make_pairs()
for pair in pairs:
ind_path = os.path.join(pre_indices_path, '%s_%s'%(pair[0], pair[1]), 'indices.csv')
pre_indices = pd.read_csv(ind_path, header=None).values
abs_output = os.path.join(pre_indices_path, '%s_%s'%(pair[0], pair[1]), 'all_processed')
print(abs_output)
if not os.path.exists(abs_output):
os.makedirs(abs_output)
main(exp_data, bc_data, pre_indices=pre_indices, output_dir=abs_output)
elif pre_indices_mode == 'all':
pre_indices = np.array([range(1700)])
abs_output = os.path.join(pre_indices_path, 'all_processed')
print(abs_output)
if not os.path.exists(abs_output):
os.makedirs(abs_output)
main(exp_data, bc_data, pre_indices=pre_indices, output_dir=abs_output, opt_type=None)
"""