Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import rdkit
|
| 4 |
+
import streamlit_ketcher
|
| 5 |
+
from streamlit_ketcher import st_ketcher
|
| 6 |
+
import run
|
| 7 |
+
import screen
|
| 8 |
+
|
| 9 |
+
# Page setup
|
| 10 |
+
st.set_page_config(page_title="DeepDAP", page_icon="🔋", layout="wide")
|
| 11 |
+
st.title("🔋DeepDAP")
|
| 12 |
+
st.subheader('',divider='rainbow')
|
| 13 |
+
# Connect to the Google Sheet
|
| 14 |
+
|
| 15 |
+
url1= r"https://docs.google.com/spreadsheets/d/1AKkZS04VF3osFT36aNHIb4iUbV8D1uNfsldcpHXogj0/gviz/tq?tqx=out:csv&sheet=dap"
|
| 16 |
+
df1 = pd.read_csv(url1, dtype=str, encoding='utf-8')
|
| 17 |
+
col1, col2 = st.columns(2)
|
| 18 |
+
st.subheader("🔍**Search papers or molecules**")
|
| 19 |
+
with col1:
|
| 20 |
+
|
| 21 |
+
text_search = st.text_input(label="_", value="",label_visibility="hidden" )
|
| 22 |
+
m1 = df1["Donor_Name"].str.contains(text_search)
|
| 23 |
+
m2 = df1["reference"].str.contains(text_search)
|
| 24 |
+
m3 = df1["Acceptor_Name"].str.contains(text_search)
|
| 25 |
+
df_search = df1[m1 | m2|m3]
|
| 26 |
+
with col2:
|
| 27 |
+
st.subheader(" ")
|
| 28 |
+
st.link_button(":black[📝**DATABASE**]", r"https://docs.google.com/spreadsheets/d/1AKkZS04VF3osFT36aNHIb4iUbV8D1uNfsldcpHXogj0")
|
| 29 |
+
st.caption(':black[👆If you want to update the origin 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 |
+
|
| 35 |
+
st.download_button(
|
| 36 |
+
"⬇️ Download edited files as .csv", edited_df.to_csv(), "edited_df.csv", use_container_width=True
|
| 37 |
+
)
|
| 38 |
+
#st.subheader("👇 :red[***Select the type of active layer...***]")
|
| 39 |
+
col3, col4 = st.columns(2)
|
| 40 |
+
with col3:
|
| 41 |
+
|
| 42 |
+
option = st.selectbox( ' 👇Select the type of active layer materials to be edited...',
|
| 43 |
+
("🎈Donor", "🎈Acceptor"), placeholder="👇Select the type of active layer materials...", )
|
| 44 |
+
with col4:
|
| 45 |
+
st.subheader(" ")
|
| 46 |
+
st.markdown('👇An example of PM6 : Y6.')
|
| 47 |
+
if st.button("🙋♂️**Example**"):
|
| 48 |
+
option ="example"
|
| 49 |
+
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'
|
| 50 |
+
do = 'CCCCC(CC)CC1=C(F)C=C(C2=C3C=C(C4=CC=C(C5=C6C(=O)C7=C(CC(CC)CCCC)SC(CC(CC)CCCC)=C7C(=O)C6=C(C6=CC=C(C)S6)S5)S4)SC3=C(C3=CC(F)=C(CC(CC)CCCC)S3)C3=C2SC(C)=C3)S1'
|
| 51 |
+
|
| 52 |
+
if option =="🎈Acceptor":
|
| 53 |
+
st.subheader("👨🔬**Input the SMILES of Acceptor Molecule**")
|
| 54 |
+
molecule = st.text_input("👨🔬**Input the SMILES of Acceptor Molecule**", label_visibility="hidden" )
|
| 55 |
+
acceptor= st_ketcher(molecule )
|
| 56 |
+
st.subheader(f"🏆**New SMILES of edited acceptor molecules**: {acceptor}")
|
| 57 |
+
st.subheader(":black[**🧡Input the SMILES of Donor Molecule**]")
|
| 58 |
+
donor= st.text_input(":black[**🧡Input the SMILES of Donor Molecule**]", label_visibility="hidden")
|
| 59 |
+
if option =="🎈Donor":
|
| 60 |
+
st.subheader("👨🔬**Input the SMILES of Donor Molecule**" )
|
| 61 |
+
do= st.text_input("👨🔬**Input the SMILES of Donor Molecule**" , label_visibility="hidden")
|
| 62 |
+
donor = st_ketcher(do)
|
| 63 |
+
st.subheader(f"🏆**New SMILES of edited donor molecules**: {donor}")
|
| 64 |
+
st.subheader(":black[**🧡Input the SMILES of Acceptor Molecule**]")
|
| 65 |
+
acceptor = st.text_input(":black[**🧡Input the SMILES of Acceptor Molecule**]", label_visibility="hidden")
|
| 66 |
+
if option =="example":
|
| 67 |
+
|
| 68 |
+
st.subheader("👨🔬**Input the SMILES of Acceptor**")
|
| 69 |
+
st.markdown(molecule)
|
| 70 |
+
acceptor= st_ketcher(molecule )
|
| 71 |
+
st.subheader(f"🏆**New SMILES of edited acceptor molecules**: {acceptor}")
|
| 72 |
+
st.subheader(":black[**🧡Input the SMILES of Donor**]")
|
| 73 |
+
st.markdown(do)
|
| 74 |
+
donor= do
|
| 75 |
+
try:
|
| 76 |
+
|
| 77 |
+
pce = run.smiles_aas_test( str(acceptor ), str(donor) )
|
| 78 |
+
st.subheader(f"⚡**PCE**: ``{pce}``")
|
| 79 |
+
except:
|
| 80 |
+
st.subheader(f"⚡**PCE**: None ")
|
| 81 |
+
st.subheader(":black[**🧡 High-throughput screening for high-performance D/A pairs**]")
|
| 82 |
+
col5, col6 = st.columns(2)
|
| 83 |
+
with col5:
|
| 84 |
+
uploaded_files = st.file_uploader("Choose a CSV file")
|
| 85 |
+
st.write( "🎈upload a csv file containing ['donor' ] and ['acceptor']")
|
| 86 |
+
with col6:
|
| 87 |
+
url2= r"https://docs.google.com/spreadsheets/d/1jPfHM21IjksNn_80fdakS1ofDNIagwMXBWAjoZBr-YY/gviz/tq?tqx=out:csv"
|
| 88 |
+
df2 = pd.read_csv(url2)
|
| 89 |
+
st.markdown('👇The example of input files for high-throughput screening.')
|
| 90 |
+
st.download_button(
|
| 91 |
+
"⬇️ Download example files", df2.to_csv(), "example.csv" )
|
| 92 |
+
|
| 93 |
+
if st.button("📑PREDICT"):
|
| 94 |
+
if uploaded_files is not None:
|
| 95 |
+
text = st.markdown(":red[Predictions are being made... Please wait...]")
|
| 96 |
+
st.progress(100, text=None)
|
| 97 |
+
x = screen.smiles_aas_test(uploaded_files )
|
| 98 |
+
fx = pd.DataFrame(list(x))
|
| 99 |
+
st.markdown(":red[Prediction finished! ]")
|
| 100 |
+
st.download_button( "⬇️Download the predicted files as .csv", fx.to_csv(), "predict results.csv", use_container_width=True)
|
| 101 |
+
else:
|
| 102 |
+
st.markdown(":red[Please upload the file first!]")
|