Skip to content

Commit 0b56704

Browse files
authored
add TS115 (#2)
* towards ts115 eval * eval ts115 * fix api typo
1 parent 5fd2940 commit 0b56704

9 files changed

Lines changed: 795 additions & 13 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
ps4_models/Conv/*.pt filter=lfs diff=lfs merge=lfs -text
22
ps4_models/Mega/*.pt filter=lfs diff=lfs merge=lfs -text
33
ps4_data/data/cb513/CB513_embeddings.npz filter=lfs diff=lfs merge=lfs -text
4+
ps4_data/data/ts115/TS115_embeddings.npz filter=lfs diff=lfs merge=lfs -text

main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,17 @@ def print_help():
5454
if sys.argv[3] in ['--mega', '--conv']:
5555
if sys.argv[3] == '--conv':
5656
model_name = 'PS4_Conv'
57-
weights_path = 'ps4_models/Conv/PS4-Conv_epoch-5_loss-0.652_acc-77.905.pt'
57+
path = 'ps4_models/Conv/PS4-Conv_epoch-5_loss-0.652_acc-77.905.pt'
5858
else:
5959
print(f'Please specify a valid model name. found: {sys.argv[3]}')
6060

6161
if len(sys.argv) > 4:
6262
path = sys.argv[4]
6363

6464
if sys.argv[2] == '--cb513':
65-
eval_cb513(path, model_name=model_name)
65+
eval_alt(path, ds_name='cb513', model_name=model_name)
66+
elif sys.argv[2] == '--ts115':
67+
eval_alt(path, ds_name='ts115', model_name=model_name)
6668
elif sys.argv[2] == '--ps4':
6769
eval_ps4_test(path, model_name=model_name)
6870
else:
@@ -103,4 +105,3 @@ def print_help():
103105

104106

105107

106-

ps4_data/data/ts115/TS115.fasta

Lines changed: 658 additions & 0 deletions
Large diffs are not rendered by default.

ps4_data/data/ts115/TS115_HHblits.csv

Lines changed: 116 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:6fcc6fa43810fb08438ac0d1987ec966ae318e84f3a5757ed4f60196670025d8
3+
size 112805135

ps4_data/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,13 @@ def pt_2_csv(phase):
250250

251251

252252
# Mark: single sequence secondary structure
253-
def load_cb513_dataset():
253+
def load_alt_dataset(ds_name):
254254

255-
df = pd.read_csv(f'ps4_data/data/cb513/CB513_HHblits.csv')
256-
embs = np.load(f'ps4_data/data/cb513/CB513_embeddings.npz', allow_pickle=True)
255+
if ds_name.upper() not in ['CB513', 'TS115']:
256+
raise ValueError(f"ds_name must be one of ['CB513', 'TS115'], got {ds_name}")
257+
258+
df = pd.read_csv(f'ps4_data/data/{ds_name.lower()}/{ds_name.upper()}_HHblits.csv')
259+
embs = np.load(f'ps4_data/data/{ds_name.lower()}/{ds_name.upper()}_embeddings.npz', allow_pickle=True)
257260
for row in range(len(df)):
258261
res_string = df['input'][row]
259262

@@ -265,7 +268,7 @@ def load_cb513_dataset():
265268
for c in mask_raw:
266269
mask_str += f'{c} '
267270

268-
_, y, mask = get_input_data_from_res_seq(res_string, ss_string, mask_str, 'CB513')
271+
_, y, mask = get_input_data_from_res_seq(res_string, ss_string, mask_str)
269272
r = torch.from_numpy(embs[str(row)]).float()
270273
yield r, y, mask
271274

ps4_eval/eval.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def eval_ps4_test(load_path, model_name='PS4_Mega'):
5050
f"q3 acc: {sum(q3_accs)/len(whole_accs)}")
5151

5252

53-
def eval_cb513(load_path, use_mask=True, model_name='PS4_Mega'):
53+
def eval_alt(load_path, ds_name='cb513', use_mask=True, model_name='PS4_Mega'):
5454
print("starting")
5555
model = load_trained_model(load_path, model_name)
5656

@@ -61,7 +61,7 @@ def eval_cb513(load_path, use_mask=True, model_name='PS4_Mega'):
6161
val_accs = []
6262
q3_accs = []
6363

64-
for r, y, mask in load_cb513_dataset():
64+
for r, y, mask in load_alt_dataset(ds_name):
6565

6666
count += 1
6767

@@ -104,7 +104,7 @@ def eval_cb513(load_path, use_mask=True, model_name='PS4_Mega'):
104104
whole_accs.append(ss_acc)
105105
__q8_q3_from_confusion(ss_confusion)
106106

107-
print(f"\nDONE: CB513, whole q8 acc: {sum(whole_accs)/len(whole_accs)}\n"
107+
print(f"\nDONE: {ds_name}, whole q8 acc: {sum(whole_accs)/len(whole_accs)}\n"
108108
f"val only q8 acc: {sum(val_accs)/len(val_accs)}\n"
109109
f"q3 acc: {sum(q3_accs)/len(val_accs)}")
110110

ps4_eval/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ps4_data.utils import load_data, load_cb513_dataset
1+
from ps4_data.utils import load_data, load_alt_dataset
22
from torch import nn, cuda, load, device
33
from ps4_models.classifiers import PS4_Mega, PS4_Conv
44

@@ -34,7 +34,8 @@ def __get_loader_for(ds):
3434
loader_dict = {
3535
'train': load_data('train'),
3636
'valid': load_data('valid'),
37-
'cb513': load_cb513_dataset()
37+
'cb513': load_alt_dataset('cb513'),
38+
'ts115': load_alt_dataset('ts115')
3839
}
3940

4041
return loader_dict[dataset]

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ Pillow~=8.1.2
88
setuptools~=57.4.0
99
pandas~=1.3.2
1010
wget~=3.2
11-
edlib~=1.3.8.post2
1211
maturin~=0.14.14

0 commit comments

Comments
 (0)