jinysun commited on
Commit
4dc2bed
·
1 Parent(s): ee612e5

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -0
app.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import rdkit
5
+ import streamlit_ketcher
6
+ from streamlit_ketcher import st_ketcher
7
+ import abcBERT
8
+ import RF
9
+
10
+
11
+ # Page setup
12
+ st.set_page_config(page_title="DeepAcceptor", page_icon="🔋", layout="wide")
13
+ st.title("🔋DeepAcceptor")
14
+
15
+ # Connect to the Google Sheet
16
+ url1 = r"https://docs.google.com/spreadsheets/d/1YOEIg0nMTSPkAOr8wkqxQRLuUhys3-J0I-KPEpmzPLw/gviz/tq?tqx=out:csv&sheet=accept"
17
+ url = r"https://docs.google.com/spreadsheets/d/1YOEIg0nMTSPkAOr8wkqxQRLuUhys3-J0I-KPEpmzPLw/gviz/tq?tqx=out:csv&sheet=111"
18
+ df1 = pd.read_csv(url1, dtype=str, encoding='utf-8')
19
+ col1, col2 = st.columns(2)
20
+ with col1:
21
+ st.subheader("🔍**Search papers or molecules**")
22
+ text_search = st.text_input(label="_", value="",label_visibility="hidden" )
23
+ m1 = df1["name"].str.contains(text_search)
24
+ m2 = df1["reference"].str.contains(text_search)
25
+ df_search = df1[m1 | m2]
26
+ with col2:
27
+
28
+ st.link_button("📝**DATABASE**", r"https://docs.google.com/spreadsheets/d/1YOEIg0nMTSPkAOr8wkqxQRLuUhys3-J0I-KPEpmzPLw")
29
+ st.markdown('👆If you want to update the database, click the button.')
30
+ if text_search:
31
+ st.write(df_search)
32
+ st.download_button( "⬇️ Download edited files as .csv", df_search.to_csv(), "df_search.csv", use_container_width=True)
33
+ edited_df = st.data_editor(df1, num_rows="dynamic")
34
+ edited_df.to_csv(url)
35
+ st.download_button(
36
+ "⬇️ Download edited files as .csv", edited_df.to_csv(), "edited_df.csv", use_container_width=True
37
+ )
38
+ st.header("📋**Input the SMILES of Molecule**")
39
+ col3, col4= st.columns(2)
40
+
41
+ with col3:
42
+
43
+ molecule = st.text_input(label="*",label_visibility="hidden")
44
+ with col4:
45
+ st.markdown('👇An example of Y6.')
46
+ if st.button("🙋‍♂️**Example**"):
47
+ molecule = 'O=C(C(C=C(F)C(F)=C1)=C1C/2=C(C#N)/C#N)C2=C/C3=C(CCCCCCCCCCC)C(S4)=C(S3)C5=C4C6=C(N5CC(CC)CCCC)C7=C(C(SC8=C9SC(/C=C%10C(C(C=C(F)C(F)=C%11)=C%11C\%10=C(C#N)C#N)=O)=C8CCCCCCCCCCC)=C9N7CC(CC)CCCC)C%12=NSN=C6%12'
48
+
49
+ smile_code = st_ketcher(molecule)
50
+ st.subheader(f"✨**Smiles code**: {smile_code}")
51
+ mol = rdkit.Chem.MolFromSmiles(smile_code)
52
+ if mol is None:
53
+ st.subheader('**❗The SMILES is ERROR❗**')
54
+ else:
55
+ try :
56
+ P = RF.main( str(smile_code ) )
57
+ st.subheader(f"⚡**PCE predicted by RF**: {P}")
58
+ except:
59
+
60
+ st.subheader(f"⚡**PCE predicted by RF**: [Running]")
61
+ try:
62
+ pce = abcBERT.main( str(smile_code ) )
63
+ st.subheader(f"⚡**PCE predicted by abcBERT**: {pce}")
64
+ except:
65
+ st.subheader(f"⚡**PCE predicted by abcBERT**: [Running]")