File size: 1,131 Bytes
f294fda
b186a29
 
f294fda
 
b186a29
f294fda
 
 
 
 
 
 
 
 
 
 
 
 
 
b186a29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import streamlit as st
import pandas as pd
import tempfile

from openbabel import pybel
from st_table_select_cell import st_table_select_cell

st.header("Openbabel test")
st.write("Select a molecul to visualize:")

# Open data in sdf format:
molecules = pybel.readfile("sdf","demo.sdf")


# Convert to a list of molecules:
moleculeList = []
for item in molecules:
    moleculeList.append(item)
    
# Prepare a dataframe:
data = pd.DataFrame({'Molecules':["molecule "+str(i) for i in range(len(moleculeList))]})

col1, col2 = st.columns(2)

with col1:
    # Show table and get user selected cell:
    selectedCell = st_table_select_cell(data)
    if selectedCell != False:
        
        # Visualize a molecule using a temporary file:
        file = tempfile.NamedTemporaryFile(suffix = ".png", delete = True)
        
        st.write(str("temporary file name is " + file.name))
        
        moleculeList[int(selectedCell["rowId"])].draw(show = False, filename = file.name)
        
        st.image(file.name, caption="Visualization")
        
with col2:
    st.write("Select a subgraph:")
    
    st.write("To be done.")