Update README.md
Browse files
README.md
CHANGED
|
@@ -120,4 +120,44 @@ def smiles_to_selfies(dataset):
|
|
| 120 |
|
| 121 |
dataset_selfies = dataset.map(smiles_to_selfies)
|
| 122 |
dataset_selfies = dataset_selfies.filter(lambda dataset: dataset["selfies"] != None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
```
|
|
|
|
| 120 |
|
| 121 |
dataset_selfies = dataset.map(smiles_to_selfies)
|
| 122 |
dataset_selfies = dataset_selfies.filter(lambda dataset: dataset["selfies"] != None)
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
5. Compute protein ('prot_bert') / ligand embeddings ('SELFIES-RoBERTa-PubChem10M')
|
| 126 |
+
|
| 127 |
+
```python
|
| 128 |
+
from sentence_transformers import SentenceTransformer
|
| 129 |
+
import re
|
| 130 |
+
import pickle
|
| 131 |
+
import os.path
|
| 132 |
+
|
| 133 |
+
# Protein embeddings
|
| 134 |
+
all_proteins_shortened = dataset_selfies.unique('seq')
|
| 135 |
+
|
| 136 |
+
protein_sequences = [re.sub(r"[UZOB]", "X", sequence) for sequence in all_proteins_shortened]
|
| 137 |
+
protein_sequences = [" ".join(sequence) for sequence in protein_sequences]
|
| 138 |
+
|
| 139 |
+
protein_model = SentenceTransformer('Rostlab/prot_bert')
|
| 140 |
+
protein_model.max_seq_length = 512
|
| 141 |
+
|
| 142 |
+
protein_emb = protein_model.encode(protein_sequences)
|
| 143 |
+
|
| 144 |
+
protein_embeddings = dict(zip(protein_sequences, protein_emb))
|
| 145 |
+
|
| 146 |
+
with open('glass_protein_embeddings.pkl', "wb") as fOut:
|
| 147 |
+
pickle.dump(protein_embeddings, fOut, protocol=pickle.HIGHEST_PROTOCOL)
|
| 148 |
+
|
| 149 |
+
# Ligand embeddings
|
| 150 |
+
all_selfies_shortened = dataset_selfies.unique('selfies')
|
| 151 |
+
|
| 152 |
+
ligand_sequences = [sequence for sequence in all_selfies_shortened]
|
| 153 |
+
|
| 154 |
+
ligand_model = SentenceTransformer('ejy/SELFIES-RoBERTa-PubChem10M')
|
| 155 |
+
ligand_model.max_seq_length = 128
|
| 156 |
+
|
| 157 |
+
ligand_emb = ligand_model.encode(ligand_sequences)
|
| 158 |
+
|
| 159 |
+
ligand_embeddings = dict(zip(ligand_sequences, ligand_emb))
|
| 160 |
+
|
| 161 |
+
with open('glass_ligand_embeddings.pkl', "wb") as fOut:
|
| 162 |
+
pickle.dump(ligand_embeddings, fOut, protocol=pickle.HIGHEST_PROTOCOL)
|
| 163 |
```
|