From 8402b9b4f98ecdcda26603c0c49e5f12116dc00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Gonz=C3=A1lez=20Duque?= Date: Tue, 6 Aug 2024 11:21:56 +0200 Subject: [PATCH 1/5] Adds link to docs for Ehrlich --- README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.MD b/README.MD index b66b09c7..68aa2b25 100644 --- a/README.MD +++ b/README.MD @@ -10,7 +10,7 @@ | Black box | References | Tests |----------|----------|----------| | [Toy continuous functions (e.g. Ackley, Hartmann...)](https://machinelearninglifescience.github.io/poli-docs/using_poli/objective_repository/toy_continuous_problems.html) | [(Al-Roomi 2015)](https://www.al-roomi.org/benchmarks/unconstrained), [(Surjanovic & Bingham 2013)](https://www.sfu.ca/~ssurjano/optimization.html) | [![poli base (dev, conda, python 3.9)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-base.yml/badge.svg)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-base.yml) | -| Ehrlich functions | [(Stanton et al. 2024)](https://arxiv.org/abs/2407.00236) | [![poli base (dev, conda, python 3.9)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-base.yml/badge.svg)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-base.yml) +| [Ehrlich functions](https://machinelearninglifescience.github.io/poli-docs/using_poli/objective_repository/ehrlich_functions.html) | [(Stanton et al. 2024)](https://arxiv.org/abs/2407.00236) | [![poli base (dev, conda, python 3.9)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-base.yml/badge.svg)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-base.yml) | [PMO/GuacaMol benchmark](https://machinelearninglifescience.github.io/poli-docs/#small-molecules) | [(Brown et al. 2019)](https://arxiv.org/abs/1811.09621), [(Gao et al. 2022)](https://openreview.net/forum?id=yCZRdI0Y7G), [(Huang et al. 2021)](https://openreview.net/pdf?id=8nvgnORnoWr) | [![poli tdc (dev, conda, python 3.9)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-tdc-env.yml/badge.svg)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-tdc-env.yml) | [Dockstring](https://machinelearninglifescience.github.io/poli-docs/using_poli/objective_repository/dockstring.html) | [(García-Ortegón et al. 2022)](https://pubs.acs.org/doi/full/10.1021/acs.jcim.1c01334) | [![poli dockstring (dev, conda, python 3.9)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-dockstring-env.yml/badge.svg)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-dockstring-env.yml) | [FoldX stability and SASA](https://machinelearninglifescience.github.io/poli-docs/#proteins) | [(Schymkowitz et al. 2005)](https://academic.oup.com/nar/article/33/suppl_2/W382/2505499?login=true) | - | From 278e926dca313cc4de4fce570110109c3db21e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Gonz=C3=A1lez=20Duque?= Date: Wed, 7 Aug 2024 13:38:22 +0200 Subject: [PATCH 2/5] Adds versioning (#235) --- pyproject.toml | 39 ++++++++++++++++++++++++++++++++++++--- requirements-dev.txt | 3 ++- setup.cfg | 6 +++--- src/poli/__init__.py | 2 +- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0b8d8e04..873b828c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "poli" -version = "0.2.1" +version = "1.0.0.dev0" description = "poli, a library of discrete objective functions" readme = "README.md" authors = [{name="Miguel González-Duque", email="miguelgondu@gmail.com"}, {name="Simon Bartels"}] @@ -28,7 +28,7 @@ dependencies = [ ] [project.optional-dependencies] -dev = ["black", "tox", "pytest"] +dev = ["black", "tox", "pytest", "bump-my-version"] docs = ["sphinx", "furo"] [project.urls] @@ -50,4 +50,37 @@ markers = [ profile = "black" [tool.ruff] -exclude = ["src/poli/core/util/proteins/rasp/inner_rasp", "src/poli/objective_repository/gfp_cbas"] \ No newline at end of file +exclude = ["src/poli/core/util/proteins/rasp/inner_rasp", "src/poli/objective_repository/gfp_cbas"] + +[tool.bumpversion] +current_version = "1.0.0.dev0" +parse = """(?x) + (?P0|[1-9]\\d*)\\. + (?P0|[1-9]\\d*)\\. + (?P0|[1-9]\\d*) + (?: + - # dash separator for pre-release section + (?P[a-zA-Z-]+) # pre-release label + (?P0|[1-9]\\d*) # pre-release version number + )? # pre-release section is optional +""" +serialize = [ + "{major}.{minor}.{patch}.{pre_l}{pre_n}", + "{major}.{minor}.{patch}", +] +search = "{current_version}" +replace = "{new_version}" +regex = false +ignore_missing_version = false +ignore_missing_files = false +tag = false +sign_tags = false +tag_name = "v{new_version}" +tag_message = "Bump version: {current_version} → {new_version}" +allow_dirty = false +commit = false +message = "Bump version: {current_version} → {new_version}" +commit_args = "" + +[tool.bumpversion.parts.pre_l] +values = ["dev"] diff --git a/requirements-dev.txt b/requirements-dev.txt index 12224ac8..512f7b7c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,4 +3,5 @@ tox pytest setuptools sphinx -furo \ No newline at end of file +furo +bump-my-version \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index ad7d8ae3..55c8c5ed 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] name = poli -version = 0.2.1 -author_email = bartels@di.ku.dk +version = "1.0.0.dev0" +author_email = miguel.gonzalez-duque@bio.ku.dk description = Protein Objectives Library long_description = file: README.md long_description_content_type = text/markdown @@ -14,7 +14,7 @@ classifiers = package_dir = =src packages = find: -python_requires = >=3.6 +python_requires = >=3.8 include_package_data = True [options.packages.find] diff --git a/src/poli/__init__.py b/src/poli/__init__.py index 6bb5b772..0051466e 100644 --- a/src/poli/__init__.py +++ b/src/poli/__init__.py @@ -1,6 +1,6 @@ """poli, a library for discrete black-box objective functions.""" -__author__ = "Simon Bartels & Miguel González-Duque (MLLS)" +__version__ = "1.0.0.dev0" from .core.util.isolation.instancing import instance_function_as_isolated_process # from .core import get_problems From 316e2b574aaabef5657bb75c2dadf1ed68f68fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Gonz=C3=A1lez=20Duque?= Date: Wed, 7 Aug 2024 14:26:40 +0200 Subject: [PATCH 3/5] Cleans ProblemSetupInformation (#236) * Cleans ProblemSetupInformation * Adds files to bumpversion * tries to fix a bug on bump * Bumps version --- pyproject.toml | 18 ++- src/poli/__init__.py | 2 +- src/poli/core/problem_setup_information.py | 105 ------------------ src/poli/core/proteins/foldx_black_box.py | 4 +- .../objective_repository/aloha/register.py | 3 +- 5 files changed, 18 insertions(+), 114 deletions(-) delete mode 100644 src/poli/core/problem_setup_information.py diff --git a/pyproject.toml b/pyproject.toml index 873b828c..f5f28f1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "poli" -version = "1.0.0.dev0" +version = "1.0.0.dev1" description = "poli, a library of discrete objective functions" readme = "README.md" authors = [{name="Miguel González-Duque", email="miguelgondu@gmail.com"}, {name="Simon Bartels"}] @@ -53,7 +53,7 @@ profile = "black" exclude = ["src/poli/core/util/proteins/rasp/inner_rasp", "src/poli/objective_repository/gfp_cbas"] [tool.bumpversion] -current_version = "1.0.0.dev0" +current_version = "1.0.0.dev1" parse = """(?x) (?P0|[1-9]\\d*)\\. (?P0|[1-9]\\d*)\\. @@ -68,8 +68,8 @@ serialize = [ "{major}.{minor}.{patch}.{pre_l}{pre_n}", "{major}.{minor}.{patch}", ] -search = "{current_version}" -replace = "{new_version}" +search = 'current_version = "{current_version}"' +replace = 'current_version = "{new_version}"' regex = false ignore_missing_version = false ignore_missing_files = false @@ -84,3 +84,13 @@ commit_args = "" [tool.bumpversion.parts.pre_l] values = ["dev"] + +[[tool.bumpversion.files]] +filename = "pyproject.toml" +search = 'version = "{current_version}"' +replace = 'version = "{new_version}"' + +[[tool.bumpversion.files]] +filename = "src/poli/__init__.py" +search = '__version__ = "{current_version}"' +replace = '__version__ = "{new_version}"' \ No newline at end of file diff --git a/src/poli/__init__.py b/src/poli/__init__.py index 0051466e..58db5c65 100644 --- a/src/poli/__init__.py +++ b/src/poli/__init__.py @@ -1,6 +1,6 @@ """poli, a library for discrete black-box objective functions.""" -__version__ = "1.0.0.dev0" +__version__ = "1.0.0.dev1" from .core.util.isolation.instancing import instance_function_as_isolated_process # from .core import get_problems diff --git a/src/poli/core/problem_setup_information.py b/src/poli/core/problem_setup_information.py deleted file mode 100644 index c934fb4a..00000000 --- a/src/poli/core/problem_setup_information.py +++ /dev/null @@ -1,105 +0,0 @@ -""" -Implements the problem setup information, which contains the problem information (e.g. alphabet, sequence length...). -""" - -from poli.core.black_box_information import BlackBoxInformation - - -class ProblemSetupInformation: - def __init__( - self, - name: str, - black_box_information: BlackBoxInformation, - ): - """ - Initialize the ProblemSetupInformation object. - - Parameters - ---------- - name : str - The problem's name. - """ - self.name = name - self.black_box_information = black_box_information - - def get_problem_name(self) -> str: - """Returns the problem's name. - - Returns - -------- - name : str - The problem's name. - """ - return self.name - - def get_max_sequence_length(self) -> int: - """ - Returns the maximum sequence length allowed by the black-box. - - Returns - -------- - max_sequence_length : int - The length of the longest sequence. - """ - return self.max_sequence_length - - def sequences_are_aligned(self) -> bool: - """ - Returns whether the sequences need to be aligned. - - Returns - -------- - aligned : bool - Whether the sequences need to be aligned. - """ - return self.aligned - - def get_alphabet(self) -> list: - """ - Returns the alphabet of allowed characters. - - Returns - -------- - alphabet : list[str] - List of tokens allowed by the black-box. - """ - return self.alphabet - - def log_transform_recommended(self) -> bool: - """ - Returns whether the black-box recommends log-transforming the targets. - - Returns - -------- - log_transform_recommended : bool - Whether the black-box recommends log-transforming the targets. - """ - return self.log_transform_recommended - - def as_dict(self) -> dict: - """Returns all attributes as a dictionary. - - Returns - -------- - info : dict - A dictionary of all attributes. - - Notes - ----- - - It's vital that this method is _not_ called __dict__, since - that breaks the serialization of the ProblemSetupInformation - when using pickle. (see https://stackoverflow.com/a/75777082/3516175) - """ - return { - "name": self.name, - "max_sequence_length": self.max_sequence_length, - "aligned": self.aligned, - "alphabet": self.alphabet, - "log_transform_recommended": self.log_transform_recommended, - } - - def __str__(self) -> str: - return f"ProblemSetupInformation(name={self.name})" - - def __repr__(self) -> str: - return f"" diff --git a/src/poli/core/proteins/foldx_black_box.py b/src/poli/core/proteins/foldx_black_box.py index 100496d8..7c404f9b 100644 --- a/src/poli/core/proteins/foldx_black_box.py +++ b/src/poli/core/proteins/foldx_black_box.py @@ -18,7 +18,7 @@ from uuid import uuid4 from poli.core.abstract_black_box import AbstractBlackBox -from poli.core.problem_setup_information import ProblemSetupInformation +from poli.core.black_box_information import BlackBoxInformation from poli.core.util.proteins.foldx import FoldxInterface from poli.core.util.proteins.pdb_parsing import ( parse_pdb_as_residue_strings, @@ -85,7 +85,7 @@ class FoldxBlackBox(AbstractBlackBox): def __init__( self, - info: ProblemSetupInformation = None, + info: BlackBoxInformation = None, batch_size: int = None, parallelize: bool = False, num_workers: int = None, diff --git a/src/poli/objective_repository/aloha/register.py b/src/poli/objective_repository/aloha/register.py index 9b0f1465..0a8b04ab 100644 --- a/src/poli/objective_repository/aloha/register.py +++ b/src/poli/objective_repository/aloha/register.py @@ -18,7 +18,6 @@ from poli.core.abstract_problem_factory import AbstractProblemFactory from poli.core.black_box_information import BlackBoxInformation from poli.core.problem import Problem -from poli.core.problem_setup_information import ProblemSetupInformation from poli.core.util.seeding import seed_python_numpy_and_torch @@ -147,7 +146,7 @@ class AlohaProblemFactory(AbstractProblemFactory): """ @staticmethod - def get_setup_information() -> ProblemSetupInformation: + def get_setup_information() -> BlackBoxInformation: """ Returns the setup information for the problem. From 2ad13d93e4f60dbaa50a4c0e227beaad8c91710d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Gonz=C3=A1lez=20Duque?= Date: Wed, 7 Aug 2024 21:23:46 +0200 Subject: [PATCH 4/5] Makes black box information dynamic (#237) * Makes information getting dynamic instead of static * Removes information from zaleplon, adds self * Forgot to remove staticmethod in deco hop * Updates the poli tdc env due to tiledbsoma dependency * Makes sure the names can computed from benchmark object * Cleans up docstrings of setup methods * Updates separator for bumpversion * Bumps version --- pyproject.toml | 6 +-- src/poli/__init__.py | 2 +- src/poli/core/abstract_benchmark.py | 6 ++- src/poli/core/abstract_black_box.py | 5 +-- src/poli/core/abstract_problem_factory.py | 30 ++------------ src/poli/core/chemistry/environment.yml | 2 +- .../albuterol_similarity/information.py | 15 ------- .../albuterol_similarity/register.py | 31 ++++++--------- .../objective_repository/aloha/register.py | 30 ++------------ .../amlodipine_mpo/information.py | 15 ------- .../amlodipine_mpo/register.py | 29 ++++++-------- .../celecoxib_rediscovery/information.py | 15 ------- .../celecoxib_rediscovery/register.py | 31 ++++++--------- .../deco_hop/information.py | 15 ------- .../objective_repository/deco_hop/register.py | 29 ++++++-------- .../dockstring/information.py | 15 ------- .../dockstring/register.py | 27 ++++++------- .../drd2_docking/information.py | 15 ------- .../drd2_docking/register.py | 29 ++++++-------- .../drd3_docking/information.py | 15 ------- .../drd3_docking/register.py | 29 ++++++-------- .../ehrlich/information.py | 15 ------- .../objective_repository/ehrlich/register.py | 22 ++++++----- .../fexofenadine_mpo/information.py | 15 ------- .../fexofenadine_mpo/register.py | 29 ++++++-------- .../foldx_rfp_lambo/information.py | 14 ------- .../foldx_rfp_lambo/register.py | 23 ++++++----- .../foldx_sasa/information.py | 17 -------- .../foldx_sasa/register.py | 39 +++++++------------ .../foldx_stability/information.py | 17 -------- .../foldx_stability/register.py | 34 +++++++--------- .../foldx_stability_and_sasa/information.py | 17 -------- .../foldx_stability_and_sasa/register.py | 38 +++++++----------- .../objective_repository/gfp_cbas/register.py | 35 ++++++++--------- .../gfp_select/register.py | 28 ++++++------- .../gsk3_beta/information.py | 15 ------- .../gsk3_beta/register.py | 31 +++++++-------- .../isomer_c7h8n2o2/information.py | 15 ------- .../isomer_c7h8n2o2/register.py | 29 ++++++-------- .../isomer_c9h10n2o2pf2cl/information.py | 15 ------- .../isomer_c9h10n2o2pf2cl/register.py | 31 ++++++--------- .../objective_repository/jnk3/information.py | 15 ------- .../objective_repository/jnk3/register.py | 29 ++++++-------- .../median_1/information.py | 15 ------- .../objective_repository/median_1/register.py | 29 ++++++-------- .../median_2/information.py | 15 ------- .../objective_repository/median_2/register.py | 29 ++++++-------- .../mestranol_similarity/information.py | 15 ------- .../mestranol_similarity/register.py | 31 ++++++--------- .../osimetrinib_mpo/information.py | 15 ------- .../osimetrinib_mpo/register.py | 29 ++++++-------- .../penalized_logp_lambo/information.py | 16 -------- .../penalized_logp_lambo/register.py | 26 ++++++------- .../perindopril_mpo/information.py | 15 ------- .../perindopril_mpo/register.py | 29 ++++++-------- .../ranolazine_mpo/information.py | 15 ------- .../ranolazine_mpo/register.py | 29 ++++++-------- .../objective_repository/rasp/information.py | 17 -------- .../objective_repository/rasp/register.py | 26 ++++++++----- .../rdkit_logp/information.py | 16 -------- .../rdkit_logp/register.py | 29 +++++++------- .../rdkit_qed/information.py | 16 -------- .../rdkit_qed/register.py | 22 ++++++----- .../information.py | 17 -------- .../rfp_foldx_stability_and_sasa/register.py | 22 ----------- .../rmf_landscape/information.py | 15 ------- .../rmf_landscape/register.py | 21 +++++----- .../objective_repository/sa_tdc/register.py | 29 ++++++-------- .../scaffold_hop/register.py | 29 ++++++-------- .../sitagliptin_mpo/register.py | 31 +++++++-------- .../super_mario_bros/register.py | 27 +++++++------ .../thiothixene_rediscovery/information.py | 15 ------- .../thiothixene_rediscovery/register.py | 31 ++++++--------- .../toy_continuous_problem/information.py | 15 ------- .../toy_continuous_problem/register.py | 31 +++++++-------- .../troglitazone_rediscovery/information.py | 15 ------- .../troglitazone_rediscovery/register.py | 31 ++++++--------- .../valsartan_smarts/information.py | 15 ------- .../valsartan_smarts/register.py | 29 ++++++-------- .../white_noise/register.py | 25 +----------- .../zaleplon_mpo/information.py | 15 ------- .../zaleplon_mpo/register.py | 29 ++++++-------- .../benchmarks/test_benchmark_creation.py | 31 +++++++++++++++ src/poli/tests/information/__init__.py | 0 .../information/test_dynamic_information.py | 10 +++++ 85 files changed, 558 insertions(+), 1273 deletions(-) delete mode 100644 src/poli/objective_repository/albuterol_similarity/information.py delete mode 100644 src/poli/objective_repository/amlodipine_mpo/information.py delete mode 100644 src/poli/objective_repository/celecoxib_rediscovery/information.py delete mode 100644 src/poli/objective_repository/deco_hop/information.py delete mode 100644 src/poli/objective_repository/dockstring/information.py delete mode 100644 src/poli/objective_repository/drd2_docking/information.py delete mode 100644 src/poli/objective_repository/drd3_docking/information.py delete mode 100644 src/poli/objective_repository/ehrlich/information.py delete mode 100644 src/poli/objective_repository/fexofenadine_mpo/information.py delete mode 100644 src/poli/objective_repository/foldx_sasa/information.py delete mode 100644 src/poli/objective_repository/foldx_stability/information.py delete mode 100644 src/poli/objective_repository/foldx_stability_and_sasa/information.py delete mode 100644 src/poli/objective_repository/gsk3_beta/information.py delete mode 100644 src/poli/objective_repository/isomer_c7h8n2o2/information.py delete mode 100644 src/poli/objective_repository/isomer_c9h10n2o2pf2cl/information.py delete mode 100644 src/poli/objective_repository/jnk3/information.py delete mode 100644 src/poli/objective_repository/median_1/information.py delete mode 100644 src/poli/objective_repository/median_2/information.py delete mode 100644 src/poli/objective_repository/mestranol_similarity/information.py delete mode 100644 src/poli/objective_repository/osimetrinib_mpo/information.py delete mode 100644 src/poli/objective_repository/penalized_logp_lambo/information.py delete mode 100644 src/poli/objective_repository/perindopril_mpo/information.py delete mode 100644 src/poli/objective_repository/ranolazine_mpo/information.py delete mode 100644 src/poli/objective_repository/rasp/information.py delete mode 100644 src/poli/objective_repository/rdkit_logp/information.py delete mode 100644 src/poli/objective_repository/rdkit_qed/information.py delete mode 100644 src/poli/objective_repository/rfp_foldx_stability_and_sasa/information.py delete mode 100644 src/poli/objective_repository/rmf_landscape/information.py delete mode 100644 src/poli/objective_repository/thiothixene_rediscovery/information.py delete mode 100644 src/poli/objective_repository/toy_continuous_problem/information.py delete mode 100644 src/poli/objective_repository/troglitazone_rediscovery/information.py delete mode 100644 src/poli/objective_repository/valsartan_smarts/information.py delete mode 100644 src/poli/objective_repository/zaleplon_mpo/information.py create mode 100644 src/poli/tests/information/__init__.py create mode 100644 src/poli/tests/information/test_dynamic_information.py diff --git a/pyproject.toml b/pyproject.toml index f5f28f1b..b63a1725 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "poli" -version = "1.0.0.dev1" +version = "1.0.0.dev2" description = "poli, a library of discrete objective functions" readme = "README.md" authors = [{name="Miguel González-Duque", email="miguelgondu@gmail.com"}, {name="Simon Bartels"}] @@ -53,13 +53,13 @@ profile = "black" exclude = ["src/poli/core/util/proteins/rasp/inner_rasp", "src/poli/objective_repository/gfp_cbas"] [tool.bumpversion] -current_version = "1.0.0.dev1" +current_version = "1.0.0.dev2" parse = """(?x) (?P0|[1-9]\\d*)\\. (?P0|[1-9]\\d*)\\. (?P0|[1-9]\\d*) (?: - - # dash separator for pre-release section + . # dash separator for pre-release section (?P[a-zA-Z-]+) # pre-release label (?P0|[1-9]\\d*) # pre-release version number )? # pre-release section is optional diff --git a/src/poli/__init__.py b/src/poli/__init__.py index 58db5c65..7f05ae41 100644 --- a/src/poli/__init__.py +++ b/src/poli/__init__.py @@ -1,6 +1,6 @@ """poli, a library for discrete black-box objective functions.""" -__version__ = "1.0.0.dev1" +__version__ = "1.0.0.dev2" from .core.util.isolation.instancing import instance_function_as_isolated_process # from .core import get_problems diff --git a/src/poli/core/abstract_benchmark.py b/src/poli/core/abstract_benchmark.py index f2d6f256..5204a3c2 100644 --- a/src/poli/core/abstract_benchmark.py +++ b/src/poli/core/abstract_benchmark.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import List, Union from poli.core.abstract_problem_factory import AbstractProblemFactory @@ -46,6 +48,8 @@ def info(self) -> str: @property def problem_names(self) -> List[str]: return [ - problem_factory.get_setup_information().name + problem_factory.__module__.replace( + "poli.objective_repository.", "" + ).replace(".register", "") for problem_factory in self.problem_factories ] diff --git a/src/poli/core/abstract_black_box.py b/src/poli/core/abstract_black_box.py index fea9761b..327e07a5 100644 --- a/src/poli/core/abstract_black_box.py +++ b/src/poli/core/abstract_black_box.py @@ -105,15 +105,14 @@ def __init__( self.batch_size = batch_size - @staticmethod - def get_black_box_info() -> BlackBoxInformation: + def get_black_box_info(self) -> BlackBoxInformation: raise NotImplementedError( "Black box information must be implemented in subclasses." ) @property def info(self) -> BlackBoxInformation: - return self.__class__.get_black_box_info() + return self.get_black_box_info() def set_observer(self, observer: AbstractObserver): """ diff --git a/src/poli/core/abstract_problem_factory.py b/src/poli/core/abstract_problem_factory.py index 1cc410ee..73ca3854 100644 --- a/src/poli/core/abstract_problem_factory.py +++ b/src/poli/core/abstract_problem_factory.py @@ -1,6 +1,5 @@ """This module implements the abstract problem factory.""" -from poli.core.black_box_information import BlackBoxInformation from poli.core.problem import Problem @@ -11,12 +10,7 @@ class MetaProblemFactory(type): """ def __repr__(cls) -> str: - try: - problem_info = cls().get_setup_information() - except NotImplementedError: - return f"<{cls.__name__}()>" - - return f"<{cls.__name__}(L={problem_info.max_sequence_length})>" + return f"<{cls.__name__}()>" def __str__(cls) -> str: return f"{cls.__name__}" @@ -30,28 +24,10 @@ class AbstractProblemFactory(metaclass=MetaProblemFactory): Methods ------- - get_setup_information: - Returns the setup information for the problem. create: Creates a problem instance with the specified parameters. """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Returns the setup information for the problem. - - Returns - -------- - problem_info: BlackBoxInformation - Information for the problem (e.g. whether it is discrete, deterministic...). - - Raises - ------- - NotImplementedError: - This method is abstract and must be implemented by subclasses. - """ - raise NotImplementedError("abstract method") - def create( self, seed: int = None, @@ -90,4 +66,6 @@ def create( NotImplementedError: This method is abstract and must be implemented by subclasses. """ - raise NotImplementedError("abstract method") + raise NotImplementedError( + "Abstract method create() must be implemented by subclasses." + ) diff --git a/src/poli/core/chemistry/environment.yml b/src/poli/core/chemistry/environment.yml index e9348d00..9368cc9b 100644 --- a/src/poli/core/chemistry/environment.yml +++ b/src/poli/core/chemistry/environment.yml @@ -19,7 +19,7 @@ dependencies: - cachetools - rdkit - selfies - - pytdc==0.4.7 + - pytdc - pyscreener - colorama - configparse diff --git a/src/poli/objective_repository/albuterol_similarity/information.py b/src/poli/objective_repository/albuterol_similarity/information.py deleted file mode 100644 index cb7e998b..00000000 --- a/src/poli/objective_repository/albuterol_similarity/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -albuterol_similarity_info = BlackBoxInformation( - name="albuterol_similarity", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/albuterol_similarity/register.py b/src/poli/objective_repository/albuterol_similarity/register.py index 8f0bb099..61f4978b 100644 --- a/src/poli/objective_repository/albuterol_similarity/register.py +++ b/src/poli/objective_repository/albuterol_similarity/register.py @@ -28,9 +28,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.albuterol_similarity.information import ( - albuterol_similarity_info, -) class AlbuterolSimilarityBlackBox(TDCBlackBox): @@ -97,9 +94,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return albuterol_similarity_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="albuterol_similarity", + max_sequence_length=np.inf, # TODO: How should we determine this? + aligned=False, + fixed_length=False, + deterministic=True, + alphabet=None, # TODO: add default alphabet + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class AlbuterolSimilarityProblemFactory(AbstractProblemFactory): @@ -110,8 +116,6 @@ class AlbuterolSimilarityProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an Albuterol Similarity problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -126,17 +130,6 @@ class AlbuterolSimilarityProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return albuterol_similarity_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/aloha/register.py b/src/poli/objective_repository/aloha/register.py index 0a8b04ab..dc0352b1 100644 --- a/src/poli/objective_repository/aloha/register.py +++ b/src/poli/objective_repository/aloha/register.py @@ -81,8 +81,7 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: + def get_black_box_info(self) -> BlackBoxInformation: return BlackBoxInformation( name="aloha", max_sequence_length=5, @@ -138,35 +137,10 @@ class AlohaProblemFactory(AbstractProblemFactory): Methods ------- - get_setup_information() - Returns the setup information for the problem. - create(...) Creates a problem instance with the specified parameters. """ - @staticmethod - def get_setup_information() -> BlackBoxInformation: - """ - Returns the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return BlackBoxInformation( - name="aloha", - max_sequence_length=5, - aligned=True, - fixed_length=True, - deterministic=True, - alphabet=list(ascii_uppercase), - log_transform_recommended=False, - discrete=True, - padding_token="", - ) - def create( self, seed: int = None, @@ -191,6 +165,8 @@ def create( The number of workers for parallel evaluation. Default is None. evaluation_budget: int, optional The maximum number of function evaluations. Default is infinity. + force_isolation: bool, optional + Unused in this black box, since it runs directly on the base environment. Returns -------- diff --git a/src/poli/objective_repository/amlodipine_mpo/information.py b/src/poli/objective_repository/amlodipine_mpo/information.py deleted file mode 100644 index 127a9d89..00000000 --- a/src/poli/objective_repository/amlodipine_mpo/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -amlodipine_mpo_info = BlackBoxInformation( - name="amlodipine_mpo", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/amlodipine_mpo/register.py b/src/poli/objective_repository/amlodipine_mpo/register.py index eab1b686..87665de0 100644 --- a/src/poli/objective_repository/amlodipine_mpo/register.py +++ b/src/poli/objective_repository/amlodipine_mpo/register.py @@ -24,7 +24,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.amlodipine_mpo.information import amlodipine_mpo_info class AmlodipineMPOBlackBox(TDCBlackBox): @@ -90,9 +89,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return amlodipine_mpo_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="amlodipine_mpo", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, + alphabet=None, # TODO: add default alphabet. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class AmlodipineMPOProblemFactory(AbstractProblemFactory): @@ -105,8 +113,6 @@ class AmlodipineMPOProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an AmlodipineMPO problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -121,17 +127,6 @@ class AmlodipineMPOProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return amlodipine_mpo_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/celecoxib_rediscovery/information.py b/src/poli/objective_repository/celecoxib_rediscovery/information.py deleted file mode 100644 index 0f834c69..00000000 --- a/src/poli/objective_repository/celecoxib_rediscovery/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -celecoxib_rediscovery_info = BlackBoxInformation( - name="celecoxib_rediscovery", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/celecoxib_rediscovery/register.py b/src/poli/objective_repository/celecoxib_rediscovery/register.py index a8d40f5b..55853b98 100644 --- a/src/poli/objective_repository/celecoxib_rediscovery/register.py +++ b/src/poli/objective_repository/celecoxib_rediscovery/register.py @@ -26,9 +26,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.celecoxib_rediscovery.information import ( - celecoxib_rediscovery_info, -) class CelecoxibRediscoveryBlackBox(TDCBlackBox): @@ -94,9 +91,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return celecoxib_rediscovery_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="celecoxib_rediscovery", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class CelecoxibRediscoveryProblemFactory(AbstractProblemFactory): @@ -109,8 +115,6 @@ class CelecoxibRediscoveryProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates a Celecoxib rediscovery problem. @@ -124,17 +128,6 @@ class CelecoxibRediscoveryProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return celecoxib_rediscovery_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/deco_hop/information.py b/src/poli/objective_repository/deco_hop/information.py deleted file mode 100644 index 44155cf9..00000000 --- a/src/poli/objective_repository/deco_hop/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -deco_hop_info = BlackBoxInformation( - name="deco_hop", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/deco_hop/register.py b/src/poli/objective_repository/deco_hop/register.py index a100c328..e39b03d1 100644 --- a/src/poli/objective_repository/deco_hop/register.py +++ b/src/poli/objective_repository/deco_hop/register.py @@ -26,7 +26,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.deco_hop.information import deco_hop_info class DecoHopBlackBox(TDCBlackBox): @@ -93,9 +92,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return deco_hop_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="deco_hop", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class DecoHopProblemFactory(AbstractProblemFactory): @@ -106,8 +114,6 @@ class DecoHopProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an Decorator Hop problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -122,17 +128,6 @@ class DecoHopProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return deco_hop_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/dockstring/information.py b/src/poli/objective_repository/dockstring/information.py deleted file mode 100644 index b75776ab..00000000 --- a/src/poli/objective_repository/dockstring/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -dockstring_black_box_information = BlackBoxInformation( - name="dockstring", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, - alphabet=None, # TODO: fix when we have a smiles alphabet - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/dockstring/register.py b/src/poli/objective_repository/dockstring/register.py index bc7cb86d..3d630a77 100644 --- a/src/poli/objective_repository/dockstring/register.py +++ b/src/poli/objective_repository/dockstring/register.py @@ -27,9 +27,6 @@ from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.isolation.instancing import get_inner_function from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.dockstring.information import ( - dockstring_black_box_information, -) class DockstringBlackBox(AbstractBlackBox): @@ -164,9 +161,18 @@ def _black_box(self, x: np.ndarray, context=None) -> np.ndarray: ) return inner_function(x, context=context) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return dockstring_black_box_information + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="dockstring", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, + alphabet=None, # TODO: fix when we have a smiles alphabet + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class DockstringProblemFactory(AbstractProblemFactory): @@ -177,8 +183,6 @@ class DockstringProblemFactory(AbstractProblemFactory): Methods ------- - get_setup_information() - Returns the setup information for the problem. create(...) Creates a problem instance with the specified parameters. @@ -191,13 +195,6 @@ class DockstringProblemFactory(AbstractProblemFactory): https://doi.org/10.1021/acs.jcim.1c01334. """ - @staticmethod - def get_setup_information() -> BlackBoxInformation: - # TODO: We might change this in the future for a - # default dictionary, depending on whether we - # are using SMILES or SELFIES. - return dockstring_black_box_information - def create( self, target_name: str, diff --git a/src/poli/objective_repository/drd2_docking/information.py b/src/poli/objective_repository/drd2_docking/information.py deleted file mode 100644 index 43680cbf..00000000 --- a/src/poli/objective_repository/drd2_docking/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -drd2_docking_info = BlackBoxInformation( - name="drd2_docking", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/drd2_docking/register.py b/src/poli/objective_repository/drd2_docking/register.py index 23962c4c..ae326618 100644 --- a/src/poli/objective_repository/drd2_docking/register.py +++ b/src/poli/objective_repository/drd2_docking/register.py @@ -27,7 +27,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.drd2_docking.information import drd2_docking_info class DRD2BlackBox(TDCBlackBox): @@ -92,9 +91,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return drd2_docking_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="drd2_docking", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class DRD2ProblemFactory(AbstractProblemFactory): @@ -105,8 +113,6 @@ class DRD2ProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates a DRD2 docking problem. @@ -122,17 +128,6 @@ class DRD2ProblemFactory(AbstractProblemFactory): """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return drd2_docking_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/drd3_docking/information.py b/src/poli/objective_repository/drd3_docking/information.py deleted file mode 100644 index fdbbcf1d..00000000 --- a/src/poli/objective_repository/drd3_docking/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -drd3_docking_info = BlackBoxInformation( - name="drd3_docking", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/drd3_docking/register.py b/src/poli/objective_repository/drd3_docking/register.py index e6557fc7..62de99a2 100644 --- a/src/poli/objective_repository/drd3_docking/register.py +++ b/src/poli/objective_repository/drd3_docking/register.py @@ -18,7 +18,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.drd3_docking.information import drd3_docking_info class DRD3BlackBox(TDCBlackBox): @@ -71,9 +70,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return drd3_docking_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="drd3_docking", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class DRD3ProblemFactory(AbstractProblemFactory): @@ -84,23 +92,10 @@ class DRD3ProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates a DRD3 docking problem. """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return drd3_docking_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/ehrlich/information.py b/src/poli/objective_repository/ehrlich/information.py deleted file mode 100644 index 45e4032a..00000000 --- a/src/poli/objective_repository/ehrlich/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -ehrlich_info = BlackBoxInformation( - name="ehrlich", - max_sequence_length=np.inf, - aligned=True, - fixed_length=True, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/ehrlich/register.py b/src/poli/objective_repository/ehrlich/register.py index b3cc3baf..ff070f86 100644 --- a/src/poli/objective_repository/ehrlich/register.py +++ b/src/poli/objective_repository/ehrlich/register.py @@ -36,7 +36,6 @@ from poli.objective_repository.ehrlich._construct_feasibility_matrix import ( _construct_transition_matrix, ) -from poli.objective_repository.ehrlich.information import ehrlich_info class EhrlichBlackBox(AbstractBlackBox): @@ -347,9 +346,18 @@ def _black_box(self, x: np.ndarray, context=None) -> np.ndarray: return np.array(values).reshape(-1, 1) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return ehrlich_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="ehrlich", + max_sequence_length=self.sequence_length, + aligned=True, + fixed_length=True, + deterministic=True, # ? + alphabet=self.alphabet, + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class EhrlichProblemFactory(AbstractProblemFactory): @@ -363,12 +371,6 @@ class EhrlichProblemFactory(AbstractProblemFactory): arXiv preprint arXiv:2407.00236. https://arxiv.org/abs/2407.00236 """ - def __init__(self) -> None: - super().__init__() - - def get_setup_information(self) -> BlackBoxInformation: - return ehrlich_info - def create( self, sequence_length: int, diff --git a/src/poli/objective_repository/fexofenadine_mpo/information.py b/src/poli/objective_repository/fexofenadine_mpo/information.py deleted file mode 100644 index b0938290..00000000 --- a/src/poli/objective_repository/fexofenadine_mpo/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -fexofenadine_mpo_info = BlackBoxInformation( - name="fexofenadine_mpo", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/fexofenadine_mpo/register.py b/src/poli/objective_repository/fexofenadine_mpo/register.py index 5cf09978..241717bd 100644 --- a/src/poli/objective_repository/fexofenadine_mpo/register.py +++ b/src/poli/objective_repository/fexofenadine_mpo/register.py @@ -25,7 +25,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.fexofenadine_mpo.information import fexofenadine_mpo_info class FexofenadineMPOBlackBox(TDCBlackBox): @@ -90,9 +89,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return fexofenadine_mpo_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="fexofenadine_mpo", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class FexofenadineMPOProblemFactory(AbstractProblemFactory): @@ -103,8 +111,6 @@ class FexofenadineMPOProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an Fexofenadine MPO problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -119,17 +125,6 @@ class FexofenadineMPOProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return fexofenadine_mpo_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/foldx_rfp_lambo/information.py b/src/poli/objective_repository/foldx_rfp_lambo/information.py index dab0fb43..3593acfc 100644 --- a/src/poli/objective_repository/foldx_rfp_lambo/information.py +++ b/src/poli/objective_repository/foldx_rfp_lambo/information.py @@ -1,5 +1,3 @@ -from poli.core.black_box_information import BlackBoxInformation - AMINO_ACIDS = [ "A", "R", @@ -22,15 +20,3 @@ "Y", "V", ] - -foldx_rfp_lambo_information = BlackBoxInformation( - name="foldx_rfp_lambo", - max_sequence_length=244, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=AMINO_ACIDS, - discrete=True, - fidelity=None, - padding_token="-", -) diff --git a/src/poli/objective_repository/foldx_rfp_lambo/register.py b/src/poli/objective_repository/foldx_rfp_lambo/register.py index 4dc011c5..dec62c2a 100644 --- a/src/poli/objective_repository/foldx_rfp_lambo/register.py +++ b/src/poli/objective_repository/foldx_rfp_lambo/register.py @@ -12,10 +12,7 @@ from poli.core.util.isolation.instancing import instance_function_as_isolated_process from poli.core.util.seeding import seed_python_numpy_and_torch from poli.objective_repository.foldx_rfp_lambo import CORRECT_SEQ, PROBLEM_SEQ -from poli.objective_repository.foldx_rfp_lambo.information import ( - AMINO_ACIDS, - foldx_rfp_lambo_information, -) +from poli.objective_repository.foldx_rfp_lambo.information import AMINO_ACIDS class FoldXRFPLamboBlackBox(AbstractBlackBox): @@ -60,9 +57,18 @@ def __init__( def _black_box(self, x, context=None): return self.inner_function(x, context) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return foldx_rfp_lambo_information + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="foldx_rfp_lambo", + max_sequence_length=244, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=AMINO_ACIDS, + discrete=True, + fidelity=None, + padding_token="-", + ) class FoldXRFPLamboProblemFactory(AbstractProblemFactory): @@ -71,9 +77,6 @@ def __init__(self): self.problem_sequence = PROBLEM_SEQ self.correct_sequence = CORRECT_SEQ - def get_setup_information(self) -> BlackBoxInformation: - return foldx_rfp_lambo_information - def create( self, seed: int = None, diff --git a/src/poli/objective_repository/foldx_sasa/information.py b/src/poli/objective_repository/foldx_sasa/information.py deleted file mode 100644 index 0bf1f06d..00000000 --- a/src/poli/objective_repository/foldx_sasa/information.py +++ /dev/null @@ -1,17 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation -from poli.core.util.proteins.defaults import AMINO_ACIDS - -foldx_sasa_info = BlackBoxInformation( - name="foldx_sasa", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, - alphabet=AMINO_ACIDS, - log_transform_recommended=False, - discrete=True, - fidelity=None, - padding_token="", -) diff --git a/src/poli/objective_repository/foldx_sasa/register.py b/src/poli/objective_repository/foldx_sasa/register.py index b6df5b6b..f72cef59 100644 --- a/src/poli/objective_repository/foldx_sasa/register.py +++ b/src/poli/objective_repository/foldx_sasa/register.py @@ -25,8 +25,8 @@ from poli.core.exceptions import FoldXNotFoundException from poli.core.problem import Problem from poli.core.util.isolation.instancing import get_inner_function +from poli.core.util.proteins.defaults import AMINO_ACIDS from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.foldx_sasa.information import foldx_sasa_info class FoldXSASABlackBox(AbstractBlackBox): @@ -138,9 +138,19 @@ def _black_box(self, x: np.ndarray, context: None) -> np.ndarray: ) return inner_function(x, context) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return foldx_sasa_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="foldx_sasa", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, + alphabet=AMINO_ACIDS, + log_transform_recommended=False, + discrete=True, + fidelity=None, + padding_token="", + ) class FoldXSASAProblemFactory(AbstractProblemFactory): @@ -149,31 +159,10 @@ class FoldXSASAProblemFactory(AbstractProblemFactory): Methods ------- - get_setup_information: - Returns the setup information for the problem. create: Creates a problem instance with the specified parameters. """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Get the setup information for the foldx_sasa objective. - - Returns - ------- - ProblemSetupInformation - The setup information for the objective. - - Notes - ----- - By default, the method uses the 20 amino acids shown in - poli.core.util.proteins.defaults. - - """ - # By default, we use the 20 amino acids shown in - # poli.core.util.proteins.defaults - return foldx_sasa_info - def create( self, wildtype_pdb_path: Union[Path, List[Path]], diff --git a/src/poli/objective_repository/foldx_stability/information.py b/src/poli/objective_repository/foldx_stability/information.py deleted file mode 100644 index f805bb0b..00000000 --- a/src/poli/objective_repository/foldx_stability/information.py +++ /dev/null @@ -1,17 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation -from poli.core.util.proteins.defaults import AMINO_ACIDS - -foldx_stability_info = BlackBoxInformation( - name="foldx_stability", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, - alphabet=AMINO_ACIDS, - log_transform_recommended=False, - discrete=True, - fidelity=None, - padding_token="", -) diff --git a/src/poli/objective_repository/foldx_stability/register.py b/src/poli/objective_repository/foldx_stability/register.py index fe1af98e..45c70f92 100644 --- a/src/poli/objective_repository/foldx_stability/register.py +++ b/src/poli/objective_repository/foldx_stability/register.py @@ -27,8 +27,8 @@ from poli.core.exceptions import FoldXNotFoundException from poli.core.problem import Problem from poli.core.util.isolation.instancing import get_inner_function +from poli.core.util.proteins.defaults import AMINO_ACIDS from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.foldx_stability.information import foldx_stability_info class FoldXStabilityBlackBox(AbstractBlackBox): @@ -149,28 +149,22 @@ def _black_box(self, x: np.ndarray, context: None) -> np.ndarray: ) return inner_function(x, context) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return foldx_stability_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="foldx_stability", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, + alphabet=AMINO_ACIDS, + log_transform_recommended=False, + discrete=True, + fidelity=None, + padding_token="", + ) class FoldXStabilityProblemFactory(AbstractProblemFactory): - def get_setup_information(self) -> BlackBoxInformation: - """ - Get the setup information for the foldx_sasa objective. - - Returns - ------- - ProblemSetupInformation - The setup information for the objective. - - Notes - ----- - By default, the method uses the 20 amino acids shown in - poli.core.util.proteins.defaults. - """ - return foldx_stability_info - def create( self, wildtype_pdb_path: Union[Path, List[Path]], diff --git a/src/poli/objective_repository/foldx_stability_and_sasa/information.py b/src/poli/objective_repository/foldx_stability_and_sasa/information.py deleted file mode 100644 index 1942ae88..00000000 --- a/src/poli/objective_repository/foldx_stability_and_sasa/information.py +++ /dev/null @@ -1,17 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation -from poli.core.util.proteins.defaults import AMINO_ACIDS - -foldx_stability_and_sasa_info = BlackBoxInformation( - name="foldx_stability_and_sasa", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, - alphabet=AMINO_ACIDS, - log_transform_recommended=False, - discrete=True, - fidelity=None, - padding_token="", -) diff --git a/src/poli/objective_repository/foldx_stability_and_sasa/register.py b/src/poli/objective_repository/foldx_stability_and_sasa/register.py index d0d5aa2d..a8cb1ea3 100644 --- a/src/poli/objective_repository/foldx_stability_and_sasa/register.py +++ b/src/poli/objective_repository/foldx_stability_and_sasa/register.py @@ -27,10 +27,8 @@ from poli.core.exceptions import FoldXNotFoundException from poli.core.problem import Problem from poli.core.util.isolation.instancing import get_inner_function +from poli.core.util.proteins.defaults import AMINO_ACIDS from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.foldx_stability_and_sasa.information import ( - foldx_stability_and_sasa_info, -) class FoldXStabilityAndSASABlackBox(AbstractBlackBox): @@ -141,9 +139,19 @@ def _black_box(self, x: np.ndarray, context: None) -> np.ndarray: return inner_function(x, context) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return foldx_stability_and_sasa_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="foldx_stability_and_sasa", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, + alphabet=AMINO_ACIDS, + log_transform_recommended=False, + discrete=True, + fidelity=None, + padding_token="", + ) class FoldXStabilityAndSASAProblemFactory(AbstractProblemFactory): @@ -152,28 +160,10 @@ class FoldXStabilityAndSASAProblemFactory(AbstractProblemFactory): Methods ------- - get_setup_information: - Returns the setup information for the problem. create: Creates a problem instance with the specified parameters. """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Get the setup information for the foldx_sasa objective. - - Returns - ------- - BlackBoxInformation - The setup information for the objective. - - Notes - ----- - By default, the method uses the 20 amino acids shown in - poli.core.util.proteins.defaults. - """ - return foldx_stability_and_sasa_info - def create( self, wildtype_pdb_path: Union[Path, List[Path]], diff --git a/src/poli/objective_repository/gfp_cbas/register.py b/src/poli/objective_repository/gfp_cbas/register.py index ca9d4cf5..b9c960bd 100644 --- a/src/poli/objective_repository/gfp_cbas/register.py +++ b/src/poli/objective_repository/gfp_cbas/register.py @@ -9,7 +9,7 @@ from poli.core.problem import Problem from poli.core.util.isolation.instancing import get_inner_function from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.gfp_cbas.information import gfp_cbas_info +from poli.objective_repository.gfp_cbas.information import AA class GFPCBasBlackBox(AbstractBlackBox): @@ -51,7 +51,7 @@ def __init__( force_isolation=self.force_isolation, quiet=False, problem_type=self.problem_type, - info=gfp_cbas_info, + info=self.get_black_box_info(), n_starting_points=self.n_starting_points, functional_only=self.functional_only, ignore_stops=self.ignore_stops, @@ -71,7 +71,7 @@ def _black_box(self, x: np.array, context=None) -> np.ndarray: force_isolation=self.force_isolation, quiet=True, problem_type=self.problem_type, - info=gfp_cbas_info, + info=self.get_black_box_info(), n_starting_points=self.n_starting_points, functional_only=self.functional_only, ignore_stops=self.ignore_stops, @@ -84,9 +84,19 @@ def _black_box(self, x: np.array, context=None) -> np.ndarray: def __iter__(self, *args, **kwargs): warn(f"{self.__class__.__name__} iteration invoked. Not implemented!") - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return gfp_cbas_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="gfp_cbas", + max_sequence_length=237, # max len of aaSequence + aligned=True, + fixed_length=True, + deterministic=False, + alphabet=AA, + log_transform_recommended=False, + discrete=True, + fidelity=None, + padding_token="", + ) class GFPCBasProblemFactory(AbstractProblemFactory): @@ -98,17 +108,6 @@ def __init__(self, problem_type: str = "gp") -> None: ) self.problem_type = problem_type.lower() - def get_setup_information(self) -> BlackBoxInformation: - """ - The problem is set up such that all available sequences - are provided in x0, however only batch_size amount of observations are known. - I.e. f(x0[:batch_size]) is returned as f_0 . - The task is to find the minimum, given that only limited inquiries (batch_size) can be done. - Given that all X are known it is recommended to use an acquisition function to rank - and inquire the highest rated sequences with the _black_box. - """ - return gfp_cbas_info - def create( self, problem_type: Literal["gp", "vae", "elbo"] = "gp", @@ -130,7 +129,7 @@ def create( self.problem_type = problem_type if seed is not None: seed_python_numpy_and_torch(seed) - problem_info = self.get_setup_information() + problem_info = self.get_problem_name() f = GFPCBasBlackBox( problem_type=problem_type, functional_only=functional_only, diff --git a/src/poli/objective_repository/gfp_select/register.py b/src/poli/objective_repository/gfp_select/register.py index 7c77de37..d5f989bd 100644 --- a/src/poli/objective_repository/gfp_select/register.py +++ b/src/poli/objective_repository/gfp_select/register.py @@ -5,8 +5,8 @@ from poli.core.black_box_information import BlackBoxInformation from poli.core.problem import Problem from poli.core.util.isolation.instancing import instance_function_as_isolated_process +from poli.core.util.proteins.defaults import AMINO_ACIDS from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.gfp_select.information import gfp_select_info class GFPSelectionBlackBox(AbstractBlackBox): @@ -47,22 +47,22 @@ def _black_box(self, x: np.array, context=None) -> np.ndarray: """ return self.inner_function(x, context) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return gfp_select_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="gfp_select", + max_sequence_length=237, # max len of aaSequence + aligned=True, # TODO: perhaps add the fact that there is a random state here? + fixed_length=True, + deterministic=False, + alphabet=AMINO_ACIDS, + log_transform_recommended=False, + discrete=True, + fidelity=None, + padding_token="", + ) class GFPSelectionProblemFactory(AbstractProblemFactory): - def get_setup_information(self) -> BlackBoxInformation: - """ - The problem is set up such that all available sequences - are provided in x0, however only batch_size amount of observations are known. - I.e. f(x0[:batch_size]) is returned as f_0 . - The task is to find the minimum, given that only limited inquiries (batch_size) can be done. - Given that all X are known it is recommended to use an acquisition function to rank - and inquire the highest rated sequences with the _black_box. - """ - return gfp_select_info def create( self, diff --git a/src/poli/objective_repository/gsk3_beta/information.py b/src/poli/objective_repository/gsk3_beta/information.py deleted file mode 100644 index b4216941..00000000 --- a/src/poli/objective_repository/gsk3_beta/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -gsk3_beta_info = BlackBoxInformation( - name="gsk3_beta", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/gsk3_beta/register.py b/src/poli/objective_repository/gsk3_beta/register.py index 373c286f..6daa13e2 100644 --- a/src/poli/objective_repository/gsk3_beta/register.py +++ b/src/poli/objective_repository/gsk3_beta/register.py @@ -32,7 +32,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.gsk3_beta.information import gsk3_beta_info class GSK3BetaBlackBox(TDCBlackBox): @@ -104,9 +103,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return gsk3_beta_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="gsk3_beta", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class GSK3BetaProblemFactory(AbstractProblemFactory): @@ -117,10 +125,8 @@ class GSK3BetaProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: - Creates a DRD3 docking problem. + Creates a GSK3Beta docking problem. References ---------- @@ -139,17 +145,6 @@ class GSK3BetaProblemFactory(AbstractProblemFactory): Journal of cheminformatics 9.1 (2017). """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return gsk3_beta_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/isomer_c7h8n2o2/information.py b/src/poli/objective_repository/isomer_c7h8n2o2/information.py deleted file mode 100644 index dfe5c6dc..00000000 --- a/src/poli/objective_repository/isomer_c7h8n2o2/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -isomer_c7h8n2o2_info = BlackBoxInformation( - name="isomer_c7h8n2o2", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/isomer_c7h8n2o2/register.py b/src/poli/objective_repository/isomer_c7h8n2o2/register.py index bbc26469..3ea55be9 100644 --- a/src/poli/objective_repository/isomer_c7h8n2o2/register.py +++ b/src/poli/objective_repository/isomer_c7h8n2o2/register.py @@ -24,7 +24,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.isomer_c7h8n2o2.information import isomer_c7h8n2o2_info class IsomerC7H8N2O2BlackBox(TDCBlackBox): @@ -90,9 +89,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return isomer_c7h8n2o2_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="isomer_c7h8n2o2", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class IsomerC7H8N2O2ProblemFactory(AbstractProblemFactory): @@ -104,8 +112,6 @@ class IsomerC7H8N2O2ProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an Isomer C7H8N2O2 problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -119,17 +125,6 @@ class IsomerC7H8N2O2ProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return isomer_c7h8n2o2_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/isomer_c9h10n2o2pf2cl/information.py b/src/poli/objective_repository/isomer_c9h10n2o2pf2cl/information.py deleted file mode 100644 index e649b0cf..00000000 --- a/src/poli/objective_repository/isomer_c9h10n2o2pf2cl/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -isomer_c9h10n2o2pf2cl_info = BlackBoxInformation( - name="isomer_c9h10n2o2pf2cl", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/isomer_c9h10n2o2pf2cl/register.py b/src/poli/objective_repository/isomer_c9h10n2o2pf2cl/register.py index a23c1974..9f85c6d9 100644 --- a/src/poli/objective_repository/isomer_c9h10n2o2pf2cl/register.py +++ b/src/poli/objective_repository/isomer_c9h10n2o2pf2cl/register.py @@ -25,9 +25,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.isomer_c9h10n2o2pf2cl.information import ( - isomer_c9h10n2o2pf2cl_info, -) class IsomerC9H10N2O2PF2ClBlackBox(TDCBlackBox): @@ -94,9 +91,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return isomer_c9h10n2o2pf2cl_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="isomer_c9h10n2o2pf2cl", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class IsomerC9H10N2O2PF2ClProblemFactory(AbstractProblemFactory): @@ -108,8 +114,6 @@ class IsomerC9H10N2O2PF2ClProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an Isomer C9H10N2O2PF2Cl problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -124,17 +128,6 @@ class IsomerC9H10N2O2PF2ClProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return isomer_c9h10n2o2pf2cl_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/jnk3/information.py b/src/poli/objective_repository/jnk3/information.py deleted file mode 100644 index 4f3264e6..00000000 --- a/src/poli/objective_repository/jnk3/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -jnk3_info = BlackBoxInformation( - name="jnk3", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/jnk3/register.py b/src/poli/objective_repository/jnk3/register.py index 4f815dec..9c4ad68a 100644 --- a/src/poli/objective_repository/jnk3/register.py +++ b/src/poli/objective_repository/jnk3/register.py @@ -31,7 +31,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.jnk3.information import jnk3_info class JNK3BlackBox(TDCBlackBox): @@ -101,9 +100,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return jnk3_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="jnk3", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class JNK3ProblemFactory(AbstractProblemFactory): @@ -114,8 +122,6 @@ class JNK3ProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates a JNK3 problem. @@ -135,17 +141,6 @@ class JNK3ProblemFactory(AbstractProblemFactory): Journal of cheminformatics 9.1 (2017). """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return jnk3_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/median_1/information.py b/src/poli/objective_repository/median_1/information.py deleted file mode 100644 index 71d7c705..00000000 --- a/src/poli/objective_repository/median_1/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -median_1_info = BlackBoxInformation( - name="median_1", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/median_1/register.py b/src/poli/objective_repository/median_1/register.py index 89c9b606..da8a04cb 100644 --- a/src/poli/objective_repository/median_1/register.py +++ b/src/poli/objective_repository/median_1/register.py @@ -25,7 +25,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.median_1.information import median_1_info class Median1BlackBox(TDCBlackBox): @@ -89,9 +88,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return median_1_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="median_1", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class Median1ProblemFactory(AbstractProblemFactory): @@ -102,8 +110,6 @@ class Median1ProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an Median 1 problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -118,17 +124,6 @@ class Median1ProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return median_1_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/median_2/information.py b/src/poli/objective_repository/median_2/information.py deleted file mode 100644 index 2996efc6..00000000 --- a/src/poli/objective_repository/median_2/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -median_2_info = BlackBoxInformation( - name="median_2", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/median_2/register.py b/src/poli/objective_repository/median_2/register.py index 0ae9a932..ff328888 100644 --- a/src/poli/objective_repository/median_2/register.py +++ b/src/poli/objective_repository/median_2/register.py @@ -24,7 +24,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.median_2.information import median_2_info class Median2BlackBox(TDCBlackBox): @@ -88,9 +87,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return median_2_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="median_2", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class Median2ProblemFactory(AbstractProblemFactory): @@ -101,8 +109,6 @@ class Median2ProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an Median 2 problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -117,17 +123,6 @@ class Median2ProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return median_2_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/mestranol_similarity/information.py b/src/poli/objective_repository/mestranol_similarity/information.py deleted file mode 100644 index 8d0ede68..00000000 --- a/src/poli/objective_repository/mestranol_similarity/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -mestranol_similarity_info = BlackBoxInformation( - name="mestranol_similarity", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/mestranol_similarity/register.py b/src/poli/objective_repository/mestranol_similarity/register.py index e421cf37..a19e48ee 100644 --- a/src/poli/objective_repository/mestranol_similarity/register.py +++ b/src/poli/objective_repository/mestranol_similarity/register.py @@ -28,9 +28,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.mestranol_similarity.information import ( - mestranol_similarity_info, -) class MestranolSimilarityBlackBox(TDCBlackBox): @@ -95,9 +92,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return mestranol_similarity_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="mestranol_similarity", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class MestranolSimilarityProblemFactory(AbstractProblemFactory): @@ -108,8 +114,6 @@ class MestranolSimilarityProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates a Mestranol Similarity problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -124,17 +128,6 @@ class MestranolSimilarityProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return mestranol_similarity_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/osimetrinib_mpo/information.py b/src/poli/objective_repository/osimetrinib_mpo/information.py deleted file mode 100644 index a0091ed3..00000000 --- a/src/poli/objective_repository/osimetrinib_mpo/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -osimetrinib_mpo_info = BlackBoxInformation( - name="osimetrinib_mpo", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/osimetrinib_mpo/register.py b/src/poli/objective_repository/osimetrinib_mpo/register.py index 1365779f..ab44e58a 100644 --- a/src/poli/objective_repository/osimetrinib_mpo/register.py +++ b/src/poli/objective_repository/osimetrinib_mpo/register.py @@ -24,7 +24,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.osimetrinib_mpo.information import osimetrinib_mpo_info class OsimetrinibMPOBlackBox(TDCBlackBox): @@ -89,9 +88,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return osimetrinib_mpo_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="osimetrinib_mpo", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class OsimetrinibMPOProblemFactory(AbstractProblemFactory): @@ -102,8 +110,6 @@ class OsimetrinibMPOProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an Osimetrinib MPO problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -118,17 +124,6 @@ class OsimetrinibMPOProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return osimetrinib_mpo_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/penalized_logp_lambo/information.py b/src/poli/objective_repository/penalized_logp_lambo/information.py deleted file mode 100644 index 362124b5..00000000 --- a/src/poli/objective_repository/penalized_logp_lambo/information.py +++ /dev/null @@ -1,16 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -penalized_logp_lambo_info = BlackBoxInformation( - name="penalized_logp_lambo", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - alphabet=None, # TODO: add when we settle for an alphabet - deterministic=True, - log_transform_recommended=False, - discrete=True, - fidelity=None, - padding_token="", -) diff --git a/src/poli/objective_repository/penalized_logp_lambo/register.py b/src/poli/objective_repository/penalized_logp_lambo/register.py index d5dd5fa4..c088379e 100644 --- a/src/poli/objective_repository/penalized_logp_lambo/register.py +++ b/src/poli/objective_repository/penalized_logp_lambo/register.py @@ -21,9 +21,6 @@ from poli.core.problem import Problem from poli.core.util.isolation.instancing import get_inner_function from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.penalized_logp_lambo.information import ( - penalized_logp_lambo_info, -) class PenalizedLogPLamboBlackBox(AbstractBlackBox): @@ -47,9 +44,6 @@ def __init__( evaluation_budget: int = float("inf"), force_isolation: bool = False, ): - """ - TODO: document - """ super().__init__( batch_size=batch_size, parallelize=parallelize, @@ -92,16 +86,22 @@ def _black_box(self, x: np.ndarray, context: dict = None): ) return inner_function(x, context) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return penalized_logp_lambo_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="penalized_logp_lambo", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + alphabet=None, # TODO: add when we settle for an alphabet + deterministic=True, + log_transform_recommended=False, + discrete=True, + fidelity=None, + padding_token="", + ) class PenalizedLogPLamboProblemFactory(AbstractProblemFactory): - def get_setup_information(self) -> BlackBoxInformation: - # TODO: do they have an alphabet? - return penalized_logp_lambo_info - def create( self, penalized: bool = True, diff --git a/src/poli/objective_repository/perindopril_mpo/information.py b/src/poli/objective_repository/perindopril_mpo/information.py deleted file mode 100644 index 93803488..00000000 --- a/src/poli/objective_repository/perindopril_mpo/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -perindopril_mpo_info = BlackBoxInformation( - name="perindopril_mpo", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/perindopril_mpo/register.py b/src/poli/objective_repository/perindopril_mpo/register.py index 71882dd7..95cff713 100644 --- a/src/poli/objective_repository/perindopril_mpo/register.py +++ b/src/poli/objective_repository/perindopril_mpo/register.py @@ -24,7 +24,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.perindopril_mpo.information import perindopril_mpo_info class PerindoprilMPOBlackBox(TDCBlackBox): @@ -88,9 +87,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return perindopril_mpo_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="perindopril_mpo", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class PerindoprilMPOProblemFactory(AbstractProblemFactory): @@ -101,8 +109,6 @@ class PerindoprilMPOProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an Perindopril MPO problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -117,17 +123,6 @@ class PerindoprilMPOProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return perindopril_mpo_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/ranolazine_mpo/information.py b/src/poli/objective_repository/ranolazine_mpo/information.py deleted file mode 100644 index cd76ac53..00000000 --- a/src/poli/objective_repository/ranolazine_mpo/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -ranolazine_mpo_info = BlackBoxInformation( - name="ranolazine_mpo", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/ranolazine_mpo/register.py b/src/poli/objective_repository/ranolazine_mpo/register.py index 6dec57e0..d3c37b28 100644 --- a/src/poli/objective_repository/ranolazine_mpo/register.py +++ b/src/poli/objective_repository/ranolazine_mpo/register.py @@ -24,7 +24,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.ranolazine_mpo.information import ranolazine_mpo_info class RanolazineMPOBlackBox(TDCBlackBox): @@ -89,9 +88,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return ranolazine_mpo_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="ranolazine_mpo", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class RanolazineMPOProblemFactory(AbstractProblemFactory): @@ -102,8 +110,6 @@ class RanolazineMPOProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an Ranolazine MPO problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -118,17 +124,6 @@ class RanolazineMPOProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return ranolazine_mpo_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/rasp/information.py b/src/poli/objective_repository/rasp/information.py deleted file mode 100644 index d982ae13..00000000 --- a/src/poli/objective_repository/rasp/information.py +++ /dev/null @@ -1,17 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation -from poli.core.util.proteins.defaults import AMINO_ACIDS - -rasp_information = BlackBoxInformation( - name="rasp", - max_sequence_length=np.inf, - aligned=True, - fixed_length=False, - deterministic=True, - alphabet=AMINO_ACIDS, - log_transform_recommended=False, - discrete=True, - fidelity="low", - padding_token="", -) diff --git a/src/poli/objective_repository/rasp/register.py b/src/poli/objective_repository/rasp/register.py index 3acf212a..b5ca36c6 100644 --- a/src/poli/objective_repository/rasp/register.py +++ b/src/poli/objective_repository/rasp/register.py @@ -20,13 +20,15 @@ from pathlib import Path from typing import List, Union +import numpy as np + from poli.core.abstract_black_box import AbstractBlackBox from poli.core.abstract_problem_factory import AbstractProblemFactory from poli.core.black_box_information import BlackBoxInformation from poli.core.problem import Problem from poli.core.util.isolation.instancing import get_inner_function +from poli.core.util.proteins.defaults import AMINO_ACIDS from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.rasp.information import rasp_information class RaspBlackBox(AbstractBlackBox): @@ -183,21 +185,25 @@ def _black_box(self, x, context=None): """ return self.inner_function(x, context=context) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: + def get_black_box_info(self) -> BlackBoxInformation: """ Returns the black box information for RaSP. """ - return rasp_information + return BlackBoxInformation( + name="rasp", + max_sequence_length=np.inf, + aligned=True, + fixed_length=False, + deterministic=True, + alphabet=AMINO_ACIDS, + log_transform_recommended=False, + discrete=True, + fidelity="low", + padding_token="", + ) class RaspProblemFactory(AbstractProblemFactory): - def get_setup_information(self) -> BlackBoxInformation: - """ - Returns the problem setup information for RaSP. - """ - return rasp_information - def create( self, wildtype_pdb_path: Union[Path, List[Path]], diff --git a/src/poli/objective_repository/rdkit_logp/information.py b/src/poli/objective_repository/rdkit_logp/information.py deleted file mode 100644 index 4a0f7f41..00000000 --- a/src/poli/objective_repository/rdkit_logp/information.py +++ /dev/null @@ -1,16 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -rdkit_logp_info = BlackBoxInformation( - name="rdkit_logp", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, - alphabet=None, # TODO: add once we settle for one - log_transform_recommended=False, - discrete=True, - fidelity=None, - padding_token="", -) diff --git a/src/poli/objective_repository/rdkit_logp/register.py b/src/poli/objective_repository/rdkit_logp/register.py index e67508e6..51c145c2 100644 --- a/src/poli/objective_repository/rdkit_logp/register.py +++ b/src/poli/objective_repository/rdkit_logp/register.py @@ -20,7 +20,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import strings_to_molecules from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.rdkit_logp.information import rdkit_logp_info class LogPBlackBox(AbstractBlackBox): @@ -72,6 +71,7 @@ def __init__( parallelize: bool = False, num_workers: int = None, evaluation_budget: int = float("inf"), + force_isolation: bool = False, ): """ Initializes the LogP black box. @@ -142,23 +142,22 @@ def _black_box(self, x: np.ndarray, context: dict = None) -> np.ndarray: return np.array(logp_values).reshape(-1, 1) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return rdkit_logp_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="rdkit_logp", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, + alphabet=None, # TODO: add once we settle for one + log_transform_recommended=False, + discrete=True, + fidelity=None, + padding_token="", + ) class LogPProblemFactory(AbstractProblemFactory): - def get_setup_information(self) -> BlackBoxInformation: - """ - Returns the setup information for the logP problem. - - Returns - ------- - info : ProblemSetupInformation - The setup information for the logP problem. - """ - return rdkit_logp_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/rdkit_qed/information.py b/src/poli/objective_repository/rdkit_qed/information.py deleted file mode 100644 index bacbf344..00000000 --- a/src/poli/objective_repository/rdkit_qed/information.py +++ /dev/null @@ -1,16 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -rdkit_qed_info = BlackBoxInformation( - name="rdkit_qed", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, - alphabet=None, # TODO: add once we settle for one - log_transform_recommended=False, - discrete=True, - fidelity=None, - padding_token="", -) diff --git a/src/poli/objective_repository/rdkit_qed/register.py b/src/poli/objective_repository/rdkit_qed/register.py index 4519166f..571ffd44 100644 --- a/src/poli/objective_repository/rdkit_qed/register.py +++ b/src/poli/objective_repository/rdkit_qed/register.py @@ -21,7 +21,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import strings_to_molecules from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.rdkit_qed.information import rdkit_qed_info class QEDBlackBox(AbstractBlackBox): @@ -158,8 +157,7 @@ def _black_box(self, x: np.ndarray, context: dict = None) -> np.ndarray: return np.array(qed_values).reshape(-1, 1) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: + def get_black_box_info(self) -> BlackBoxInformation: """Returns the black box information for the QED problem. Returns @@ -167,7 +165,18 @@ def get_black_box_info() -> BlackBoxInformation: BlackBoxInformation The black box information for the QED problem. """ - return rdkit_qed_info + return BlackBoxInformation( + name="rdkit_qed", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, + alphabet=None, # TODO: add once we settle for one + log_transform_recommended=False, + discrete=True, + fidelity=None, + padding_token="", + ) class QEDProblemFactory(AbstractProblemFactory): @@ -180,15 +189,10 @@ class QEDProblemFactory(AbstractProblemFactory): Methods ------- - get_setup_information() - Returns the setup information for the problem. create(...) Creates a problem instance with the specified parameters. """ - def get_setup_information(self) -> BlackBoxInformation: - return rdkit_qed_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/rfp_foldx_stability_and_sasa/information.py b/src/poli/objective_repository/rfp_foldx_stability_and_sasa/information.py deleted file mode 100644 index a353df2f..00000000 --- a/src/poli/objective_repository/rfp_foldx_stability_and_sasa/information.py +++ /dev/null @@ -1,17 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation -from poli.core.util.proteins.defaults import AMINO_ACIDS - -rfp_foldx_stability_and_sasa_info = BlackBoxInformation( - name="rfp_foldx_stability_and_sasa", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, - alphabet=AMINO_ACIDS, - log_transform_recommended=False, - discrete=True, - fidelity=None, - padding_token="", -) diff --git a/src/poli/objective_repository/rfp_foldx_stability_and_sasa/register.py b/src/poli/objective_repository/rfp_foldx_stability_and_sasa/register.py index 4044152c..1cc20876 100644 --- a/src/poli/objective_repository/rfp_foldx_stability_and_sasa/register.py +++ b/src/poli/objective_repository/rfp_foldx_stability_and_sasa/register.py @@ -23,15 +23,11 @@ import numpy as np from poli.core.abstract_problem_factory import AbstractProblemFactory -from poli.core.black_box_information import BlackBoxInformation from poli.core.problem import Problem from poli.core.util.seeding import seed_numpy, seed_python from poli.objective_repository.foldx_stability_and_sasa.register import ( FoldXStabilityAndSASABlackBox, ) -from poli.objective_repository.rfp_foldx_stability_and_sasa.information import ( - rfp_foldx_stability_and_sasa_info, -) class RFPFoldXStabilityAndSASAProblemFactory(AbstractProblemFactory): @@ -40,28 +36,10 @@ class RFPFoldXStabilityAndSASAProblemFactory(AbstractProblemFactory): Methods ------- - get_setup_information: - Returns the setup information for the problem. create: Creates a problem instance with the specified parameters. """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Get the setup information for the foldx_sasa objective. - - Returns - ------- - ProblemSetupInformation - The setup information for the objective. - - Notes - ----- - By default, the method uses the 20 amino acids shown in - poli.core.util.proteins.defaults. - """ - return rfp_foldx_stability_and_sasa_info - def create( self, wildtype_pdb_path: Union[Path, List[Path]], diff --git a/src/poli/objective_repository/rmf_landscape/information.py b/src/poli/objective_repository/rmf_landscape/information.py deleted file mode 100644 index 17c0d804..00000000 --- a/src/poli/objective_repository/rmf_landscape/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation -from poli.core.util.proteins.defaults import AMINO_ACIDS - -rmf_info = BlackBoxInformation( - name="rmf_landscape", - max_sequence_length=np.inf, - aligned=True, - fixed_length=True, - deterministic=False, - alphabet=AMINO_ACIDS, # TODO: differentiate between AA and NA inputs? - log_transform_recommended=False, - discrete=True, -) diff --git a/src/poli/objective_repository/rmf_landscape/register.py b/src/poli/objective_repository/rmf_landscape/register.py index 08944abf..6ae20933 100644 --- a/src/poli/objective_repository/rmf_landscape/register.py +++ b/src/poli/objective_repository/rmf_landscape/register.py @@ -20,8 +20,8 @@ from poli.core.black_box_information import BlackBoxInformation from poli.core.problem import Problem from poli.core.util.isolation.instancing import get_inner_function +from poli.core.util.proteins.defaults import AMINO_ACIDS from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.rmf_landscape.information import rmf_info class RMFBlackBox(AbstractBlackBox): @@ -144,9 +144,17 @@ def _black_box(self, x: np.ndarray, context: None) -> np.ndarray: ) return inner_function(x, context) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return rmf_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="rmf_landscape", + max_sequence_length=np.inf, + aligned=True, + fixed_length=True, + deterministic=False, + alphabet=AMINO_ACIDS, # TODO: differentiate between AA and NA inputs? + log_transform_recommended=False, + discrete=True, + ) class RMFProblemFactory(AbstractProblemFactory): @@ -155,15 +163,10 @@ class RMFProblemFactory(AbstractProblemFactory): Methods ------- - get_setup_information() - returns problem setup information. create(...) Creates RMF problem instance with specified parameters. """ - def get_setup_information(self) -> BlackBoxInformation: - return rmf_info - def create( self, wildtype: List[str] | str, diff --git a/src/poli/objective_repository/sa_tdc/register.py b/src/poli/objective_repository/sa_tdc/register.py index 52a7715a..1dbbf7aa 100644 --- a/src/poli/objective_repository/sa_tdc/register.py +++ b/src/poli/objective_repository/sa_tdc/register.py @@ -18,7 +18,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.sa_tdc.information import sa_tdc_info class SABlackBox(TDCBlackBox): @@ -75,9 +74,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return sa_tdc_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="sa_tdc", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class SAProblemFactory(AbstractProblemFactory): @@ -85,23 +93,10 @@ class SAProblemFactory(AbstractProblemFactory): Methods ------- - get_setup_information() - Returns the setup information for the problem. create(...) Creates a synthetic-accessibility problem instance with the specified parameters. """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Returns the setup information for the problem. - - Returns - -------- - problem_info: BlackBoxInformation - The setup information for the problem. - """ - return sa_tdc_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/scaffold_hop/register.py b/src/poli/objective_repository/scaffold_hop/register.py index bca24aa1..da7b9bea 100644 --- a/src/poli/objective_repository/scaffold_hop/register.py +++ b/src/poli/objective_repository/scaffold_hop/register.py @@ -24,7 +24,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.scaffold_hop.information import scaffold_hop_info class ScaffoldHopBlackBox(TDCBlackBox): @@ -89,9 +88,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return scaffold_hop_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="scaffold_hop", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class ScaffoldHopProblemFactory(AbstractProblemFactory): @@ -102,8 +110,6 @@ class ScaffoldHopProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an Scaffold Hop problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -118,17 +124,6 @@ class ScaffoldHopProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return scaffold_hop_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/sitagliptin_mpo/register.py b/src/poli/objective_repository/sitagliptin_mpo/register.py index bf688ae1..0d1a463f 100644 --- a/src/poli/objective_repository/sitagliptin_mpo/register.py +++ b/src/poli/objective_repository/sitagliptin_mpo/register.py @@ -24,7 +24,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.sitagliptin_mpo.information import sitagliptin_mpo_info class SitagliptinMPOBlackBox(TDCBlackBox): @@ -88,9 +87,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return sitagliptin_mpo_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="sitagliptin_mpo", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class SitagliptinMPOProblemFactory(AbstractProblemFactory): @@ -100,9 +108,7 @@ class SitagliptinMPOProblemFactory(AbstractProblemFactory): We recommend you cite the references [1] and [2] when using this task. Methods - ------ - get_setup_information: - Retrieves the setup information for the problem. + ------- create: Creates an sitagliptin MPO problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -117,17 +123,6 @@ class SitagliptinMPOProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return sitagliptin_mpo_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/super_mario_bros/register.py b/src/poli/objective_repository/super_mario_bros/register.py index f7e1a060..6ac9cb1e 100644 --- a/src/poli/objective_repository/super_mario_bros/register.py +++ b/src/poli/objective_repository/super_mario_bros/register.py @@ -17,7 +17,7 @@ from poli.core.problem import Problem from poli.core.util.isolation.instancing import get_inner_function from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.super_mario_bros.information import smb_info +from poli.objective_repository.super_mario_bros.information import SMB_ALPHABET THIS_DIR = Path(__file__).parent.resolve() @@ -96,7 +96,7 @@ def __init__( class_name="SMBIsolatedLogic", module_to_import="poli.objective_repository.super_mario_bros.isolated_function", force_isolation=self.force_isolation, - alphabet=smb_info.alphabet, + alphabet=self.get_black_box_info().alphabet, max_time=self.max_time, visualize=self.visualize, value_on_unplayable=self.value_on_unplayable, @@ -110,16 +110,25 @@ def _black_box(self, x: np.ndarray, context=None) -> np.ndarray: module_to_import="poli.objective_repository.super_mario_bros.isolated_function", force_isolation=self.force_isolation, quiet=True, - alphabet=smb_info.alphabet, + alphabet=self.get_black_box_info().alphabet, max_time=self.max_time, visualize=self.visualize, value_on_unplayable=self.value_on_unplayable, ) return inner_function(x, context) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return smb_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="super_mario_bros", + max_sequence_length=14 * 14, + aligned=True, + fixed_length=True, + deterministic=False, + alphabet=SMB_ALPHABET, + log_transform_recommended=True, + discrete=True, + padding_token=None, + ) class SuperMarioBrosProblemFactory(AbstractProblemFactory): @@ -128,16 +137,10 @@ class SuperMarioBrosProblemFactory(AbstractProblemFactory): Methods ------- - get_setup_information(self) - Returns the setup information for the problem. create(...) -> Tuple[SMBBlackBox, np.ndarray, np.ndarray] Creates a new instance of the SMBBlackBox class. """ - def get_setup_information(self) -> BlackBoxInformation: - """Returns the setup information for the problem.""" - return smb_info - def create( self, max_time: int = 30, diff --git a/src/poli/objective_repository/thiothixene_rediscovery/information.py b/src/poli/objective_repository/thiothixene_rediscovery/information.py deleted file mode 100644 index c1fcab0d..00000000 --- a/src/poli/objective_repository/thiothixene_rediscovery/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -thiothixene_rediscovery_info = BlackBoxInformation( - name="thiothixene_rediscovery", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/thiothixene_rediscovery/register.py b/src/poli/objective_repository/thiothixene_rediscovery/register.py index 0f89bdaf..cde07aa2 100644 --- a/src/poli/objective_repository/thiothixene_rediscovery/register.py +++ b/src/poli/objective_repository/thiothixene_rediscovery/register.py @@ -26,9 +26,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.thiothixene_rediscovery.information import ( - thiothixene_rediscovery_info, -) class ThiothixeneRediscoveryBlackBox(TDCBlackBox): @@ -93,9 +90,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return thiothixene_rediscovery_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="thiothixene_rediscovery", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class ThiothixeneRediscoveryProblemFactory(AbstractProblemFactory): @@ -106,8 +112,6 @@ class ThiothixeneRediscoveryProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates a DRD2 docking problem. @@ -121,17 +125,6 @@ class ThiothixeneRediscoveryProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return thiothixene_rediscovery_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/toy_continuous_problem/information.py b/src/poli/objective_repository/toy_continuous_problem/information.py deleted file mode 100644 index ec3de567..00000000 --- a/src/poli/objective_repository/toy_continuous_problem/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -toy_continuous_info = BlackBoxInformation( - name="toy_continuous_problem", - max_sequence_length=np.inf, - aligned=True, - fixed_length=True, - deterministic=True, - alphabet=None, - log_transform_recommended=False, - discrete=False, - padding_token=None, -) diff --git a/src/poli/objective_repository/toy_continuous_problem/register.py b/src/poli/objective_repository/toy_continuous_problem/register.py index c85916c5..363549d4 100644 --- a/src/poli/objective_repository/toy_continuous_problem/register.py +++ b/src/poli/objective_repository/toy_continuous_problem/register.py @@ -21,9 +21,6 @@ from poli.core.black_box_information import BlackBoxInformation from poli.core.problem import Problem from poli.core.util.seeding import seed_python_numpy_and_torch -from poli.objective_repository.toy_continuous_problem.information import ( - toy_continuous_info, -) from .toy_continuous_problem import POSSIBLE_FUNCTIONS, ToyContinuousProblem @@ -133,23 +130,23 @@ def _black_box(self, x: np.ndarray, context: dict = None) -> np.ndarray: return self.function(x) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return toy_continuous_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="toy_continuous_problem", + max_sequence_length=( + self.embed_in if self.embed_in is not None else self.n_dimensions + ), + aligned=True, + fixed_length=True, + deterministic=True, + alphabet=None, + log_transform_recommended=False, + discrete=False, + padding_token=None, + ) class ToyContinuousProblemFactory(AbstractProblemFactory): - def get_setup_information(self) -> BlackBoxInformation: - """ - Returns the setup information for the problem. - - Returns - ------- - problem_info : ProblemSetupInformation - The setup information for the problem. - """ - return toy_continuous_info - def create( self, function_name: str, diff --git a/src/poli/objective_repository/troglitazone_rediscovery/information.py b/src/poli/objective_repository/troglitazone_rediscovery/information.py deleted file mode 100644 index d0df5baf..00000000 --- a/src/poli/objective_repository/troglitazone_rediscovery/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -troglitazone_rediscovery_info = BlackBoxInformation( - name="troglitazone_rediscovery", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/troglitazone_rediscovery/register.py b/src/poli/objective_repository/troglitazone_rediscovery/register.py index b8180e06..92fccc4f 100644 --- a/src/poli/objective_repository/troglitazone_rediscovery/register.py +++ b/src/poli/objective_repository/troglitazone_rediscovery/register.py @@ -25,9 +25,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.troglitazone_rediscovery.information import ( - troglitazone_rediscovery_info, -) class TroglitazoneRediscoveryBlackBox(TDCBlackBox): @@ -93,9 +90,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return troglitazone_rediscovery_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="troglitazone_rediscovery", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class TroglitazoneRediscoveryProblemFactory(AbstractProblemFactory): @@ -106,8 +112,6 @@ class TroglitazoneRediscoveryProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates a Troglitazone rediscovery problem. @@ -121,17 +125,6 @@ class TroglitazoneRediscoveryProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return troglitazone_rediscovery_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/valsartan_smarts/information.py b/src/poli/objective_repository/valsartan_smarts/information.py deleted file mode 100644 index 56547041..00000000 --- a/src/poli/objective_repository/valsartan_smarts/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -valsartan_smarts_info = BlackBoxInformation( - name="valsartan_smarts", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/valsartan_smarts/register.py b/src/poli/objective_repository/valsartan_smarts/register.py index cfe93171..70fb0feb 100644 --- a/src/poli/objective_repository/valsartan_smarts/register.py +++ b/src/poli/objective_repository/valsartan_smarts/register.py @@ -25,7 +25,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.valsartan_smarts.information import valsartan_smarts_info class ValsartanSMARTSBlackBox(TDCBlackBox): @@ -90,9 +89,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return valsartan_smarts_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="valsartan_smarts", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class ValsartanSMARTSProblemFactory(AbstractProblemFactory): @@ -103,8 +111,6 @@ class ValsartanSMARTSProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates a Valsartan SMARTS problem. @@ -118,17 +124,6 @@ class ValsartanSMARTSProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return valsartan_smarts_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/objective_repository/white_noise/register.py b/src/poli/objective_repository/white_noise/register.py index 0d32cb4d..c9265aea 100644 --- a/src/poli/objective_repository/white_noise/register.py +++ b/src/poli/objective_repository/white_noise/register.py @@ -89,8 +89,7 @@ def _black_box(self, x: np.ndarray, context: dict = None) -> np.ndarray: """ return np.random.randn(x.shape[0], 1) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: + def get_black_box_info(self) -> BlackBoxInformation: return BlackBoxInformation( name="white_noise", max_sequence_length=np.inf, @@ -105,28 +104,6 @@ def get_black_box_info() -> BlackBoxInformation: class WhiteNoiseProblemFactory(AbstractProblemFactory): - @staticmethod - def get_setup_information() -> BlackBoxInformation: - """ - Returns the setup information for the problem. - - Returns - ------- - problem_info : BlackBoxInformation - The setup information for the problem. - """ - return BlackBoxInformation( - name="white_noise", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=False, - alphabet=[str(i) for i in range(10)], - log_transform_recommended=False, - discrete=True, - padding_token="", - ) - def create( self, seed: int = None, diff --git a/src/poli/objective_repository/zaleplon_mpo/information.py b/src/poli/objective_repository/zaleplon_mpo/information.py deleted file mode 100644 index 3ac07f39..00000000 --- a/src/poli/objective_repository/zaleplon_mpo/information.py +++ /dev/null @@ -1,15 +0,0 @@ -import numpy as np - -from poli.core.black_box_information import BlackBoxInformation - -zaleplon_mpo_info = BlackBoxInformation( - name="zaleplon_mpo", - max_sequence_length=np.inf, - aligned=False, - fixed_length=False, - deterministic=True, # ? - alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. - log_transform_recommended=False, - discrete=True, - padding_token="", -) diff --git a/src/poli/objective_repository/zaleplon_mpo/register.py b/src/poli/objective_repository/zaleplon_mpo/register.py index 4e3f66c7..0f8b2e14 100644 --- a/src/poli/objective_repository/zaleplon_mpo/register.py +++ b/src/poli/objective_repository/zaleplon_mpo/register.py @@ -24,7 +24,6 @@ from poli.core.problem import Problem from poli.core.util.chemistry.string_to_molecule import translate_smiles_to_selfies from poli.core.util.seeding import seed_numpy, seed_python -from poli.objective_repository.zaleplon_mpo.information import zaleplon_mpo_info class ZaleplonMPOBlackBox(TDCBlackBox): @@ -89,9 +88,18 @@ def __init__( evaluation_budget=evaluation_budget, ) - @staticmethod - def get_black_box_info() -> BlackBoxInformation: - return zaleplon_mpo_info + def get_black_box_info(self) -> BlackBoxInformation: + return BlackBoxInformation( + name="zaleplon_mpo", + max_sequence_length=np.inf, + aligned=False, + fixed_length=False, + deterministic=True, # ? + alphabet=None, # TODO: add alphabet once we settle for one for SMLIES/SELFIES. + log_transform_recommended=False, + discrete=True, + padding_token="", + ) class ZaleplonMPOProblemFactory(AbstractProblemFactory): @@ -102,8 +110,6 @@ class ZaleplonMPOProblemFactory(AbstractProblemFactory): Methods ------ - get_setup_information: - Retrieves the setup information for the problem. create: Creates an zaleplon MPO problem, containing a black box and an initial value x0 (taken from the documentation of TDC). @@ -118,17 +124,6 @@ class ZaleplonMPOProblemFactory(AbstractProblemFactory): https://pubs.acs.org/doi/10.1021/acs.jcim.8b00839 """ - def get_setup_information(self) -> BlackBoxInformation: - """ - Retrieves the setup information for the problem. - - Returns - -------- - problem_info: ProblemSetupInformation - The setup information for the problem. - """ - return zaleplon_mpo_info - def create( self, string_representation: Literal["SMILES", "SELFIES"] = "SMILES", diff --git a/src/poli/tests/benchmarks/test_benchmark_creation.py b/src/poli/tests/benchmarks/test_benchmark_creation.py index 3e67ef5f..37c8ee91 100644 --- a/src/poli/tests/benchmarks/test_benchmark_creation.py +++ b/src/poli/tests/benchmarks/test_benchmark_creation.py @@ -29,6 +29,37 @@ def test_creating_embedded_toy_continuous_functions_benchmark(): f(x0) +def test_names_from_guacamol_benchmark(): + from poli.benchmarks import GuacaMolGoalDirectedBenchmark + + assert GuacaMolGoalDirectedBenchmark( + string_representation="SMILES" + ).problem_names == [ + "albuterol_similarity", + "amlodipine_mpo", + "celecoxib_rediscovery", + "deco_hop", + "fexofenadine_mpo", + "isomer_c7h8n2o2", + "isomer_c9h10n2o2pf2cl", + "median_1", + "median_2", + "mestranol_similarity", + "osimetrinib_mpo", + "perindopril_mpo", + "ranolazine_mpo", + "rdkit_logp", + "rdkit_qed", + "sa_tdc", + "scaffold_hop", + "sitagliptin_mpo", + "thiothixene_rediscovery", + "troglitazone_rediscovery", + "valsartan_smarts", + "zaleplon_mpo", + ] + + @pytest.mark.poli__tdc def test_creating_guacamol_benchmark(): from poli.benchmarks import GuacaMolGoalDirectedBenchmark diff --git a/src/poli/tests/information/__init__.py b/src/poli/tests/information/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/poli/tests/information/test_dynamic_information.py b/src/poli/tests/information/test_dynamic_information.py new file mode 100644 index 00000000..52846b03 --- /dev/null +++ b/src/poli/tests/information/test_dynamic_information.py @@ -0,0 +1,10 @@ +from poli.repository import ToyContinuousBlackBox + + +def test_dynamic_info_on_toy_continuous_black_box(): + f = ToyContinuousBlackBox( + function_name="ackley_function_01", + n_dimensions=4, + ) + + assert f.info.max_sequence_length == 4 From e9cf11a24b36d2a18c3e20f76483ce8c7ec2ffad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Gonz=C3=A1lez=20Duque?= Date: Wed, 7 Aug 2024 21:53:56 +0200 Subject: [PATCH 5/5] Adds bump my version to the contributing guide --- CONTRIBUTING.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 53e44344..189d2921 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,6 +63,24 @@ There are several different environments (depending on the black boxes we test). If you want to run tests in all environments, remove `-e poli-base-py39` and just run `tox`. This might take a while, and several conda envs will be created. +## Bump the version! + +Your last commit in your branch should be a bump version. + +One of the dev requirements is `bump-my-version`. You should be able to check what the version would be bumped to by running + +```bash +bump-my-version show-bump +``` + +For most cases, you'll be bumping `pre_n` in the `dev` branch. You can bump it with + +```bash +bump-my-version bump pre_n +``` + +This will modify the relevant files: `pyproject.toml` and `src/poli/__init__.py`. + ## Create a pull request to dev Once all tests pass and you are ready to share your changes, create a pull request to the `dev` branch. \ No newline at end of file