robert 2.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- robert/__init__.py +9 -0
- robert/__main__.py +20 -0
- robert/_version.py +3 -0
- robert/api.py +646 -0
- robert/aqme.py +280 -0
- robert/argument_parser.py +98 -0
- robert/checkml.py +433 -0
- robert/checkml_score.py +50 -0
- robert/curate.py +217 -0
- robert/evaluate_bot_retrieval.py +125 -0
- robert/evaluate_bot_support.py +102 -0
- robert/evaluate_workflow_summaries.py +87 -0
- robert/export_bot_docs_knowledge.py +1632 -0
- robert/generate.py +249 -0
- robert/generate_utils.py +311 -0
- robert/gui_easyrob/__init__.py +0 -0
- robert/gui_easyrob/assets/gif_easyrob.gif +0 -0
- robert/gui_easyrob/bot/__init__.py +47 -0
- robert/gui_easyrob/bot/answer_metadata.py +198 -0
- robert/gui_easyrob/bot/bot_context.py +679 -0
- robert/gui_easyrob/bot/bot_engine.py +1100 -0
- robert/gui_easyrob/bot/bot_panel.py +1231 -0
- robert/gui_easyrob/bot/bot_rag.py +1178 -0
- robert/gui_easyrob/bot/bot_window.py +39 -0
- robert/gui_easyrob/bot/bot_worker.py +149 -0
- robert/gui_easyrob/bot/credential_store.py +143 -0
- robert/gui_easyrob/bot/error_parser.py +105 -0
- robert/gui_easyrob/bot/evidence_policy.py +164 -0
- robert/gui_easyrob/bot/heuristics.py +859 -0
- robert/gui_easyrob/bot/icons.py +56 -0
- robert/gui_easyrob/bot/input_csv_audit.py +212 -0
- robert/gui_easyrob/bot/knowledge/aqme_context.json +5907 -0
- robert/gui_easyrob/bot/knowledge/robert_context.json +4817 -0
- robert/gui_easyrob/bot/knowledge/ui_context.json +8293 -0
- robert/gui_easyrob/bot/knowledge_schema.py +1252 -0
- robert/gui_easyrob/bot/knowledge_sources/aqme_user_guidance.json +442 -0
- robert/gui_easyrob/bot/knowledge_sources/coverage_manifest.json +95 -0
- robert/gui_easyrob/bot/knowledge_sources/robert_user_guidance.json +471 -0
- robert/gui_easyrob/bot/knowledge_sources/ui_user_guidance.json +1312 -0
- robert/gui_easyrob/bot/llm_providers.py +1573 -0
- robert/gui_easyrob/bot/online_docs.py +105 -0
- robert/gui_easyrob/bot/prompt_policy.py +575 -0
- robert/gui_easyrob/bot/question_intent.py +562 -0
- robert/gui_easyrob/bot/response_quality.py +104 -0
- robert/gui_easyrob/bot/result_insights.py +225 -0
- robert/gui_easyrob/bot/token_usage.py +75 -0
- robert/gui_easyrob/bot/workflow_results.py +1396 -0
- robert/gui_easyrob/checkml_launcher.py +15 -0
- robert/gui_easyrob/easyrob.py +29 -0
- robert/gui_easyrob/easyrob_launcher.py +113 -0
- robert/gui_easyrob/main/__init__.py +9 -0
- robert/gui_easyrob/main/window.py +5152 -0
- robert/gui_easyrob/result_navigation.py +14 -0
- robert/gui_easyrob/tabs/__init__.py +23 -0
- robert/gui_easyrob/tabs/advanced_options.py +370 -0
- robert/gui_easyrob/tabs/aqme.py +1234 -0
- robert/gui_easyrob/tabs/checkml.py +898 -0
- robert/gui_easyrob/tabs/images.py +427 -0
- robert/gui_easyrob/tabs/interactive_predictions.py +555 -0
- robert/gui_easyrob/tabs/molssi.py +447 -0
- robert/gui_easyrob/tabs/predictions.py +484 -0
- robert/gui_easyrob/tabs/result_catalog.py +170 -0
- robert/gui_easyrob/tabs/results.py +490 -0
- robert/gui_easyrob/tabs/results_workspace.py +120 -0
- robert/gui_easyrob/test_bot_input_csv_audit.py +152 -0
- robert/gui_easyrob/test_bot_question_routing.py +383 -0
- robert/gui_easyrob/test_bot_result_analysis.py +356 -0
- robert/gui_easyrob/test_bot_retrieval_evaluation.py +110 -0
- robert/gui_easyrob/test_bot_ui_integration.py +278 -0
- robert/gui_easyrob/test_checkml_app_mode.py +124 -0
- robert/gui_easyrob/test_checkml_completion.py +57 -0
- robert/gui_easyrob/test_checkml_defaults.py +37 -0
- robert/gui_easyrob/test_checkml_result_summary.py +113 -0
- robert/gui_easyrob/test_checkml_web_mode.py +57 -0
- robert/gui_easyrob/test_dialog_layout.py +33 -0
- robert/gui_easyrob/test_gui_bot_regressions.py +320 -0
- robert/gui_easyrob/test_molssi_auto.py +569 -0
- robert/gui_easyrob/test_tutorial_view.py +215 -0
- robert/gui_easyrob/tutorials/check_model.md +25 -0
- robert/gui_easyrob/tutorials/chemdraw.md +49 -0
- robert/gui_easyrob/tutorials/csv.md +53 -0
- robert/gui_easyrob/tutorials/descriptors.md +21 -0
- robert/gui_easyrob/tutorials/overview.md +65 -0
- robert/gui_easyrob/tutorials/predictions.md +25 -0
- robert/gui_easyrob/tutorials/robbot.md +29 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/check_model/check_model_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_10.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_11.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_12.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_13.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_8.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/chemdraw/chemdraw_9.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_1_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_8.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/csv/csv_9.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/descriptors/descriptors_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_1_8.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_5_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/overview/overview_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_1_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/predictions/predictions_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_1.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_2.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_3.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_4.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_5.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_6.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_7.png +0 -0
- robert/gui_easyrob/tutorials/tutorial_images/robbot/robbot_8.png +0 -0
- robert/gui_easyrob/utils/__init__.py +0 -0
- robert/gui_easyrob/utils/aqme_utils.py +238 -0
- robert/gui_easyrob/utils/molssi_utils.py +584 -0
- robert/gui_easyrob/utils/predictions_utils.py +985 -0
- robert/gui_easyrob/utils/utils_gui.py +738 -0
- robert/gui_easyrob/version.py +68 -0
- robert/gui_easyrob/web/app.css +484 -0
- robert/gui_easyrob/web/app.html +134 -0
- robert/gui_easyrob/web/app.js +764 -0
- robert/gui_easyrob/web/checkml_brand.png +0 -0
- robert/gui_easyrob/web/easyrob_background.gif +0 -0
- robert/gui_easyrob/web/easyrob_background.png +0 -0
- robert/gui_easyrob/web/images.css +89 -0
- robert/gui_easyrob/web/images.html +39 -0
- robert/gui_easyrob/web/images.js +101 -0
- robert/gui_easyrob/web/results.js +499 -0
- robert/gui_easyrob/web/robert_brand.png +0 -0
- robert/gui_easyrob/web_dialogs.py +64 -0
- robert/gui_easyrob/web_results.py +253 -0
- robert/gui_easyrob/web_shell.py +684 -0
- robert/gui_easyrob/workflow_progress.py +89 -0
- robert/gui_easyrob/workflow_run_lock.py +27 -0
- robert/icons/CheckML_icon.png +0 -0
- robert/icons/Robert_icon.png +0 -0
- robert/icons/Robert_logo.jpg +0 -0
- robert/icons/Robert_logo_transparent.png +0 -0
- robert/icons/documentation_icon.png +0 -0
- robert/icons/info_icon.png +0 -0
- robert/icons/pdf_icon.png +0 -0
- robert/icons/play_icon.png +0 -0
- robert/icons/stop_icon.png +0 -0
- robert/icons/youtube_icon.ico +0 -0
- robert/predict.py +193 -0
- robert/predict_utils.py +410 -0
- robert/report/CheckML_logo.jpg +0 -0
- robert/report/GENERATE.png +0 -0
- robert/report/Robert_icon.ico +0 -0
- robert/report/Robert_logo.jpg +0 -0
- robert/report/Robert_logo1.jpg +0 -0
- robert/report/abbrev.png +0 -0
- robert/report/adv_anal.png +0 -0
- robert/report/checkml_pass.svg +3 -0
- robert/report/checkml_unclear.svg +3 -0
- robert/report/checkml_warning.svg +3 -0
- robert/report/features.png +0 -0
- robert/report/outliers.png +0 -0
- robert/report/pred.png +0 -0
- robert/report/repro.png +0 -0
- robert/report/robust_x.png +0 -0
- robert/report/robust_y_high.png +0 -0
- robert/report/robust_y_low.png +0 -0
- robert/report/score.png +0 -0
- robert/report/score_0.jpg +0 -0
- robert/report/score_1.jpg +0 -0
- robert/report/score_10.jpg +0 -0
- robert/report/score_2.jpg +0 -0
- robert/report/score_3.jpg +0 -0
- robert/report/score_4.jpg +0 -0
- robert/report/score_5.jpg +0 -0
- robert/report/score_6.jpg +0 -0
- robert/report/score_7.jpg +0 -0
- robert/report/score_8.jpg +0 -0
- robert/report/score_9.jpg +0 -0
- robert/report/score_gray_0.jpg +0 -0
- robert/report/score_gray_1.jpg +0 -0
- robert/report/score_gray_10.jpg +0 -0
- robert/report/score_gray_2.jpg +0 -0
- robert/report/score_gray_3.jpg +0 -0
- robert/report/score_gray_4.jpg +0 -0
- robert/report/score_gray_5.jpg +0 -0
- robert/report/score_gray_6.jpg +0 -0
- robert/report/score_gray_7.jpg +0 -0
- robert/report/score_gray_8.jpg +0 -0
- robert/report/score_gray_9.jpg +0 -0
- robert/report/score_w_1_0.jpg +0 -0
- robert/report/score_w_1_1.jpg +0 -0
- robert/report/score_w_2_0.jpg +0 -0
- robert/report/score_w_2_1.jpg +0 -0
- robert/report/score_w_2_2.jpg +0 -0
- robert/report/score_w_2_gray_0.jpg +0 -0
- robert/report/score_w_2_gray_1.jpg +0 -0
- robert/report/score_w_2_gray_2.jpg +0 -0
- robert/report/score_w_3_0.jpg +0 -0
- robert/report/score_w_3_1.jpg +0 -0
- robert/report/score_w_3_2.jpg +0 -0
- robert/report/score_w_3_3.jpg +0 -0
- robert/report/score_w_4_0.jpg +0 -0
- robert/report/score_w_4_1.JPG +0 -0
- robert/report/score_w_4_2.jpg +0 -0
- robert/report/score_w_4_3.jpg +0 -0
- robert/report/score_w_4_4.jpg +0 -0
- robert/report/transpa.png +0 -0
- robert/report/y_distrib.png +0 -0
- robert/report.py +2880 -0
- robert/report_utils.py +2270 -0
- robert/robert.py +181 -0
- robert/utils.py +4763 -0
- robert/verify.py +606 -0
- robert-2.2.0.dist-info/METADATA +55 -0
- robert-2.2.0.dist-info/RECORD +261 -0
- robert-2.2.0.dist-info/WHEEL +5 -0
- robert-2.2.0.dist-info/entry_points.txt +3 -0
- robert-2.2.0.dist-info/licenses/LICENSE +21 -0
- robert-2.2.0.dist-info/top_level.txt +1 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AQME utility helpers for easyROB.
|
|
3
|
+
|
|
4
|
+
This module provides domain-specific utilities used by the AQME tab, including
|
|
5
|
+
ChemDraw file handling and SMARTS pattern detection.
|
|
6
|
+
|
|
7
|
+
Responsibilities:
|
|
8
|
+
- Provide UI components for ChemDraw file selection
|
|
9
|
+
- Perform maximum common substructure (MCS) detection using RDKit
|
|
10
|
+
- Execute computationally expensive tasks in separate processes
|
|
11
|
+
- Bridge multiprocessing results back into the Qt event loop via signals
|
|
12
|
+
|
|
13
|
+
Architecture:
|
|
14
|
+
- Uses multiprocessing (Process + Queue) to avoid blocking the GUI
|
|
15
|
+
- Wraps background execution with Qt-compatible worker (MCSProcessWorker)
|
|
16
|
+
- Implements timeout handling to prevent long-running or stuck processes
|
|
17
|
+
|
|
18
|
+
Notes:
|
|
19
|
+
- Designed to isolate chemistry-heavy logic from GUI modules
|
|
20
|
+
- Ensures responsiveness when processing large molecular datasets
|
|
21
|
+
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
# ------------------------------------------------------------
|
|
25
|
+
# Standard library
|
|
26
|
+
# ------------------------------------------------------------
|
|
27
|
+
import os
|
|
28
|
+
from multiprocessing import Process, Queue
|
|
29
|
+
|
|
30
|
+
# ------------------------------------------------------------
|
|
31
|
+
# Third-party libraries
|
|
32
|
+
# ------------------------------------------------------------
|
|
33
|
+
from rdkit import Chem
|
|
34
|
+
from rdkit.Chem import rdFMCS
|
|
35
|
+
from PySide6.QtCore import QObject, QTimer, Qt, Signal
|
|
36
|
+
from PySide6.QtWidgets import (
|
|
37
|
+
QDialog,
|
|
38
|
+
QLabel,
|
|
39
|
+
QMessageBox as QtMessageBox,
|
|
40
|
+
QPushButton,
|
|
41
|
+
QVBoxLayout,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
from .utils_gui import QMessageBox
|
|
46
|
+
except ImportError:
|
|
47
|
+
QMessageBox = QtMessageBox
|
|
48
|
+
|
|
49
|
+
# ------------------------------------------------------------
|
|
50
|
+
# Local imports
|
|
51
|
+
# ------------------------------------------------------------
|
|
52
|
+
from .utils_gui import DropLabel
|
|
53
|
+
|
|
54
|
+
class ChemDrawFileDialog(QDialog):
|
|
55
|
+
"""Dialog that collects the main ChemDraw/SDF input file."""
|
|
56
|
+
|
|
57
|
+
def __init__(self, parent=None):
|
|
58
|
+
super().__init__(parent)
|
|
59
|
+
self.setWindowTitle("Select ChemDraw Files")
|
|
60
|
+
self.setMinimumWidth(500)
|
|
61
|
+
self.setWindowFlags(Qt.Dialog | Qt.MSWindowsFixedSizeDialogHint)
|
|
62
|
+
self.setSizeGripEnabled(True)
|
|
63
|
+
|
|
64
|
+
self.main_chemdraw_path = None
|
|
65
|
+
self.optional_chemdraw_path = None
|
|
66
|
+
|
|
67
|
+
layout = QVBoxLayout(self)
|
|
68
|
+
|
|
69
|
+
title = QLabel("Please select your ChemDraw files")
|
|
70
|
+
title.setStyleSheet("font-weight: bold; font-size: 16px;")
|
|
71
|
+
title.setAlignment(Qt.AlignCenter)
|
|
72
|
+
layout.addWidget(title)
|
|
73
|
+
|
|
74
|
+
self.main_label = DropLabel(
|
|
75
|
+
"Drag & Drop a main .sdf, .cdxml, or .mol",
|
|
76
|
+
self,
|
|
77
|
+
file_filter="ChemDraw Files (*.sdf *.cdxml *.mol *.cdx)",
|
|
78
|
+
extensions=(".sdf", ".cdxml", ".mol", ".cdx"),
|
|
79
|
+
)
|
|
80
|
+
self.main_label.set_callback(self.set_main_file)
|
|
81
|
+
layout.addWidget(self.main_label)
|
|
82
|
+
|
|
83
|
+
self.continue_button = QPushButton("Continue")
|
|
84
|
+
self.continue_button.setStyleSheet("padding: 8px; font-weight: bold;")
|
|
85
|
+
self.continue_button.clicked.connect(self.continue_clicked)
|
|
86
|
+
layout.addWidget(self.continue_button, alignment=Qt.AlignRight)
|
|
87
|
+
|
|
88
|
+
def set_main_file(self, path):
|
|
89
|
+
"""Set the main ChemDraw file path and update the label."""
|
|
90
|
+
self.main_chemdraw_path = path
|
|
91
|
+
self.main_label.setText(f"Selected: {os.path.basename(path)}")
|
|
92
|
+
|
|
93
|
+
def continue_clicked(self):
|
|
94
|
+
"""Check if a main ChemDraw file has been selected and accept the dialog."""
|
|
95
|
+
if not self.main_chemdraw_path:
|
|
96
|
+
QMessageBox.warning(self, "Missing File", "Please select a main ChemDraw file.")
|
|
97
|
+
return
|
|
98
|
+
self.accept()
|
|
99
|
+
|
|
100
|
+
def mcs_process(smiles_list, result_queue):
|
|
101
|
+
"""Find the maximum common substructure for a list of SMILES."""
|
|
102
|
+
try:
|
|
103
|
+
mol_list = []
|
|
104
|
+
for smiles in smiles_list:
|
|
105
|
+
mol = Chem.MolFromSmiles(smiles)
|
|
106
|
+
mol_with_hs = Chem.AddHs(mol)
|
|
107
|
+
if mol_with_hs:
|
|
108
|
+
mol_list.append(mol_with_hs)
|
|
109
|
+
|
|
110
|
+
if not mol_list:
|
|
111
|
+
result_queue.put(("error", "No valid molecules."))
|
|
112
|
+
return
|
|
113
|
+
|
|
114
|
+
mcs_result = rdFMCS.FindMCS(mol_list)
|
|
115
|
+
if mcs_result and mcs_result.smartsString:
|
|
116
|
+
result_queue.put(("success", mcs_result.smartsString))
|
|
117
|
+
else:
|
|
118
|
+
result_queue.put(("error", "⚠️ No common SMARTS pattern found."))
|
|
119
|
+
except Exception as exc:
|
|
120
|
+
result_queue.put(("error", f"❌ MCS failed: {str(exc)}"))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class MCSProcessWorker(QObject):
|
|
124
|
+
"""Async wrapper around a subprocess-based MCS calculation."""
|
|
125
|
+
|
|
126
|
+
finished = Signal(str)
|
|
127
|
+
error = Signal(str)
|
|
128
|
+
timeout = Signal()
|
|
129
|
+
|
|
130
|
+
def __init__(self, smiles_list, timeout_ms=10000):
|
|
131
|
+
super().__init__()
|
|
132
|
+
self.smiles_list = smiles_list
|
|
133
|
+
self.queue = Queue()
|
|
134
|
+
self.process = None
|
|
135
|
+
self.timer = QTimer()
|
|
136
|
+
self.timer.setSingleShot(True)
|
|
137
|
+
self.timer.timeout.connect(self._on_timeout)
|
|
138
|
+
self.timeout_ms = timeout_ms
|
|
139
|
+
self._poll_scheduled = False
|
|
140
|
+
self._finished = False
|
|
141
|
+
|
|
142
|
+
def start(self):
|
|
143
|
+
"""Start the MCS process and the timeout timer."""
|
|
144
|
+
self._finished = False
|
|
145
|
+
self.process = Process(target=mcs_process, args=(self.smiles_list, self.queue))
|
|
146
|
+
self.process.start()
|
|
147
|
+
self.timer.start(self.timeout_ms)
|
|
148
|
+
self._schedule_poll()
|
|
149
|
+
|
|
150
|
+
def _schedule_poll(self):
|
|
151
|
+
"""Schedule the next result poll only once at a time."""
|
|
152
|
+
if self._finished or self._poll_scheduled:
|
|
153
|
+
return
|
|
154
|
+
|
|
155
|
+
self._poll_scheduled = True
|
|
156
|
+
QTimer.singleShot(100, self.check_result)
|
|
157
|
+
|
|
158
|
+
def _finalize_process(self):
|
|
159
|
+
"""Release process and queue resources exactly once."""
|
|
160
|
+
if self._finished:
|
|
161
|
+
return
|
|
162
|
+
|
|
163
|
+
self._finished = True
|
|
164
|
+
self._poll_scheduled = False
|
|
165
|
+
self.timer.stop()
|
|
166
|
+
|
|
167
|
+
process = self.process
|
|
168
|
+
self.process = None
|
|
169
|
+
if process is not None:
|
|
170
|
+
try:
|
|
171
|
+
if process.is_alive():
|
|
172
|
+
process.join(timeout=1)
|
|
173
|
+
except Exception:
|
|
174
|
+
pass
|
|
175
|
+
|
|
176
|
+
try:
|
|
177
|
+
if process.is_alive():
|
|
178
|
+
process.terminate()
|
|
179
|
+
process.join(timeout=1)
|
|
180
|
+
except Exception:
|
|
181
|
+
pass
|
|
182
|
+
|
|
183
|
+
try:
|
|
184
|
+
process.close()
|
|
185
|
+
except Exception:
|
|
186
|
+
pass
|
|
187
|
+
|
|
188
|
+
queue = self.queue
|
|
189
|
+
self.queue = None
|
|
190
|
+
if queue is not None:
|
|
191
|
+
try:
|
|
192
|
+
while not queue.empty():
|
|
193
|
+
queue.get_nowait()
|
|
194
|
+
except Exception:
|
|
195
|
+
pass
|
|
196
|
+
|
|
197
|
+
try:
|
|
198
|
+
queue.close()
|
|
199
|
+
except Exception:
|
|
200
|
+
pass
|
|
201
|
+
|
|
202
|
+
try:
|
|
203
|
+
queue.join_thread()
|
|
204
|
+
except Exception:
|
|
205
|
+
pass
|
|
206
|
+
|
|
207
|
+
def check_result(self):
|
|
208
|
+
"""Check if the MCS process has produced a result or if it is still running."""
|
|
209
|
+
self._poll_scheduled = False
|
|
210
|
+
|
|
211
|
+
if self._finished or self.queue is None:
|
|
212
|
+
return
|
|
213
|
+
|
|
214
|
+
if not self.queue.empty():
|
|
215
|
+
status, msg = self.queue.get()
|
|
216
|
+
self._finalize_process()
|
|
217
|
+
if status == "success":
|
|
218
|
+
self.finished.emit(msg)
|
|
219
|
+
else:
|
|
220
|
+
self.error.emit(msg)
|
|
221
|
+
elif self.process is not None and self.process.is_alive():
|
|
222
|
+
self._schedule_poll()
|
|
223
|
+
else:
|
|
224
|
+
self._finalize_process()
|
|
225
|
+
|
|
226
|
+
def _on_timeout(self):
|
|
227
|
+
"""Terminate the MCS process and emit a timeout signal."""
|
|
228
|
+
if self._finished:
|
|
229
|
+
return
|
|
230
|
+
|
|
231
|
+
if self.process and self.process.is_alive():
|
|
232
|
+
try:
|
|
233
|
+
self.process.terminate()
|
|
234
|
+
except Exception:
|
|
235
|
+
pass
|
|
236
|
+
|
|
237
|
+
self._finalize_process()
|
|
238
|
+
self.timeout.emit()
|