Spaces:
Running
Running
Gilmullin Almaz
commited on
Commit
·
863a53f
1
Parent(s):
2e221c0
logging
Browse files
app.py
CHANGED
|
@@ -25,6 +25,8 @@ from cluster.rs_cgr import *
|
|
| 25 |
from cluster.clustering import *
|
| 26 |
from StructureFingerprint import MorganFingerprint
|
| 27 |
|
|
|
|
|
|
|
| 28 |
|
| 29 |
disable_progress_bars("huggingface_hub")
|
| 30 |
|
|
@@ -247,22 +249,50 @@ if submit_planning:
|
|
| 247 |
|
| 248 |
|
| 249 |
### Modified part
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
cluster_box, z = st.columns(2, gap="medium")
|
| 251 |
with cluster_box:
|
|
|
|
|
|
|
| 252 |
num_clusters = st.slider('Number of clusters to display', min_value=2, max_value=10, value=2)
|
| 253 |
|
| 254 |
submit_clustering = st.button('Start clustering')
|
| 255 |
|
| 256 |
if submit_clustering:
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
# Access results
|
| 267 |
clusters = results['clusters_dict']
|
| 268 |
|
|
|
|
| 25 |
from cluster.clustering import *
|
| 26 |
from StructureFingerprint import MorganFingerprint
|
| 27 |
|
| 28 |
+
import psutil
|
| 29 |
+
|
| 30 |
|
| 31 |
disable_progress_bars("huggingface_hub")
|
| 32 |
|
|
|
|
| 249 |
|
| 250 |
|
| 251 |
### Modified part
|
| 252 |
+
# cluster_box, z = st.columns(2, gap="medium")
|
| 253 |
+
# with cluster_box:
|
| 254 |
+
# num_clusters = st.slider('Number of clusters to display', min_value=2, max_value=10, value=2)
|
| 255 |
+
|
| 256 |
+
# submit_clustering = st.button('Start clustering')
|
| 257 |
+
|
| 258 |
+
# if submit_clustering:
|
| 259 |
+
# st.subheader("Examples of clusters")
|
| 260 |
+
# super_cgrs_dict = reassign_nums(tree)
|
| 261 |
+
|
| 262 |
+
# reduced_super_cgrs_dict = process_all_rs_cgrs(super_cgrs_dict)
|
| 263 |
+
|
| 264 |
+
# mfp = MorganFingerprint()
|
| 265 |
+
|
| 266 |
+
# results = cluster_molecules(reduced_super_cgrs_dict, mfp, max_clusters=num_clusters)
|
| 267 |
cluster_box, z = st.columns(2, gap="medium")
|
| 268 |
with cluster_box:
|
| 269 |
+
st.write(f"Current memory usage: {psutil.Process().memory_info().rss / 1024 / 1024:.2f} MB")
|
| 270 |
+
st.write(f"Number of winning nodes: {len(tree.winning_nodes)}")
|
| 271 |
num_clusters = st.slider('Number of clusters to display', min_value=2, max_value=10, value=2)
|
| 272 |
|
| 273 |
submit_clustering = st.button('Start clustering')
|
| 274 |
|
| 275 |
if submit_clustering:
|
| 276 |
+
try:
|
| 277 |
+
st.write("Starting clustering process...")
|
| 278 |
+
st.write(f"Memory before clustering: {psutil.Process().memory_info().rss / 1024 / 1024:.2f} MB")
|
| 279 |
+
|
| 280 |
+
super_cgrs_dict = reassign_nums(tree)
|
| 281 |
+
st.write("Reassign nums completed")
|
| 282 |
+
|
| 283 |
+
reduced_super_cgrs_dict = process_all_rs_cgrs(super_cgrs_dict)
|
| 284 |
+
st.write("Process RS CGRs completed")
|
| 285 |
+
|
| 286 |
+
st.write(f"Memory after CGR processing: {psutil.Process().memory_info().rss / 1024 / 1024:.2f} MB")
|
| 287 |
+
|
| 288 |
+
mfp = MorganFingerprint()
|
| 289 |
+
results = cluster_molecules(reduced_super_cgrs_dict, mfp, max_clusters=num_clusters)
|
| 290 |
+
st.write("Clustering completed")
|
| 291 |
+
|
| 292 |
+
except Exception as e:
|
| 293 |
+
st.error(f"Clustering failed with error: {str(e)}")
|
| 294 |
+
st.write(f"Tree state valid: {hasattr(tree, 'winning_nodes')}")
|
| 295 |
+
raise e
|
| 296 |
# Access results
|
| 297 |
clusters = results['clusters_dict']
|
| 298 |
|