Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,13 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
import py3Dmol
|
|
|
3 |
from rdkit import Chem
|
4 |
from rdkit.Chem import Draw
|
5 |
from PIL import Image
|
6 |
from rdkit import Chem
|
7 |
from rdkit.Chem import AllChem
|
8 |
-
|
9 |
from ipywidgets import interact,fixed,IntSlider
|
10 |
-
import ipywidgets
|
11 |
-
|
12 |
|
13 |
def smi2conf(smiles):
|
14 |
'''Convert SMILES to rdkit.Mol with 3D coordinates'''
|
@@ -46,18 +45,20 @@ def MolTo3DView(mol, size=(300, 300), style="stick", surface=False, opacity=0.5)
|
|
46 |
viewer.zoomTo()
|
47 |
return viewer
|
48 |
|
49 |
-
|
50 |
def MakeMolecule(name, ingredients):
|
51 |
st.write(name)
|
52 |
m = Chem.MolFromSmiles(ingredients)
|
53 |
im=Draw.MolToImage(m)
|
54 |
st.image(im)
|
55 |
|
56 |
-
|
57 |
def conf_viewer(idx):
|
58 |
mol = confs[idx]
|
59 |
return MolTo3DView(mol).show()
|
60 |
-
|
|
|
|
|
|
|
|
|
61 |
@interact
|
62 |
def smi2viewer(smi='CC=O'):
|
63 |
try:
|
@@ -65,7 +66,8 @@ def smi2viewer(smi='CC=O'):
|
|
65 |
return MolTo3DView(conf).show()
|
66 |
except:
|
67 |
return None
|
68 |
-
|
|
|
69 |
smi = 'COc3nc(OCc2ccc(C#N)c(c1ccc(C(=O)O)cc1)c2P(=O)(O)O)ccc3C[NH2+]CC(I)NC(=O)C(F)(Cl)Br'
|
70 |
conf = smi2conf(smi)
|
71 |
viewer = MolTo3DView(conf, size=(600, 300), style='sphere')
|
@@ -76,15 +78,11 @@ m = Chem.MolFromSmiles(compound_smiles)
|
|
76 |
im=Draw.MolToImage(m)
|
77 |
st.image(im)
|
78 |
|
79 |
-
|
80 |
-
|
81 |
MakeMolecule("Ethanol", "CCO")
|
82 |
MakeMolecule("Acetic acid", "CC(=O)O")
|
83 |
MakeMolecule("Cyclohexane", "C1CCCCC1")
|
84 |
MakeMolecule("Pyridine", "c1cnccc1")
|
85 |
|
86 |
-
|
87 |
-
|
88 |
viewer = MolTo3DView(conf, size=(600, 300), style='sphere')
|
89 |
viewer.show()
|
90 |
|
@@ -98,7 +96,6 @@ confs = [smi2conf(s) for s in smis]
|
|
98 |
|
99 |
interact(conf_viewer, idx=ipywidgets.IntSlider(min=0,max=len(class_0_list)-1, step=1))
|
100 |
|
101 |
-
|
102 |
smis = [ 'COc3nc(OCc2ccc(C#N)c(c1ccc(C(=O)O)cc1)c2P(=O)(O)O)ccc3C[NH2+]CC(I)NC(=O)C(F)(Cl)Br',
|
103 |
'CC(NCCNCC1=CC=C(OCC2=C(C)C(C3=CC=CC=C3)=CC=C2)N=C1OC)=O',
|
104 |
'Cc1c(COc2cc(OCc3cccc(c3)C#N)c(CN3C[C@H](O)C[C@H]3C(O)=O)cc2Cl)cccc1-c1ccc2OCCOc2c1',
|
@@ -107,9 +104,6 @@ smis = [ 'COc3nc(OCc2ccc(C#N)c(c1ccc(C(=O)O)cc1)c2P(=O)(O)O)ccc3C[NH2+]CC(I)NC(=
|
|
107 |
|
108 |
confs = [smi2conf(s) for s in smis]
|
109 |
|
110 |
-
def style_selector(idx, s):
|
111 |
-
conf = confs[idx]
|
112 |
-
return MolTo3DView(conf, style=s).show()
|
113 |
|
114 |
interact(style_selector,
|
115 |
idx=ipywidgets.IntSlider(min=0,max=len(class_0_list)-1, step=1),
|
@@ -117,7 +111,3 @@ interact(style_selector,
|
|
117 |
options=['line', 'stick', 'sphere'],
|
118 |
value='line',
|
119 |
description='Style:'))
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
1 |
import streamlit as st
|
2 |
+
import ipywidgets
|
3 |
import py3Dmol
|
4 |
+
|
5 |
from rdkit import Chem
|
6 |
from rdkit.Chem import Draw
|
7 |
from PIL import Image
|
8 |
from rdkit import Chem
|
9 |
from rdkit.Chem import AllChem
|
|
|
10 |
from ipywidgets import interact,fixed,IntSlider
|
|
|
|
|
11 |
|
12 |
def smi2conf(smiles):
|
13 |
'''Convert SMILES to rdkit.Mol with 3D coordinates'''
|
|
|
45 |
viewer.zoomTo()
|
46 |
return viewer
|
47 |
|
|
|
48 |
def MakeMolecule(name, ingredients):
|
49 |
st.write(name)
|
50 |
m = Chem.MolFromSmiles(ingredients)
|
51 |
im=Draw.MolToImage(m)
|
52 |
st.image(im)
|
53 |
|
|
|
54 |
def conf_viewer(idx):
|
55 |
mol = confs[idx]
|
56 |
return MolTo3DView(mol).show()
|
57 |
+
|
58 |
+
def style_selector(idx, s):
|
59 |
+
conf = confs[idx]
|
60 |
+
return MolTo3DView(conf, style=s).show()
|
61 |
+
|
62 |
@interact
|
63 |
def smi2viewer(smi='CC=O'):
|
64 |
try:
|
|
|
66 |
return MolTo3DView(conf).show()
|
67 |
except:
|
68 |
return None
|
69 |
+
|
70 |
+
|
71 |
smi = 'COc3nc(OCc2ccc(C#N)c(c1ccc(C(=O)O)cc1)c2P(=O)(O)O)ccc3C[NH2+]CC(I)NC(=O)C(F)(Cl)Br'
|
72 |
conf = smi2conf(smi)
|
73 |
viewer = MolTo3DView(conf, size=(600, 300), style='sphere')
|
|
|
78 |
im=Draw.MolToImage(m)
|
79 |
st.image(im)
|
80 |
|
|
|
|
|
81 |
MakeMolecule("Ethanol", "CCO")
|
82 |
MakeMolecule("Acetic acid", "CC(=O)O")
|
83 |
MakeMolecule("Cyclohexane", "C1CCCCC1")
|
84 |
MakeMolecule("Pyridine", "c1cnccc1")
|
85 |
|
|
|
|
|
86 |
viewer = MolTo3DView(conf, size=(600, 300), style='sphere')
|
87 |
viewer.show()
|
88 |
|
|
|
96 |
|
97 |
interact(conf_viewer, idx=ipywidgets.IntSlider(min=0,max=len(class_0_list)-1, step=1))
|
98 |
|
|
|
99 |
smis = [ 'COc3nc(OCc2ccc(C#N)c(c1ccc(C(=O)O)cc1)c2P(=O)(O)O)ccc3C[NH2+]CC(I)NC(=O)C(F)(Cl)Br',
|
100 |
'CC(NCCNCC1=CC=C(OCC2=C(C)C(C3=CC=CC=C3)=CC=C2)N=C1OC)=O',
|
101 |
'Cc1c(COc2cc(OCc3cccc(c3)C#N)c(CN3C[C@H](O)C[C@H]3C(O)=O)cc2Cl)cccc1-c1ccc2OCCOc2c1',
|
|
|
104 |
|
105 |
confs = [smi2conf(s) for s in smis]
|
106 |
|
|
|
|
|
|
|
107 |
|
108 |
interact(style_selector,
|
109 |
idx=ipywidgets.IntSlider(min=0,max=len(class_0_list)-1, step=1),
|
|
|
111 |
options=['line', 'stick', 'sphere'],
|
112 |
value='line',
|
113 |
description='Style:'))
|
|
|
|
|
|
|
|