|
a |
|
b/Code/Drug Discovery/Meta-Llama-3/SMILES to SELFIES estimator.ipynb |
|
|
1 |
{ |
|
|
2 |
"nbformat": 4, |
|
|
3 |
"nbformat_minor": 0, |
|
|
4 |
"metadata": { |
|
|
5 |
"colab": { |
|
|
6 |
"provenance": [], |
|
|
7 |
"machine_shape": "hm" |
|
|
8 |
}, |
|
|
9 |
"kernelspec": { |
|
|
10 |
"name": "python3", |
|
|
11 |
"display_name": "Python 3" |
|
|
12 |
}, |
|
|
13 |
"language_info": { |
|
|
14 |
"name": "python" |
|
|
15 |
} |
|
|
16 |
}, |
|
|
17 |
"cells": [ |
|
|
18 |
{ |
|
|
19 |
"cell_type": "code", |
|
|
20 |
"execution_count": 1, |
|
|
21 |
"metadata": { |
|
|
22 |
"colab": { |
|
|
23 |
"base_uri": "https://localhost:8080/", |
|
|
24 |
"height": 0 |
|
|
25 |
}, |
|
|
26 |
"id": "gwcBUTqt0Uuz", |
|
|
27 |
"outputId": "c97a5433-ce1a-440f-888d-0c2ccbbc4a1a" |
|
|
28 |
}, |
|
|
29 |
"outputs": [ |
|
|
30 |
{ |
|
|
31 |
"output_type": "stream", |
|
|
32 |
"name": "stdout", |
|
|
33 |
"text": [ |
|
|
34 |
"Collecting selfies\n", |
|
|
35 |
" Downloading selfies-2.1.1-py3-none-any.whl (35 kB)\n", |
|
|
36 |
"Installing collected packages: selfies\n", |
|
|
37 |
"Successfully installed selfies-2.1.1\n" |
|
|
38 |
] |
|
|
39 |
} |
|
|
40 |
], |
|
|
41 |
"source": [ |
|
|
42 |
"# !pip install selfies --upgrade\n", |
|
|
43 |
"# github, aspuru-guzik-group/selfies, https://github.com/aspuru-guzik-group/selfies" |
|
|
44 |
] |
|
|
45 |
}, |
|
|
46 |
{ |
|
|
47 |
"cell_type": "code", |
|
|
48 |
"source": [ |
|
|
49 |
"import selfies as sf\n", |
|
|
50 |
"\n", |
|
|
51 |
"adenine = \"Nc1c2ncNc2ncn1\"\n", |
|
|
52 |
"\n", |
|
|
53 |
"# SMILES -> SELFIES -> SMILES translation\n", |
|
|
54 |
"try:\n", |
|
|
55 |
" adenine_sf = sf.encoder(adenine) #\n", |
|
|
56 |
" adenine_smi = sf.decoder(adenine_sf) # NC1=NC=NC2=C1N=CN2\n", |
|
|
57 |
"except sf.EncoderError:\n", |
|
|
58 |
" pass # sf.encoder error!\n", |
|
|
59 |
"except sf.DecoderError:\n", |
|
|
60 |
" pass # sf.decoder error!\n", |
|
|
61 |
"\n", |
|
|
62 |
"len_adenine = sf.len_selfies(adenine_sf) # 8\n", |
|
|
63 |
"\n", |
|
|
64 |
"symbols_adenine = list(sf.split_selfies(adenine_sf))\n", |
|
|
65 |
"# ['[C]', '[=C]', '[C]', '[=C]', '[C]', '[=C]', '[Ring1]', '[=Branch1]']\n", |
|
|
66 |
"print(\"SMILES =\", adenine_smi)\n", |
|
|
67 |
"print(\"SELFIES =\", adenine_sf)" |
|
|
68 |
], |
|
|
69 |
"metadata": { |
|
|
70 |
"colab": { |
|
|
71 |
"base_uri": "https://localhost:8080/", |
|
|
72 |
"height": 0 |
|
|
73 |
}, |
|
|
74 |
"id": "m9c5VU9i0eEh", |
|
|
75 |
"outputId": "2253edd6-ecf5-4282-e83f-27e6aa1e2708" |
|
|
76 |
}, |
|
|
77 |
"execution_count": 8, |
|
|
78 |
"outputs": [ |
|
|
79 |
{ |
|
|
80 |
"output_type": "stream", |
|
|
81 |
"name": "stdout", |
|
|
82 |
"text": [ |
|
|
83 |
"SMILES = NC1=C2N=CNC2=NC=N1\n", |
|
|
84 |
"SELFIES = [N][C][=C][N][=C][N][C][Ring1][Branch1][=N][C][=N][Ring1][=Branch2]\n" |
|
|
85 |
] |
|
|
86 |
} |
|
|
87 |
] |
|
|
88 |
} |
|
|
89 |
] |
|
|
90 |
} |