1212)
1313from chemlog .cli import CLASSIFIERS , _smiles_to_mol , strategy_call
1414from chemlog_extra .alg_classification .by_element_classification import (
15- XMolecularEntityClassifier ,
1615 OrganoXCompoundClassifier ,
16+ XMolecularEntityClassifier ,
1717)
18- from functools import lru_cache
18+
19+ from chebifier import modelwise_smiles_lru_cache
1920
2021from .base_predictor import BasePredictor
2122
4748
4849
4950class ChemlogExtraPredictor (BasePredictor ):
50-
5151 CHEMLOG_CLASSIFIER = None
5252
5353 def __init__ (self , model_name : str , ** kwargs ):
@@ -72,12 +72,10 @@ def predict_smiles_tuple(self, smiles_list: tuple[str]) -> list:
7272
7373
7474class ChemlogXMolecularEntityPredictor (ChemlogExtraPredictor ):
75-
7675 CHEMLOG_CLASSIFIER = XMolecularEntityClassifier
7776
7877
7978class ChemlogOrganoXCompoundPredictor (ChemlogExtraPredictor ):
80-
8179 CHEMLOG_CLASSIFIER = OrganoXCompoundClassifier
8280
8381
@@ -97,7 +95,6 @@ def __init__(self, model_name: str, **kwargs):
9795 # fmt: on
9896 print (f"Initialised ChemLog model { self .model_name } " )
9997
100- @lru_cache (maxsize = 100 )
10198 def predict_smiles (self , smiles : str ) -> Optional [dict ]:
10299 mol = _smiles_to_mol (smiles )
103100 if mol is None :
@@ -122,7 +119,8 @@ def predict_smiles(self, smiles: str) -> Optional[dict]:
122119 for label in self .peptide_labels + pos_labels
123120 }
124121
125- def predict_smiles_tuple (self , smiles_list : tuple [str ]) -> list :
122+ @modelwise_smiles_lru_cache .batch_decorator
123+ def predict_smiles_list (self , smiles_list : list [str ]) -> list :
126124 results = []
127125 for i , smiles in tqdm .tqdm (enumerate (smiles_list )):
128126 results .append (self .predict_smiles (smiles ))
0 commit comments