legend1234 commited on
Commit
ed190ed
1 Parent(s): e1092cb

Update layout

Browse files
Files changed (2) hide show
  1. .streamlit/config.toml +3 -0
  2. app.py +62 -25
.streamlit/config.toml CHANGED
@@ -1,2 +1,5 @@
1
  [theme]
2
  base="light"
 
 
 
 
1
  [theme]
2
  base="light"
3
+
4
+ [server]
5
+ maxUploadSize=2
app.py CHANGED
@@ -5,22 +5,17 @@ from io import StringIO
5
  import joblib
6
  import numpy as np
7
  import pandas as pd
8
-
9
  # page set up
10
  import streamlit as st
11
  from b3clf.descriptor_padel import compute_descriptors
12
  from b3clf.geometry_opt import geometry_optimize
13
- from b3clf.utils import (
14
- get_descriptors,
15
- predict_permeability,
16
- scale_descriptors,
17
- select_descriptors,
18
- )
19
  from streamlit_ketcher import st_ketcher
20
 
21
  st.set_page_config(
22
  page_title="BBB Permeability Prediction with Imbalanced Learning",
23
- page_icon="🧊",
24
  layout="wide",
25
  # initial_sidebar_state="expanded",
26
  # menu_items={
@@ -130,21 +125,48 @@ def generate_predictions(
130
 
131
 
132
  # Create the Streamlit app
133
- st.title("BBB Permeability Prediction with Imbalanced Learning")
 
134
 
135
  # Create a file uploader
136
 
137
- st.subheader("Input Data")
138
- file = st.file_uploader(
139
- "Upload a CSV or SDF file",
140
- type=["csv", "sdf", "txt"],
141
- # accept_multiple_files=False,
142
- )
 
 
143
  # st.write("The content of the file will be displayed below once uploaded.")
144
- if file:
145
- # if "csv" in file.name or "txt" in file.name:
146
- # st.write(file.read().decode("utf-8"))
147
- st.write(file)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
 
149
 
150
  # Generate predictions when the user uploads a file
@@ -157,24 +179,39 @@ if file:
157
  temp_file.write(file.read())
158
  X_features, results = generate_predictions(temp_file_path)
159
 
160
- feature_column, prediction_column = st.columns(2)
161
-
162
  # feture table
163
  with feature_column:
164
- st.subheader("Features")
165
  st.dataframe(X_features)
 
 
 
 
 
 
 
 
166
 
167
  # prediction table
168
  with prediction_column:
169
- st.subheader("Predictions")
170
  if results is not None:
171
  # Display the predictions in a table
172
- st.dataframe(results)
173
  # Add a button to download the predictions as a CSV file
174
- predictions_csv = results.to_csv(index=False)
175
  results_file_name = file.name.split(".")[0] + "_b3clf_predictions.csv"
176
  st.download_button(
177
  "Download predictions as CSV",
178
  data=predictions_csv,
179
  file_name=results_file_name,
180
  )
 
 
 
 
 
 
 
 
 
 
 
5
  import joblib
6
  import numpy as np
7
  import pandas as pd
 
8
  # page set up
9
  import streamlit as st
10
  from b3clf.descriptor_padel import compute_descriptors
11
  from b3clf.geometry_opt import geometry_optimize
12
+ from b3clf.utils import (get_descriptors, predict_permeability,
13
+ scale_descriptors, select_descriptors)
 
 
 
 
14
  from streamlit_ketcher import st_ketcher
15
 
16
  st.set_page_config(
17
  page_title="BBB Permeability Prediction with Imbalanced Learning",
18
+ # page_icon="🧊",
19
  layout="wide",
20
  # initial_sidebar_state="expanded",
21
  # menu_items={
 
125
 
126
 
127
  # Create the Streamlit app
128
+ st.title(":blue[BBB Permeability Prediction with Imbalanced Learning]")
129
+ info_column, upload_column = st.columns(2)
130
 
131
  # Create a file uploader
132
 
133
+ with upload_column:
134
+ st.subheader("Molecule Input")
135
+ file = st.file_uploader(
136
+ label="Upload a CSV, SDF or TXT file",
137
+ type=["csv", "sdf", "txt"],
138
+ help="Input molecule file and only text files are supported.",
139
+ # accept_multiple_files=False,
140
+ )
141
  # st.write("The content of the file will be displayed below once uploaded.")
142
+ # if file:
143
+ # if "csv" in file.name or "txt" in file.name:
144
+ # st.write(file.read().decode("utf-8"))
145
+ # st.write(file)
146
+
147
+ with info_column:
148
+ st.subheader("About `B3clf`")
149
+ # fmt: off
150
+ st.markdown(
151
+ """
152
+ `B3clf` is a Python package for predicting the blood-brain barrier (BBB) permeability of small molecules using imbalanced learning. Source code is available at https://github.com/theochem/B3clf.""" #
153
+ )
154
+ # fmt: on
155
+
156
+ feature_column, prediction_column = st.columns(2)
157
+ with feature_column:
158
+ st.subheader("Features")
159
+ placeholder_features = st.empty()
160
+ # placeholder_features = pd.DataFrame(index=[1, 2, 3, 4],
161
+ # columns=["ID", "nAcid", "ALogP", "Alogp2",
162
+ # "AMR", "naAromAtom", "nH", "nN"])
163
+ # st.dataframe(placeholder_features)
164
+ placeholder_features.text("molecular features")
165
+
166
+ with prediction_column:
167
+ st.subheader("Predictions")
168
+ # placeholder_predictions = st.empty()
169
+ # placeholder_predictions.text("prediction")
170
 
171
 
172
  # Generate predictions when the user uploads a file
 
179
  temp_file.write(file.read())
180
  X_features, results = generate_predictions(temp_file_path)
181
 
 
 
182
  # feture table
183
  with feature_column:
 
184
  st.dataframe(X_features)
185
+ # placeholder_features.dataframe(X_features, hide_index=False)
186
+ feature_file_name = file.name.split(".")[0] + "_b3clf_features.csv"
187
+ features_csv = X_features.to_csv(index=True)
188
+ st.download_button(
189
+ "Download features as CSV",
190
+ data=features_csv,
191
+ file_name=feature_file_name,
192
+ )
193
 
194
  # prediction table
195
  with prediction_column:
196
+ # st.subheader("Predictions")
197
  if results is not None:
198
  # Display the predictions in a table
199
+ st.dataframe(results, hide_index=True)
200
  # Add a button to download the predictions as a CSV file
201
+ predictions_csv = results.to_csv(index=True)
202
  results_file_name = file.name.split(".")[0] + "_b3clf_predictions.csv"
203
  st.download_button(
204
  "Download predictions as CSV",
205
  data=predictions_csv,
206
  file_name=results_file_name,
207
  )
208
+
209
+ # hide footer
210
+ # https://github.com/streamlit/streamlit/issues/892
211
+ hide_streamlit_style = """
212
+ <style>
213
+ #MainMenu {visibility: hidden;}
214
+ footer {visibility: hidden;}
215
+ </style>
216
+ """
217
+ st.markdown(hide_streamlit_style, unsafe_allow_html=True)