legend1234 commited on
Commit
25c6551
1 Parent(s): 169efdf

Fix the location of job submission button

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -5,12 +5,17 @@ from io import StringIO
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_extras.let_it_rain import rain
15
  from streamlit_ketcher import st_ketcher
16
 
@@ -44,6 +49,9 @@ resample_methods_dict = {
44
  "no resampling": "common",
45
  }
46
 
 
 
 
47
 
48
 
49
  def generate_predictions(
@@ -147,8 +155,8 @@ with info_column:
147
  data=file_smi,
148
  file_name="sample_input_smiles.csv",
149
  )
150
- # Create a file uploader
151
 
 
152
  with upload_column:
153
  st.subheader("Model Selection")
154
  with st.container():
@@ -180,9 +188,9 @@ with upload_column:
180
  with upload_col:
181
  file = st.file_uploader(
182
  label="Upload a CSV, SDF or TXT file",
183
- type=["csv", "sdf", "txt"],
184
- help="Input molecule file and only text files are supported.",
185
- # accept_multiple_files=False,
186
  )
187
  # submit job column
188
  with submit_job_col:
@@ -247,7 +255,10 @@ if submit_job_button:
247
 
248
  # feture table
249
  with feature_column:
250
- st.dataframe(X_features)
 
 
 
251
  # placeholder_features.dataframe(X_features, hide_index=False)
252
  feature_file_name = file.name.split(".")[0] + "_b3clf_features.csv"
253
  features_csv = X_features.to_csv(index=True)
@@ -262,7 +273,10 @@ if submit_job_button:
262
  # st.subheader("Predictions")
263
  if results is not None:
264
  # Display the predictions in a table
265
- st.dataframe(results, hide_index=True)
 
 
 
266
  # Add a button to download the predictions as a CSV file
267
  predictions_csv = results.to_csv(index=True)
268
  results_file_name = file.name.split(".")[0] + "_b3clf_predictions.csv"
 
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_extras.let_it_rain import rain
20
  from streamlit_ketcher import st_ketcher
21
 
 
49
  "no resampling": "common",
50
  }
51
 
52
+ pandas_display_options = {
53
+ "line_limit": 50,
54
+ }
55
 
56
 
57
  def generate_predictions(
 
155
  data=file_smi,
156
  file_name="sample_input_smiles.csv",
157
  )
 
158
 
159
+ # Create a file uploader
160
  with upload_column:
161
  st.subheader("Model Selection")
162
  with st.container():
 
188
  with upload_col:
189
  file = st.file_uploader(
190
  label="Upload a CSV, SDF or TXT file",
191
+ type=["csv", "sdf", "txt", "smi"],
192
+ help="Input molecule file only supports *.csv, *.sdf, *.txt and *.smi.",
193
+ accept_multiple_files=False,
194
  )
195
  # submit job column
196
  with submit_job_col:
 
255
 
256
  # feture table
257
  with feature_column:
258
+ selected_feature_rows = np.min(
259
+ [X_features.shape[0], pandas_display_options["line_limit"]]
260
+ )
261
+ st.dataframe(X_features.iloc[:selected_feature_rows, :], hide_index=False)
262
  # placeholder_features.dataframe(X_features, hide_index=False)
263
  feature_file_name = file.name.split(".")[0] + "_b3clf_features.csv"
264
  features_csv = X_features.to_csv(index=True)
 
273
  # st.subheader("Predictions")
274
  if results is not None:
275
  # Display the predictions in a table
276
+ selected_result_rows = np.min(
277
+ [results.shape[0], pandas_display_options["line_limit"]]
278
+ )
279
+ st.dataframe(results.iloc[:selected_result_rows, :], hide_index=True)
280
  # Add a button to download the predictions as a CSV file
281
  predictions_csv = results.to_csv(index=True)
282
  results_file_name = file.name.split(".")[0] + "_b3clf_predictions.csv"