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
robert/aqme.py
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Parameters
|
|
3
|
+
----------
|
|
4
|
+
|
|
5
|
+
csv_name : str, default=''
|
|
6
|
+
Name of the CSV file containing the database with SMILES and code_name columns. A path can be provided (i.e. 'C:/Users/FOLDER/FILE.csv').
|
|
7
|
+
destination : str, default=None,
|
|
8
|
+
Directory to create the output file(s).
|
|
9
|
+
varfile : str, default=None
|
|
10
|
+
Option to parse the variables using a yaml file (specify the filename, i.e. varfile=FILE.yaml).
|
|
11
|
+
y : str, default=''
|
|
12
|
+
Name of the column containing the response variable in the input CSV file (i.e. 'solubility').
|
|
13
|
+
qdescp_keywords : str, default=''
|
|
14
|
+
Add extra keywords to the AQME-QDESCP run (i.e. qdescp_keywords="--qdescp_atoms ['Ir']")
|
|
15
|
+
descp_lvl : str, default='interpret'
|
|
16
|
+
Type of descriptor to be used in the AQME-ROBERT workflow. Options are 'interpret', 'denovo' or 'full'.
|
|
17
|
+
|
|
18
|
+
"""
|
|
19
|
+
#####################################################.
|
|
20
|
+
# This file stores the AQME class #
|
|
21
|
+
# used to perform the AQME-ROBERT workflow #
|
|
22
|
+
#####################################################.
|
|
23
|
+
|
|
24
|
+
import os
|
|
25
|
+
import glob
|
|
26
|
+
import subprocess
|
|
27
|
+
import time
|
|
28
|
+
import shutil
|
|
29
|
+
import sys
|
|
30
|
+
from pathlib import Path
|
|
31
|
+
import pandas as pd
|
|
32
|
+
from robert.utils import (load_variables,
|
|
33
|
+
finish_print,
|
|
34
|
+
load_database,
|
|
35
|
+
is_smiles_column
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
# list of potential arguments from CSV inputs in AQME
|
|
39
|
+
aqme_args = ['charge','mult','complex_type','geom','constraints_atoms','constraints_dist','constraints_angle','constraints_dihedral','sample']
|
|
40
|
+
|
|
41
|
+
class aqme:
|
|
42
|
+
"""
|
|
43
|
+
Class containing all the functions from the AQME module.
|
|
44
|
+
|
|
45
|
+
Parameters
|
|
46
|
+
----------
|
|
47
|
+
kwargs : argument class
|
|
48
|
+
Specify any arguments from the AQME module (for a complete list of variables, visit the ROBERT documentation)
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def __init__(self, **kwargs):
|
|
52
|
+
|
|
53
|
+
start_time = time.time()
|
|
54
|
+
|
|
55
|
+
# load default and user-specified variables
|
|
56
|
+
self.args = load_variables(kwargs, "aqme")
|
|
57
|
+
|
|
58
|
+
# check if AQME is installed (required for this module)
|
|
59
|
+
_ = self.init_aqme()
|
|
60
|
+
|
|
61
|
+
# run an AQME workflow, which includes CSEARCH and QDESCP jobs
|
|
62
|
+
self = self.run_csearch_qdescp(self.args.csv_name)
|
|
63
|
+
|
|
64
|
+
# run an AQME workflow for the test set (if any)
|
|
65
|
+
if self.args.csv_test != '':
|
|
66
|
+
_ = self.run_csearch_qdescp(self.args.csv_test,aqme_test=True)
|
|
67
|
+
|
|
68
|
+
# move AQME output files (remove previous runs as well)
|
|
69
|
+
_ = move_aqme()
|
|
70
|
+
|
|
71
|
+
# finish the printing of the AQME info file
|
|
72
|
+
_ = finish_print(self,start_time,'AQME')
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def run_csearch_qdescp(self,csv_target,aqme_test=False):
|
|
76
|
+
'''
|
|
77
|
+
Runs CSEARCH and QDESCP jobs in AQME
|
|
78
|
+
'''
|
|
79
|
+
|
|
80
|
+
# load database just to perform data checks (i.e. no need to run AQME if the specified y is not
|
|
81
|
+
# in the database, since the program would crush in the subsequent CURATE job)
|
|
82
|
+
job_type = 'aqme'
|
|
83
|
+
path_sdf = Path(f'{os.getcwd()}/CSEARCH/sdf_temp')
|
|
84
|
+
if aqme_test:
|
|
85
|
+
job_type = 'aqme_test'
|
|
86
|
+
if not path_sdf.exists():
|
|
87
|
+
path_sdf.mkdir(exist_ok=True, parents=True)
|
|
88
|
+
|
|
89
|
+
# move the SDF files from the csv_name run (otherwise, the xTB calcs are repeated in csv_test)
|
|
90
|
+
else:
|
|
91
|
+
if path_sdf.exists():
|
|
92
|
+
shutil.rmtree(path_sdf)
|
|
93
|
+
path_sdf.mkdir(exist_ok=True, parents=True)
|
|
94
|
+
for sdf_file in glob.glob(f'{os.getcwd()}/CSEARCH/*.sdf'):
|
|
95
|
+
new_sdf = path_sdf.joinpath(os.path.basename(sdf_file))
|
|
96
|
+
if os.path.exists(new_sdf):
|
|
97
|
+
os.remove(new_sdf)
|
|
98
|
+
shutil.move(sdf_file, new_sdf)
|
|
99
|
+
|
|
100
|
+
# Load database
|
|
101
|
+
csv_df,_,_ = load_database(self,csv_target,job_type,print_info=False)
|
|
102
|
+
|
|
103
|
+
# avoid running calcs with special signs (i.e. *)
|
|
104
|
+
for name_csv_indiv in csv_df['code_name']:
|
|
105
|
+
if '*' in f'{name_csv_indiv}':
|
|
106
|
+
self.args.log.write(f"\nx WARNING! The names provided in the CSV contain * (i.e. {name_csv_indiv}). Please, remove all the * characters.")
|
|
107
|
+
self.args.log.finalize()
|
|
108
|
+
sys.exit()
|
|
109
|
+
|
|
110
|
+
# find if there is more than one SMILES column in the CSV file
|
|
111
|
+
for column in csv_df.columns:
|
|
112
|
+
if is_smiles_column(column):
|
|
113
|
+
|
|
114
|
+
self.args.ignore.append(column)
|
|
115
|
+
|
|
116
|
+
# create individual csv file for each SMILES column
|
|
117
|
+
csv_temp = csv_df[['code_name', column] + [col for col in csv_df.columns if col.lower() in aqme_args]]
|
|
118
|
+
csv_temp.columns = ['code_name', 'SMILES'] + [col for col in csv_temp.columns if col.lower() in aqme_args]
|
|
119
|
+
|
|
120
|
+
if column.upper() == "SMILES":
|
|
121
|
+
smi_suffix = None
|
|
122
|
+
csv_temp.to_csv('AQME_indiv.csv', index=False)
|
|
123
|
+
aqme_indv_name = 'AQME_indiv'
|
|
124
|
+
else:
|
|
125
|
+
smi_suffix = column.split("_", 1)[1]
|
|
126
|
+
csv_temp['code_name'] = csv_temp['code_name'].astype(str) + '_' + smi_suffix
|
|
127
|
+
csv_temp.to_csv(f'AQME_indiv_{smi_suffix}.csv', index=False)
|
|
128
|
+
aqme_indv_name = f'AQME_indiv_{smi_suffix}'
|
|
129
|
+
|
|
130
|
+
# run AQME-QDESCP to generate descriptors
|
|
131
|
+
python_executable = sys.executable or 'python'
|
|
132
|
+
cmd_qdescp = [python_executable,'-u', '-m', 'aqme', '--qdescp', '--input', f'{aqme_indv_name}.csv', '--program', 'xtb', '--csv_name', f'{aqme_indv_name}.csv', '--nprocs', f'{self.args.nprocs}', '--robert']
|
|
133
|
+
_ = self.run_aqme(cmd_qdescp, self.args.qdescp_keywords)
|
|
134
|
+
|
|
135
|
+
if smi_suffix is not None:
|
|
136
|
+
# Change column names by adding suffix
|
|
137
|
+
try:
|
|
138
|
+
df_temp = pd.read_csv(f'AQME-ROBERT_{self.args.descp_lvl}_{aqme_indv_name}.csv', encoding='utf-8')
|
|
139
|
+
except FileNotFoundError:
|
|
140
|
+
self.args.log.write("x WARNING! ROBERT stopped due to a problem with the AQME job. Please, check the previous AQME warnings.")
|
|
141
|
+
sys.exit()
|
|
142
|
+
df_temp.columns = [f'{col}_{smi_suffix}' if col not in ['code_name','SMILES'] and col not in aqme_args else col for col in df_temp.columns]
|
|
143
|
+
df_temp.to_csv(f'AQME-ROBERT_{self.args.descp_lvl}_{aqme_indv_name}.csv', index=False)
|
|
144
|
+
|
|
145
|
+
# Check if there are missing rows in the AQME-ROBERT_{aqme_indv_name}.csv
|
|
146
|
+
if len(df_temp) < len(csv_temp):
|
|
147
|
+
missing_rows = csv_temp.loc[~csv_temp['code_name'].isin(df_temp['code_name'])]
|
|
148
|
+
# match df_temp's actual column set/order instead of assuming code_name/SMILES
|
|
149
|
+
# are the first two columns - AQME's output column order isn't guaranteed, and
|
|
150
|
+
# appending by raw position would silently misalign values into other columns
|
|
151
|
+
missing_full = missing_rows[['code_name', 'SMILES']].reindex(columns=df_temp.columns)
|
|
152
|
+
missing_full.to_csv(f'AQME-ROBERT_{self.args.descp_lvl}_{aqme_indv_name}.csv', mode='a', header=False, index=False)
|
|
153
|
+
|
|
154
|
+
# Get the order of code_name in aqme_indv_name
|
|
155
|
+
order = csv_temp['code_name'].tolist()
|
|
156
|
+
|
|
157
|
+
# Sort the rows in 'AQME-ROBERT_{aqme_indv_name}.csv' based on the order
|
|
158
|
+
df_temp = pd.read_csv(f'AQME-ROBERT_{self.args.descp_lvl}_{aqme_indv_name}.csv', encoding='utf-8')
|
|
159
|
+
df_temp = df_temp.sort_values(by='code_name', key=lambda x: x.map({v: i for i, v in enumerate(order)}))
|
|
160
|
+
|
|
161
|
+
# Fill missing values with corresponding SMILES row
|
|
162
|
+
df_temp = df_temp.fillna(df_temp.groupby('SMILES').transform('first'))
|
|
163
|
+
|
|
164
|
+
df_temp.to_csv(f'AQME-ROBERT_{self.args.descp_lvl}_{aqme_indv_name}.csv', index=False)
|
|
165
|
+
|
|
166
|
+
# return SDF files after csv_test
|
|
167
|
+
if aqme_test:
|
|
168
|
+
for sdf_file in glob.glob(f'{path_sdf}/*.sdf'):
|
|
169
|
+
new_sdf = Path(f'{os.getcwd()}/CSEARCH').joinpath(os.path.basename(sdf_file))
|
|
170
|
+
shutil.move(sdf_file, new_sdf)
|
|
171
|
+
shutil.rmtree(path_sdf)
|
|
172
|
+
|
|
173
|
+
aqme_db = f'AQME-ROBERT_{self.args.descp_lvl}_{Path(csv_target).name}'
|
|
174
|
+
|
|
175
|
+
# if AQME-ROBERT_AQME_indiv_n.csv >0 in folder:
|
|
176
|
+
if len(glob.glob(f'AQME-ROBERT_{self.args.descp_lvl}_AQME_indiv*.csv')) > 0:
|
|
177
|
+
|
|
178
|
+
df_concat = pd.DataFrame()
|
|
179
|
+
|
|
180
|
+
# Read and concatenate CSV files
|
|
181
|
+
for file in sorted(glob.glob(f'AQME-ROBERT_{self.args.descp_lvl}_AQME_indiv*.csv'), key=os.path.getmtime,reverse=True):
|
|
182
|
+
columns_to_drop = ['code_name', 'SMILES'] + aqme_args
|
|
183
|
+
df_temp = pd.read_csv(file, encoding='utf-8')
|
|
184
|
+
columns_to_drop = [col for col in columns_to_drop if col in df_temp.columns]
|
|
185
|
+
df_temp = df_temp.drop(columns=columns_to_drop)
|
|
186
|
+
df_concat = pd.concat([df_temp, df_concat], axis=1)
|
|
187
|
+
df_concat = pd.concat([csv_df, df_concat], axis=1)
|
|
188
|
+
df_concat.to_csv(aqme_db, index=False)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
# if no qdesc_atom is set, only keep molecular properties and discard atomic properties
|
|
192
|
+
# ensure that the AQME database was successfully created
|
|
193
|
+
if not os.path.exists(aqme_db):
|
|
194
|
+
self.args.log.write(f"\nx The initial AQME descriptor protocol did not create any CSV output!")
|
|
195
|
+
sys.exit()
|
|
196
|
+
|
|
197
|
+
# remove atomic properties if no SMARTS patterns were selected in qdescp
|
|
198
|
+
if 'qdescp_atoms' not in self.args.qdescp_keywords:
|
|
199
|
+
_ = filter_atom_prop(aqme_db,csv_df)
|
|
200
|
+
|
|
201
|
+
# remove arguments from CSV inputs in AQME
|
|
202
|
+
_ = filter_aqme_args(aqme_db)
|
|
203
|
+
|
|
204
|
+
# delete AQME_indiv*.csv files
|
|
205
|
+
for file in glob.glob('*QME_indiv*.csv'):
|
|
206
|
+
os.remove(file)
|
|
207
|
+
|
|
208
|
+
# this returns stores options just in case csv_test is included
|
|
209
|
+
return self
|
|
210
|
+
|
|
211
|
+
def run_aqme(self,command,extra_keywords):
|
|
212
|
+
'''
|
|
213
|
+
Function that runs the AQME jobs
|
|
214
|
+
'''
|
|
215
|
+
|
|
216
|
+
if extra_keywords != '':
|
|
217
|
+
for keyword in extra_keywords.split():
|
|
218
|
+
command.append(keyword)
|
|
219
|
+
|
|
220
|
+
subprocess.run(command)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def init_aqme(self):
|
|
224
|
+
'''
|
|
225
|
+
Checks whether AQME is installed
|
|
226
|
+
'''
|
|
227
|
+
|
|
228
|
+
try:
|
|
229
|
+
from aqme.qprep import qprep
|
|
230
|
+
except ModuleNotFoundError:
|
|
231
|
+
self.args.log.write("x AQME is not installed (required for the --aqme option)! The program is typically installed within 2-5 minutes (https://aqme.readthedocs.io, see the Installation section)")
|
|
232
|
+
sys.exit()
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def filter_atom_prop(aqme_db, csv_df):
|
|
236
|
+
'''
|
|
237
|
+
Function that filters off atomic properties if no atom was selected in the --qdescp_atoms option
|
|
238
|
+
'''
|
|
239
|
+
|
|
240
|
+
aqme_df = pd.read_csv(aqme_db, encoding='utf-8')
|
|
241
|
+
for column in aqme_df.columns:
|
|
242
|
+
if column == 'DBSTEP_Vbur':
|
|
243
|
+
aqme_df = aqme_df.drop(column, axis=1)
|
|
244
|
+
# remove lists of atomic properties (skip columns from AQME arguments)
|
|
245
|
+
elif aqme_df[column].dtype == object and column.lower() not in aqme_args:
|
|
246
|
+
# use the first non-missing value instead of row 0, since AQME can fail for the
|
|
247
|
+
# first molecule specifically and leave a NaN there (not iterable, unlike a string)
|
|
248
|
+
first_valid = aqme_df[column].dropna()
|
|
249
|
+
if not first_valid.empty and '[' in str(first_valid.iloc[0]) and column not in csv_df.columns:
|
|
250
|
+
aqme_df = aqme_df.drop(column, axis=1)
|
|
251
|
+
os.remove(aqme_db)
|
|
252
|
+
_ = aqme_df.to_csv(f'{aqme_db}', index=None, header=True)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def filter_aqme_args(aqme_db):
|
|
256
|
+
'''
|
|
257
|
+
Function that filters off AQME arguments in CSV inputs
|
|
258
|
+
'''
|
|
259
|
+
|
|
260
|
+
aqme_df = pd.read_csv(aqme_db, encoding='utf-8')
|
|
261
|
+
for column in aqme_df.columns:
|
|
262
|
+
if column.lower() in aqme_args:
|
|
263
|
+
aqme_df = aqme_df.drop(column, axis=1)
|
|
264
|
+
os.remove(aqme_db)
|
|
265
|
+
_ = aqme_df.to_csv(f'{aqme_db}', index = None, header=True)
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def move_aqme():
|
|
269
|
+
'''
|
|
270
|
+
Move raw data from AQME-CSEARCH and -QDESCP runs into the AQME folder
|
|
271
|
+
'''
|
|
272
|
+
|
|
273
|
+
for file in glob.glob(f'*'):
|
|
274
|
+
if 'CSEARCH' in file or 'QDESCP' in file:
|
|
275
|
+
if os.path.exists(f'AQME/{file}'):
|
|
276
|
+
if os.path.isdir(f'AQME/{file}'):
|
|
277
|
+
shutil.rmtree(f'AQME/{file}')
|
|
278
|
+
else:
|
|
279
|
+
os.remove(f'AQME/{file}')
|
|
280
|
+
shutil.move(file, f'AQME/{file}')
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#####################################################.
|
|
2
|
+
# This file contains the argument parser #
|
|
3
|
+
#####################################################.
|
|
4
|
+
|
|
5
|
+
import copy
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
var_dict = {
|
|
9
|
+
"varfile": None,
|
|
10
|
+
"command_line": False,
|
|
11
|
+
"extra_cmd": '',
|
|
12
|
+
"curate": False,
|
|
13
|
+
"generate": False,
|
|
14
|
+
"predict": False,
|
|
15
|
+
"verify": False,
|
|
16
|
+
"aqme": False,
|
|
17
|
+
"report": False,
|
|
18
|
+
"cheers": False,
|
|
19
|
+
"checkml": False,
|
|
20
|
+
"seed": 0,
|
|
21
|
+
"destination": None,
|
|
22
|
+
"csv_name" : '',
|
|
23
|
+
"csv_test": '',
|
|
24
|
+
"y" : '',
|
|
25
|
+
"discard" : [],
|
|
26
|
+
"ignore" : [],
|
|
27
|
+
"categorical" : "onehot",
|
|
28
|
+
"corr_filter_x" : True,
|
|
29
|
+
"corr_filter_y" : False,
|
|
30
|
+
"rfecv_filter" : True,
|
|
31
|
+
"std" : True,
|
|
32
|
+
# deprecated, no effect: kept only so old command lines/YAML files that pass it still run
|
|
33
|
+
"desc_thres" : 25,
|
|
34
|
+
"thres_y" : 0.001,
|
|
35
|
+
"thres_x" : 0.7,
|
|
36
|
+
"test_set" : 0.2,
|
|
37
|
+
"auto_test" : True,
|
|
38
|
+
"auto_type": True,
|
|
39
|
+
"auto_fill": True,
|
|
40
|
+
"model" : ['RF','GB','NN','MVL'],
|
|
41
|
+
"eval_model" : 'MVL',
|
|
42
|
+
"model_obj" : None,
|
|
43
|
+
"model_file" : '',
|
|
44
|
+
"model_params" : '',
|
|
45
|
+
"type" : "reg",
|
|
46
|
+
"split" : "auto",
|
|
47
|
+
"nprocs": 8,
|
|
48
|
+
"error_type" : "rmse",
|
|
49
|
+
"pfi_epochs" : 5,
|
|
50
|
+
"pfi_threshold" : 0.2,
|
|
51
|
+
"pfi_filter" : True,
|
|
52
|
+
"pfi_max" : 0,
|
|
53
|
+
"init_points" : 10,
|
|
54
|
+
"n_iter" : 10,
|
|
55
|
+
"expect_improv" : 0.05,
|
|
56
|
+
"kfold" : 5,
|
|
57
|
+
"repeat_kfolds" : 10,
|
|
58
|
+
"alpha" : 0.05,
|
|
59
|
+
"params_dir" : '',
|
|
60
|
+
"all_models" : True,
|
|
61
|
+
"t_value" : 2,
|
|
62
|
+
"shap_show" : 10,
|
|
63
|
+
"pfi_show" : 10,
|
|
64
|
+
"names" : '',
|
|
65
|
+
"qdescp_keywords" : '',
|
|
66
|
+
"descp_lvl": "interpret",
|
|
67
|
+
"report_modules" : ['AQME','CURATE','GENERATE','VERIFY','PREDICT'],
|
|
68
|
+
"debug_report": False,
|
|
69
|
+
# Internal API/BO uncertainty options. Normal ROBERT workflows leave them unused.
|
|
70
|
+
"_api_predict": False,
|
|
71
|
+
"conformal_enable": True,
|
|
72
|
+
"conformal_calib_frac": 0.15,
|
|
73
|
+
"conformal_coverage": 0.9,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# part for using the options in a script or jupyter notebook
|
|
78
|
+
class options_add:
|
|
79
|
+
pass
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def set_options(kwargs):
|
|
83
|
+
# set default options and options provided
|
|
84
|
+
options = options_add()
|
|
85
|
+
# dictionary containing default values for options
|
|
86
|
+
|
|
87
|
+
for key in var_dict:
|
|
88
|
+
vars(options)[key] = copy.deepcopy(var_dict[key])
|
|
89
|
+
for key in kwargs:
|
|
90
|
+
if key in var_dict:
|
|
91
|
+
vars(options)[key] = kwargs[key]
|
|
92
|
+
elif key.lower() in var_dict:
|
|
93
|
+
vars(options)[key.lower()] = kwargs[key]
|
|
94
|
+
else:
|
|
95
|
+
print("Warning! Option: [", key,":",kwargs[key],"] provided but no option exists, try the online documentation to see available options for each module.",)
|
|
96
|
+
sys.exit()
|
|
97
|
+
|
|
98
|
+
return options
|