---
license: apache-2.0
pipeline_tag: translation
tags:
- chemistry
- biology
inference: false
---
# **Contributors**
- Sebastian Lindner (GitHub [@Bienenwolf655](https://github.com/Bienenwolf655); Twitter [@lindner_seb](https://twitter.com/lindner_seb))
- Michael Heinzinger (GitHub [@mheinzinger](https://github.com/mheinzinger); Twitter [@HeinzingerM](https://twitter.com/HeinzingerM))
- Noelia Ferruz (GitHub [@noeliaferruz](https://github.com/noeliaferruz); Twitter [@ferruz_noelia](https://twitter.com/ferruz_noelia); Webpage: [www.aiproteindesign.com](https://www.aiproteindesign.com) )
# **REXzyme: A Translation Machine for the Generation of New-to-Nature Enzymes**
**Work in Progress**
REXzyme (Reaction to Enzyme) (manuscript in preparation) is a translation machine -similar to Google Translator-
for the generation of enzymes that catalize user-defined reactions.
![Inference of REXzyme](./rexzyme3.png)
It is possible to provide fine-grained input at the substrate level.
Akin to how translation machines have learned to translate between complex language pairs with great success,
often diverging in their representation at the character level (Japanese - English), we posit that an advanced architecture will
be able to translate between the chemical and sequence spaces. REXzyme was trained on a set of 2480 reactions
and ~32M enzyme pairs and it produces sequences that are predicted to perform their intended reactions. A second
version of the model with 14k more reactions will be uploaded to this repository shortly.
you will need to provide a reaction in the SMILES format
(Simplified molecular-input line-entry system). A useful online server to convert from molecules to SMILES
can be found here: https://cactus.nci.nih.gov/chemical/structure.
After converting each of the reaction components you should combine them in the following scheme: ```ReactantA.ReactantB>AgentA>ProductA.ProductB```
Additionally, one should prepend the task suffix ```r2s``` and append the eos token ``````
e.g. for the carbonic anhydrase reaction: ```r2sO.COO>>HCOOO.[H+]```
We provide this python script to convert reactants to the required reaction format, but
we always recommend to draw and double-check the structures in a server like [cactus](https://cactus.nci.nih.gov/chemical/structure)
```python
# left reactants (seperated by '.') seperated by a equal sign from the products (also seperated by '.')
reactions = "CO2 . H2O = carbonic acid . H+"
# agents (seperated by .)
agent = ""
# https://stackoverflow.com/questions/54930121/converting-molecule-name-to-smiles
from urllib.request import urlopen
from urllib.parse import quote
def CIRconvert(ids):
try:
url = 'http://cactus.nci.nih.gov/chemical/structure/' + quote(ids) + '/smiles'
ans = urlopen(url).read().decode('utf8')
return ans
except:
return 'Did not work'
reagent = [CIRconvert(i) for i in reactions.replace(' ','').split('=')[0].split('.') if i != ""]
agent = [CIRconvert(i) for i in agent.replace(' ','').split('.') if i != ""]
product = [CIRconvert(i) for i in reactions.replace(' ','').split('=')[1].split('.') if i != ""]
f"r2s{'.'.join(reagent)}>{'.'.join(agent)}>{'.'.join(product)}"
```
We are still working in the analysis of the model for different tasks, including experimental testing.
See below in this documentation information about the models' performance in different in-silico tasks and how to generate your own enzymes.
## **Model description**
REXzyme is based on the [Efficient T5 Large Transformer](https://huggingface.co/google/t5-efficient-large) architecture (which in turn is very similar to the current version of Google Translator)
and contains 48 (24 encoder/ 24 decoder) layers with a model dimensionality of 1024, totaling 770 million parameters.
REXzyme is a translation machine trained on portion the [RHEA database](https://www.rhea-db.org/) containing 31,970,152 reaction-enzyme pairs.
A second dataset with >14k reactions is being trained and will be uploaded soon.
The pre-training was done on pairs of SMILES and amino acid sequences, tokenized with a char-level
Sentencepiece tokenizer. Note that two seperate tokenizers were used for input (./tokenizer_smiles) and labels (./tokenizer_aa).
REXzyme was pre-trained with a supervised translation objective i.e., the model learned to process the continous
representation of the reaction from the encoder to autoregressively (causual language modeling) produce the output.
The output tokens (amino acids) are generated one at a time, from left to right, and the model learns to match the original enzyme sequence.
Hence, the model learns the dependencies among protein sequence features that enable a specific enzymatic reaction.
There are stark differences in the number of members among reaction classes.
However, since we are tokenizing the reaction SMILES on a character level,
the model has learnt dependencies among molecules and enzyme sequence features, and it can transfer learning from more to less populated
reaction classes.
## **Model Performance**
- **Dataset curation**
We converted the reactions from rxn format to smile string including only left-to-right reactions.
The enzyme sequences were truncated to 1024.
Enzymes catalyzing more than one reaction appear in multiple enzyme-reaction pairs.
- **General descriptors**
| Method | Natural | Generated [1] |
| :--- | :----: | ---: |
| **IUPRED3 (ordered)** | 99.9% | 99.9% |
| **ESMFold (avg. plddt)** | 85.03 | 79.82 |
| **FlDPnn** | 0.0878 | 0.0929 |
[1]| We excluded sequences with %identities ≥ 70% and pLDDTs < 60%.
- **Functional classification**
Method | ProteInfer | CLEAN | ||
Dataset | Natural (%) | Generated (%) | Natural (%) | Generated (%) |
EC: Level 1 | 81 | 80 | 80 | 79 |
EC: Level 2 | 78 | 77 | 79 | 78 |
EC: Level 3 | 76 | 75 | 78 | 77 |
EC: Level 4 | 62 | 58 | 70 | 65 |
No EC predicted | 10 | 7 | 0 | 0 |
GO-Terms | 41 | 39 | - | - |
No GO predicted | 1 | 1 | - | - |