Spaces:
Sleeping
Sleeping
Commit ·
b186a29
1
Parent(s): cf82ed6
Update
Browse files- app.py +25 -27
- st_openbabel_demo.py +0 -42
app.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
-
|
| 4 |
|
| 5 |
from openbabel import pybel
|
| 6 |
-
|
| 7 |
|
| 8 |
st.header("Openbabel test")
|
| 9 |
st.write("Select a molecul to visualize:")
|
|
@@ -16,29 +16,27 @@ molecules = pybel.readfile("sdf","demo.sdf")
|
|
| 16 |
moleculeList = []
|
| 17 |
for item in molecules:
|
| 18 |
moleculeList.append(item)
|
| 19 |
-
|
| 20 |
-
st.write(moleculeList[0].molwt)
|
| 21 |
|
| 22 |
# Prepare a dataframe:
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import tempfile
|
| 4 |
|
| 5 |
from openbabel import pybel
|
| 6 |
+
from st_table_select_cell import st_table_select_cell
|
| 7 |
|
| 8 |
st.header("Openbabel test")
|
| 9 |
st.write("Select a molecul to visualize:")
|
|
|
|
| 16 |
moleculeList = []
|
| 17 |
for item in molecules:
|
| 18 |
moleculeList.append(item)
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# Prepare a dataframe:
|
| 21 |
+
data = pd.DataFrame({'Molecules':["molecule "+str(i) for i in range(len(moleculeList))]})
|
| 22 |
+
|
| 23 |
+
col1, col2 = st.columns(2)
|
| 24 |
+
|
| 25 |
+
with col1:
|
| 26 |
+
# Show table and get user selected cell:
|
| 27 |
+
selectedCell = st_table_select_cell(data)
|
| 28 |
+
if selectedCell != False:
|
| 29 |
+
|
| 30 |
+
# Visualize a molecule using a temporary file:
|
| 31 |
+
file = tempfile.NamedTemporaryFile(suffix = ".png", delete = True)
|
| 32 |
+
|
| 33 |
+
st.write(str("temporary file name is " + file.name))
|
| 34 |
+
|
| 35 |
+
moleculeList[int(selectedCell["rowId"])].draw(show = False, filename = file.name)
|
| 36 |
+
|
| 37 |
+
st.image(file.name, caption="Visualization")
|
| 38 |
+
|
| 39 |
+
with col2:
|
| 40 |
+
st.write("Select a subgraph:")
|
| 41 |
+
|
| 42 |
+
st.write("To be done.")
|
st_openbabel_demo.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import pandas as pd
|
| 3 |
-
import tempfile
|
| 4 |
-
|
| 5 |
-
from openbabel import pybel
|
| 6 |
-
from st_table_select_cell import st_table_select_cell
|
| 7 |
-
|
| 8 |
-
st.header("Openbabel test")
|
| 9 |
-
st.write("Select a molecul to visualize:")
|
| 10 |
-
|
| 11 |
-
# Open data in sdf format:
|
| 12 |
-
molecules = pybel.readfile("sdf","demo.sdf")
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
# Convert to a list of molecules:
|
| 16 |
-
moleculeList = []
|
| 17 |
-
for item in molecules:
|
| 18 |
-
moleculeList.append(item)
|
| 19 |
-
|
| 20 |
-
# Prepare a dataframe:
|
| 21 |
-
data = pd.DataFrame({'Molecules':["molecule "+str(i) for i in range(len(moleculeList))]})
|
| 22 |
-
|
| 23 |
-
col1, col2 = st.columns(2)
|
| 24 |
-
|
| 25 |
-
with col1:
|
| 26 |
-
# Show table and get user selected cell:
|
| 27 |
-
selectedCell = st_table_select_cell(data)
|
| 28 |
-
if selectedCell != False:
|
| 29 |
-
|
| 30 |
-
# Visualize a molecule using a temporary file:
|
| 31 |
-
file = tempfile.NamedTemporaryFile(suffix = ".png", delete = True)
|
| 32 |
-
|
| 33 |
-
st.write(str("temporary file name is " + file.name))
|
| 34 |
-
|
| 35 |
-
moleculeList[int(selectedCell["rowId"])].draw(show = False, filename = file.name)
|
| 36 |
-
|
| 37 |
-
st.image(file.name, caption="Visualization")
|
| 38 |
-
|
| 39 |
-
with col2:
|
| 40 |
-
st.write("Select a subgraph:")
|
| 41 |
-
|
| 42 |
-
st.write("To be done.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|