Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from rdkit.Chem import Draw
|
2 |
+
from rdkit import Chem
|
3 |
+
import selfies as sf
|
4 |
+
|
5 |
+
def greet(name):
|
6 |
+
sf_output = ['[C][=C][C][=C][C][=C][Ring1][=Branch1]',
|
7 |
+
'[C][=C][C][=C][C][=C][C][=C][Ring1][=Branch1]',
|
8 |
+
'[C][=C][C][=C][C][=C][Ring1][=Branch1][C][=C][C][=C]',
|
9 |
+
'[C][=C][C][=C][C][=C][Ring1][=Branch1][C@H1][C][=C][C]',
|
10 |
+
'[C][=C][C][=C][C][=C][Ring1][=Branch1][C@H1][=C][C][=C]']
|
11 |
+
|
12 |
+
smis = [sf.decoder(i) for i in sf_output]
|
13 |
+
|
14 |
+
mols = []
|
15 |
+
for smi in smis:
|
16 |
+
mol = Chem.MolFromSmiles(smi)
|
17 |
+
mols.append(mol)
|
18 |
+
|
19 |
+
img = Draw.MolsToGridImage(
|
20 |
+
mols,
|
21 |
+
molsPerRow=4,
|
22 |
+
subImgSize=(200,200),
|
23 |
+
legends=['' for x in mols]
|
24 |
+
)
|
25 |
+
|
26 |
+
return img
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="images", title="Molecular Language Model as Multi-task Generator",
|
37 |
+
)
|
38 |
+
iface.launch()
|