ejy commited on
Commit
2acabd4
·
verified ·
1 Parent(s): f3ebb84

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +40 -0
README.md CHANGED
@@ -47,4 +47,44 @@ def smiles_to_selfies(dataset):
47
 
48
  binding_data = binding_data.map(smiles_to_selfies)
49
  binding_data = binding_data.filter(lambda dataset: dataset["selfies"] != None)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  ```
 
47
 
48
  binding_data = binding_data.map(smiles_to_selfies)
49
  binding_data = binding_data.filter(lambda dataset: dataset["selfies"] != None)
50
+ ```
51
+
52
+ 3. Compute protein ('prot_bert') / ligand embeddings ('SELFIES-RoBERTa-PubChem10M')
53
+
54
+ ```python
55
+ from sentence_transformers import SentenceTransformer
56
+ import re
57
+ import pickle
58
+ import os.path
59
+
60
+ # Protein embeddings
61
+ all_proteins_shortened = binding_data.unique('seq')
62
+
63
+ protein_sequences = [re.sub(r"[UZOB]", "X", sequence) for sequence in all_proteins_shortened]
64
+ protein_sequences = [" ".join(sequence) for sequence in protein_sequences]
65
+
66
+ protein_model = SentenceTransformer('Rostlab/prot_bert')
67
+ protein_model.max_seq_length = 512
68
+
69
+ protein_emb = protein_model.encode(protein_sequences)
70
+
71
+ protein_embeddings = dict(zip(protein_sequences, protein_emb))
72
+
73
+ with open('protein_embeddings.pkl', "wb") as fOut:
74
+ pickle.dump(protein_embeddings, fOut, protocol=pickle.HIGHEST_PROTOCOL)
75
+
76
+ # Ligand embeddings
77
+ all_selfies_shortened = binding_data.unique('selfies')
78
+
79
+ ligand_sequences = [sequence for sequence in all_selfies_shortened]
80
+
81
+ ligand_model = SentenceTransformer('ejy/SELFIES-RoBERTa-PubChem10M')
82
+ ligand_model.max_seq_length = 128
83
+
84
+ ligand_emb = ligand_model.encode(ligand_sequences)
85
+
86
+ ligand_embeddings = dict(zip(ligand_sequences, ligand_emb))
87
+
88
+ with open('ligand_embeddings.pkl', "wb") as fOut:
89
+ pickle.dump(ligand_embeddings, fOut, protocol=pickle.HIGHEST_PROTOCOL)
90
  ```