Update README.md
Browse files
README.md
CHANGED
|
@@ -20,4 +20,104 @@ dataset_info:
|
|
| 20 |
download_size: 161743110
|
| 21 |
dataset_size: 606248442.8293403
|
| 22 |
---
|
| 23 |
-
# From [GLASS GPCR database](https://
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
download_size: 161743110
|
| 21 |
dataset_size: 606248442.8293403
|
| 22 |
---
|
| 23 |
+
# From the [GLASS GPCR database](https://aideepmed.com/GLASS1/), converted to SELFIES
|
| 24 |
+
|
| 25 |
+
Steps to prepare the database:
|
| 26 |
+
|
| 27 |
+
1. Download the GLASS database
|
| 28 |
+
|
| 29 |
+
```bash
|
| 30 |
+
wget https://zhanggroup.org/GLASS/downloads/interactions_active.tsv
|
| 31 |
+
wget https://zhanggroup.org/GLASS/downloads/interactions_inactives.tsv
|
| 32 |
+
wget https://zhanggroup.org/GLASS/downloads/targets.tsv
|
| 33 |
+
wget https://zhanggroup.org/GLASS/downloads/ligands.tsv
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
2. Select just the columns of interest
|
| 37 |
+
|
| 38 |
+
```bash
|
| 39 |
+
cut -d$'\t' -f6,9 ligands.tsv > ligands2.tsv
|
| 40 |
+
cut -d$'\t' -f2,5 targets.tsv > targets2.tsv
|
| 41 |
+
cut -d$'\t' -f1,2,4,5 interactions_active.tsv > interactions_active2.tsv
|
| 42 |
+
cut -d$'\t' -f1,2,4,5 interactions_inactives.tsv > interactions_inactives2.tsv
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
3. Parse interactions
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
import pandas as pd
|
| 49 |
+
import numpy as np
|
| 50 |
+
|
| 51 |
+
ligands = pd.read_csv('ligands2.tsv', sep='\t')
|
| 52 |
+
proteins = pd.read_csv('targets2.tsv', sep='\t')
|
| 53 |
+
|
| 54 |
+
actives = pd.read_csv('interactions_active2.tsv', sep='\t')
|
| 55 |
+
inactives = pd.read_csv('interactions_inactives2.tsv', sep='\t')
|
| 56 |
+
|
| 57 |
+
ligand_dict = {}
|
| 58 |
+
|
| 59 |
+
for index, item in ligands.iterrows():
|
| 60 |
+
ligand_dict[item['InChI Key']] = item['Canonical SMILES']
|
| 61 |
+
|
| 62 |
+
protein_dict = {}
|
| 63 |
+
|
| 64 |
+
for index, item in proteins.iterrows():
|
| 65 |
+
protein_dict[item['UniProt ID']] = item['FASTA Sequence']
|
| 66 |
+
|
| 67 |
+
def rehydrate_interactions(x):
|
| 68 |
+
uniprot_id = x['UniProt ID']
|
| 69 |
+
inchi_id = x['InChI Key']
|
| 70 |
+
|
| 71 |
+
smile = ligand_dict[inchi_id]
|
| 72 |
+
fasta = protein_dict[uniprot_id]
|
| 73 |
+
|
| 74 |
+
return smile, fasta
|
| 75 |
+
|
| 76 |
+
actives[["smiles", "seq"]] = actives.apply(rehydrate_interactions, axis=1, result_type="expand")
|
| 77 |
+
inactives[["smiles", "seq"]] = inactives.apply(rehydrate_interactions, axis=1, result_type="expand")
|
| 78 |
+
|
| 79 |
+
actives = actives.drop(columns=['UniProt ID', 'InChI Key'])
|
| 80 |
+
inactives = inactives.drop(columns=['UniProt ID', 'InChI Key'])
|
| 81 |
+
|
| 82 |
+
actives['Y_binary'] = len(actives) * [1]
|
| 83 |
+
inactives['Y_binary'] = len(inactives) * [0]
|
| 84 |
+
|
| 85 |
+
merged = pd.concat([actives, inactives], axis=0)
|
| 86 |
+
merged = merged[merged['Unit'] == 'nM']
|
| 87 |
+
|
| 88 |
+
merged = merged.drop(columns=['Unit'])
|
| 89 |
+
merged = merged.reset_index()
|
| 90 |
+
merged = merged.drop(columns=['index'])
|
| 91 |
+
|
| 92 |
+
merged['Value'] = merged['Value'].map(lambda x: x.strip('>').strip(' ').strip('<'))
|
| 93 |
+
merged['Value'] = merged['Value'].map(lambda x: x.split(" - ")[0])
|
| 94 |
+
merged['Value'] = pd.to_numeric(merged['Value'], errors='coerce')
|
| 95 |
+
merged = merged.rename(columns={"Value": "Y_affinity"})
|
| 96 |
+
merged = merged[merged['Y_affinity'] != 0]
|
| 97 |
+
merged['Y_log_affinity'] = 6 - np.log(merged['Y_affinity']) / np.log(10)
|
| 98 |
+
merged = merged[merged['Y_log_affinity'] >= 0]
|
| 99 |
+
merged = merged[merged['Y_log_affinity'] <= 10]
|
| 100 |
+
|
| 101 |
+
shuffled = merged.sample(frac=1)
|
| 102 |
+
shuffled = shuffled.reset_index()
|
| 103 |
+
shuffled = shuffled.drop(columns=['index'])
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
4. Convert SMILES to [SELFIES](https://github.com/aspuru-guzik-group/selfies)
|
| 107 |
+
|
| 108 |
+
```python
|
| 109 |
+
from datasets import Dataset, DatasetDict
|
| 110 |
+
from datasets import load_dataset
|
| 111 |
+
import selfies
|
| 112 |
+
|
| 113 |
+
dataset = Dataset.from_pandas(shuffled, split='train')
|
| 114 |
+
|
| 115 |
+
def smiles_to_selfies(dataset):
|
| 116 |
+
try:
|
| 117 |
+
return {"selfies": selfies.encoder(dataset["smiles"])}
|
| 118 |
+
except selfies.EncoderError:
|
| 119 |
+
return {"selfies": None}
|
| 120 |
+
|
| 121 |
+
dataset_selfies = dataset.map(smiles_to_selfies)
|
| 122 |
+
dataset_selfies = dataset_selfies.filter(lambda dataset: dataset["selfies"] != None)
|
| 123 |
+
```
|