-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: Cleaned Enzeptional toolbox Signed-off-by: nanayves <yves.g.nana@gmail.com> * ci: try to tie cuda version to scatter * wip: space instead of comma * wip: cuda separate * wip: pin sentence-transformers * ci: reduce disk space --------- Signed-off-by: nanayves <yves.g.nana@gmail.com> Co-authored-by: jannisborn <jab@zurich.ibm.com>
- Loading branch information
1 parent
94f0091
commit 789cbcc
Showing
14 changed files
with
1,491 additions
and
616 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Enzyme Optimization in Biocatalytic Reactions | ||
|
||
This repository provides an example on how ro run the framework for the optimization of enzymes within the context of biocatalytic reactions. | ||
|
||
## Prerequisites | ||
|
||
Before initiating the enzyme optimization process, execute the following command in your terminal to activate the environment: | ||
|
||
```console | ||
conda activate gt4sd | ||
``` | ||
|
||
## Running the example | ||
|
||
To run the example simply type: | ||
|
||
```console | ||
python example_enzeptional.py | ||
``` | ||
|
||
## Citation | ||
|
||
```bibtex | ||
@inproceedings{teukam2023enzyme, | ||
title={Enzyme optimization via a generative language modeling-based evolutionary algorithm}, | ||
author={Teukam, Yves Gaetan Nana and Grisoni, Francesca and Manica, Matteo and Zipoli, Federico and Laino, Teodoro}, | ||
booktitle={American Chemical Society (ACS) Spring Meeting}, | ||
year={2023} | ||
} | ||
``` |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import logging | ||
import pandas as pd | ||
from gt4sd.frameworks.enzeptional.processing import HFandTAPEModelUtility | ||
from gt4sd.frameworks.enzeptional.core import SequenceMutator, EnzymeOptimizer | ||
from gt4sd.configuration import GT4SDConfiguration, sync_algorithm_with_s3 | ||
|
||
|
||
def initialize_environment(): | ||
"""Synchronize with GT4SD S3 storage and set up the environment.""" | ||
# NOTE: For those interested in optimizing kcat values, it is important to adjust the scorer path to reflect this focus, thereby selecting the appropriate model for kcat optimization: f"{configuration.gt4sd_local_cache_path}/properties/proteins/enzeptional/scorers/kcat/model.pkl". The specification of the scaler, located within the same directory as the `scorer.pkl`, is mandatory for accurate model performance. | ||
configuration = GT4SDConfiguration.get_instance() | ||
sync_algorithm_with_s3("proteins/enzeptional/scorers", module="properties") | ||
return f"{configuration.gt4sd_local_cache_path}/properties/proteins/enzeptional/scorers/feasibility/model.pkl" | ||
|
||
|
||
def load_experiment_parameters(): | ||
"""Load experiment parameters from a CSV file.""" | ||
df = pd.read_csv("data.csv").iloc[1] | ||
return df["substrates"], df["products"], df["sequences"], eval(df["intervals"]) | ||
|
||
|
||
def setup_optimizer( | ||
substrate_smiles, product_smiles, sample_sequence, intervals, scorer_path | ||
): | ||
"""Set up and return the optimizer with all necessary components configured.""" | ||
model_tokenizer_paths = "facebook/esm2_t33_650M_UR50D" | ||
chem_paths = "seyonec/ChemBERTa-zinc-base-v1" | ||
|
||
protein_model = HFandTAPEModelUtility( | ||
embedding_model_path=model_tokenizer_paths, tokenizer_path=model_tokenizer_paths | ||
) | ||
mutation_config = { | ||
"type": "language-modeling", | ||
"embedding_model_path": model_tokenizer_paths, | ||
"tokenizer_path": model_tokenizer_paths, | ||
"unmasking_model_path": model_tokenizer_paths, | ||
} | ||
|
||
mutator = SequenceMutator(sequence=sample_sequence, mutation_config=mutation_config) | ||
optimizer_config = { | ||
"sequence": sample_sequence, | ||
"protein_model": protein_model, | ||
"substrate_smiles": substrate_smiles, | ||
"product_smiles": product_smiles, | ||
"chem_model_path": chem_paths, | ||
"chem_tokenizer_path": chem_paths, | ||
"scorer_filepath": scorer_path, | ||
"mutator": mutator, | ||
"intervals": intervals, | ||
"batch_size": 5, | ||
"top_k": 3, | ||
"selection_ratio": 0.25, | ||
"perform_crossover": True, | ||
"crossover_type": "single_point", | ||
"concat_order": ["substrate", "sequence", "product"], | ||
} | ||
return EnzymeOptimizer(**optimizer_config) | ||
|
||
|
||
def optimize_sequences(optimizer): | ||
"""Optimize sequences using the configured optimizer.""" | ||
return optimizer.optimize( | ||
num_iterations=3, num_sequences=5, num_mutations=5, time_budget=3600 | ||
) | ||
|
||
|
||
def main(): | ||
logging.basicConfig(level=logging.INFO) | ||
scorer_path = initialize_environment() | ||
( | ||
substrate_smiles, | ||
product_smiles, | ||
sample_sequence, | ||
intervals, | ||
) = load_experiment_parameters() | ||
optimizer = setup_optimizer( | ||
substrate_smiles, product_smiles, sample_sequence, intervals, scorer_path | ||
) | ||
optimized_sequences, iteration_info = optimize_sequences(optimizer) | ||
logging.info("Optimization completed.") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.