Skip to content

Commit

Permalink
[CLEAN] removed bo_utils.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntGro committed Jun 5, 2023
1 parent 10e975f commit cd06734
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 34 deletions.
31 changes: 0 additions & 31 deletions AntBO/bo/bo_utils.py

This file was deleted.

12 changes: 11 additions & 1 deletion AntBO/bo/localbo_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
import random
from copy import deepcopy

from bo.bo_utils import check_cdr_constraints, idx_to_AA, N_glycosylation_pattern
from bo.kernels import *
import re

COUNT_AA = 5
AA = 'ACDEFGHIKLMNPQRSTVWY'
AA_to_idx = {aa: i for i, aa in enumerate(AA)}
idx_to_AA = {value: key for key, value in AA_to_idx.items()}
N_glycosylation_pattern = 'N[^P][ST][^P]'


# from Bio.SeqUtils.ProtParam import ProteinAnalysis

Expand Down Expand Up @@ -44,6 +49,11 @@ def check_cdr_constraints_all(x, x_center_local=None, hamming=None, config=None)
return int(not (c1)), int(not (c2)), int(not (c3))


def check_cdr_constraints(x) -> bool:
constr = check_cdr_constraints_all(x)
return np.all(constr)


def onehot2ordinal(x, categorical_dims):
"""Convert one-hot representation of strings back to ordinal representation."""
from itertools import chain
Expand Down
2 changes: 1 addition & 1 deletion AntBO/bo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
def get_x_y_from_csv(csv_path):
data = pd.read_csv(csv_path)
x = data["x"].values
from bo.bo_utils import AA_to_idx
from bo.localbo_utils import AA_to_idx
x = np.array([[AA_to_idx[cat] for cat in xx] for xx in x])
y = torch.tensor(data["y"].values).reshape(-1, 1)
return x, y
Expand Down
2 changes: 1 addition & 1 deletion AntBO/bo/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from bo.localbo_cat import CASMOPOLITANCat
from bo.localbo_utils import from_unit_cube, latin_hypercube, to_unit_cube, ordinal2onehot, onehot2ordinal,\
random_sample_within_discrete_tr_ordinal
from bo.bo_utils import check_cdr_constraints
from bo.localbo_utils import check_cdr_constraints
import torch
import logging
from gpytorch.utils.errors import NotPSDError, NanError
Expand Down

0 comments on commit cd06734

Please sign in to comment.