convert df to csv before download
Browse files
app.py
CHANGED
|
@@ -52,6 +52,12 @@ def about_page():
|
|
| 52 |
)
|
| 53 |
|
| 54 |
st.image('figures/hyper-dti.png', caption='Overview of HyperPCM architecture.')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
def retrieval():
|
|
@@ -203,7 +209,9 @@ def retrieval():
|
|
| 203 |
mol_img = Chem.Draw.MolToImage(mol)
|
| 204 |
st.image(mol_img, caption=f"{results.loc[j + 5*i, 'Prediction']:.2f}")
|
| 205 |
|
| 206 |
-
st.download_button('Download
|
|
|
|
|
|
|
| 207 |
|
| 208 |
page_names_to_func = {
|
| 209 |
'Retrieval': retrieval,
|
|
|
|
| 52 |
)
|
| 53 |
|
| 54 |
st.image('figures/hyper-dti.png', caption='Overview of HyperPCM architecture.')
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
@st.cache
|
| 58 |
+
def convert_df(df):
|
| 59 |
+
# IMPORTANT: Cache the conversion to prevent computation on every rerun
|
| 60 |
+
return df.to_csv().encode('utf-8')
|
| 61 |
|
| 62 |
|
| 63 |
def retrieval():
|
|
|
|
| 209 |
mol_img = Chem.Draw.MolToImage(mol)
|
| 210 |
st.image(mol_img, caption=f"{results.loc[j + 5*i, 'Prediction']:.2f}")
|
| 211 |
|
| 212 |
+
st.download_button('Download retrieved drug compounds.', convert_df(results.head(selected_k)), file_name='retrieved_drugs.csv')
|
| 213 |
+
|
| 214 |
+
st.markdown('## TMP title')
|
| 215 |
|
| 216 |
page_names_to_func = {
|
| 217 |
'Retrieval': retrieval,
|