From 9fb04fc0c557cb2aa509044c5e00fcccc036c6b5 Mon Sep 17 00:00:00 2001 From: Brandon Trabucco Date: Tue, 31 Aug 2021 17:49:18 -0700 Subject: [PATCH] hotfix for fingerprint calculation (when SMILES is invalid) --- README.md | 4 ++-- .../feature_extractors/morgan_fingerprint_features.py | 8 ++++---- example_iteration_script.py | 3 ++- setup.py | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bb1d8e6..971e899 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,14 @@ The goal of model-based optimization is to find an input **x** that maximizes an Design-Bench can be installed with the complete set of benchmarks via our pip package. ```bash -pip install design-bench[all]==2.0.15 +pip install design-bench[all]==2.0.16 pip install morphing-agents==1.5.1 ``` Alternatively, if you do not have MuJoCo, you may opt for a minimal install. ```bash -pip install design-bench==2.0.15 +pip install design-bench==2.0.16 ``` ## Available Tasks diff --git a/design_bench/oracles/feature_extractors/morgan_fingerprint_features.py b/design_bench/oracles/feature_extractors/morgan_fingerprint_features.py index a2c295c..bf884b1 100644 --- a/design_bench/oracles/feature_extractors/morgan_fingerprint_features.py +++ b/design_bench/oracles/feature_extractors/morgan_fingerprint_features.py @@ -101,12 +101,12 @@ def dataset_to_oracle_x(self, x_batch, dataset): tokens = xi[1:stop_tokens[0] if stop_tokens.size > 0 else xi[1:]] # apply morgan fingerprint featurization using rdkit - value = self.featurizer.featurize( - self.tokenizer.decode(tokens).replace(" ", ""))[0] + token_string = self.tokenizer.decode(tokens).replace(" ", "") + value = self.featurizer.featurize(token_string)[0] # collate all results into a single numpy array - x_out.append(np.zeros([2048], dtype=self.dtype) - if value is None + x_out.append(np.zeros([self.size], dtype=self.dtype) + if value.size != self.size else np.array(value, dtype=self.dtype)) return np.asarray(x_out) diff --git a/example_iteration_script.py b/example_iteration_script.py index c6eb5fc..ea4c8c2 100644 --- a/example_iteration_script.py +++ b/example_iteration_script.py @@ -1,11 +1,12 @@ import pickle as pkl import design_bench as db import numpy as np +from design_bench.oracles.feature_extractors.morgan_fingerprint_features import MorganFingerprintFeatures if __name__ == "__main__": - with open("type_assay_pairs.pkl", "wb") as f: + with open("type_assay_pairs.pkl", "rb") as f: type_assay_pairs = pkl.load(f) all_rank_corr = [] diff --git a/setup.py b/setup.py index 21227a7..0498a52 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ LONG_DESCRIPTION = readme.read() -setup(name='design-bench', version='2.0.15', license='MIT', +setup(name='design-bench', version='2.0.16', license='MIT', packages=find_packages(include=['design_bench', 'design_bench.*']), description='Design-Bench: Benchmarks for ' 'Data-Driven Offline Model-Based Optimization', @@ -17,7 +17,7 @@ author_email='brandon@btrabucco.com', url='https://github.com/brandontrabucco/design-bench', download_url='https://github.com/' - 'brandontrabucco/design-bench/archive/v2_0_15.tar.gz', + 'brandontrabucco/design-bench/archive/v2_0_16.tar.gz', keywords=['Deep Learning', 'Neural Networks', 'Benchmark', 'Model-Based Optimization'], extras_require={'all': ['gym[mujoco]'], 'cma': ['cma']},