koptelovmax commited on
Commit
b186a29
·
1 Parent(s): cf82ed6
Files changed (2) hide show
  1. app.py +25 -27
  2. st_openbabel_demo.py +0 -42
app.py CHANGED
@@ -1,9 +1,9 @@
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,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
- #data = pd.DataFrame({'Molecules':["molecule "+str(i) for i in range(len(moleculeList))]})
24
-
25
- #col1, col2 = st.columns(2)
26
-
27
- #with col1:
28
- # # Show table and get user selected cell:
29
- # selectedCell = st_table_select_cell(data)
30
- # if selectedCell != False:
31
- #
32
- # # Visualize a molecule using a temporary file:
33
- # file = tempfile.NamedTemporaryFile(suffix = ".png", delete = True)
34
- #
35
- # st.write(str("temporary file name is " + file.name))
36
- #
37
- # moleculeList[int(selectedCell["rowId"])].draw(show = False, filename = file.name)
38
- #
39
- # st.image(file.name, caption="Visualization")
40
- #
41
- #with col2:
42
- # st.write("Select a subgraph:")
43
- #
44
- # st.write("To be done.")
 
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.")