Skip to content

Commit c803be0

Browse files
committed
1. Adding QDESCP-xTB and QCORR-ORCA pytests
1 parent baedcaa commit c803be0

File tree

16 files changed

+20476
-176
lines changed

16 files changed

+20476
-176
lines changed

Example_workflows/QCORR_processing_QM_outputs/QCORR_7/orca_TS_success.out

Lines changed: 8156 additions & 0 deletions
Large diffs are not rendered by default.

Example_workflows/QCORR_processing_QM_outputs/QCORR_7/orca_imag_freq.out

Lines changed: 11941 additions & 0 deletions
Large diffs are not rendered by default.

Example_workflows/QDESCP_generating_xtb_features/QDESCP_features.ipynb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
22
"cells": [
33
{
4+
"attachments": {},
45
"cell_type": "markdown",
56
"metadata": {},
67
"source": [
78
"#### Organic molecule with SMILES input, CSEARCH performs conformational sampling with RDKit, QDESCP produces xtb properties\n"
89
]
910
},
1011
{
12+
"attachments": {},
1113
"cell_type": "markdown",
1214
"metadata": {},
1315
"source": [
@@ -35,6 +37,7 @@
3537
]
3638
},
3739
{
40+
"attachments": {},
3841
"cell_type": "markdown",
3942
"metadata": {},
4043
"source": [
@@ -54,7 +57,7 @@
5457
"# 1) Program xTB (program='xtb')\n",
5558
"# 1) Files to run (files=sdf_rdkit_files)\n",
5659
"# 2) Include Boltzmann averaging and RDKit descriptors (boltz=True)\n",
57-
"qdescp(program='xtb',files=sdf_rdkit_files,boltz=True)\n",
60+
"qdescp(program='xtb',files=sdf_rdkit_files)\n",
5861
" "
5962
]
6063
},

aqme/aqme.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ def main():
216216
if args.qdescp:
217217
qdescp(
218218
verbose=args.verbose,
219+
command_line=args.command_line,
219220
w_dir_main=args.w_dir_main,
220221
destination=args.destination,
221222
files=args.files,

aqme/cmin.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@
101101
import time
102102
from aqme.utils import (
103103
load_variables,
104-
substituted_mol,
105104
mol_from_sdf_or_mol_or_mol2,
106-
add_prefix_suffix
105+
add_prefix_suffix,
106+
check_xtb
107107
)
108108
from aqme.filter import ewin_filter, pre_E_filter, RMSD_and_E_filter
109109
from aqme.cmin_utils import creation_of_dup_csv_cmin
@@ -140,6 +140,10 @@ def __init__(self, **kwargs):
140140
self.args.log.finalize()
141141
sys.exit()
142142

143+
# check if xTB is installed
144+
if self.args.program.lower() == "xtb":
145+
_ = check_xtb(self)
146+
143147
# retrieves the different files to run in CMIN
144148
if len(self.args.files) == 0:
145149
self.args.log.write('\nx No files were found! Make sure you use quotation marks if you are using * (i.e. --files "*.sdf")')
@@ -421,10 +425,10 @@ def compute_cmin(self, file):
421425

422426
return dup_data
423427

424-
# xTB AND ANI MAIN OPTIMIZATION PROCESS
428+
# ANI MAIN OPTIMIZATION PROCESS
425429
def ani_optimize(self, mol, charge, mult):
426430

427-
# Attempts ANI/xTB imports and exits if the programs are not installed
431+
# Attempts ANI imports and exits if the programs are not installed
428432
try:
429433
import torch
430434
import warnings
@@ -509,27 +513,14 @@ def get_cmin_model(self):
509513
Function to generate the optimization model for CMIN (using xTB or ANI methods)
510514
"""
511515

512-
if self.args.program.lower() == "ani":
513-
try:
514-
import torchani
515-
except (ImportError,ModuleNotFoundError):
516-
self.args.log.write("x Torchani is not installed! You can install the program with 'pip install torchani'")
517-
self.args.log.finalize()
518-
sys.exit()
519-
520-
model = getattr(torchani.models,self.args.ani_method)()
516+
try:
517+
import torchani
518+
except (ImportError,ModuleNotFoundError):
519+
self.args.log.write("x Torchani is not installed! You can install the program with 'pip install torchani'")
520+
self.args.log.finalize()
521+
sys.exit()
521522

522-
elif self.args.program.lower() == "xtb":
523-
try:
524-
subprocess.run(
525-
["xtb", "-h"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
526-
)
527-
except FileNotFoundError:
528-
self.args.log.write("x xTB is not installed (CREST cannot be used)! You can install the program with 'conda install -c conda-forge xtb'")
529-
self.args.log.finalize()
530-
sys.exit()
531-
532-
model = None
523+
model = getattr(torchani.models,self.args.ani_method)()
533524

534525
return model
535526

aqme/csearch/base.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
load_variables,
213213
set_metal_atomic_number,
214214
check_xtb,
215+
check_crest,
215216
get_files
216217
)
217218
from aqme.csearch.crest import xtb_opt_main
@@ -246,6 +247,7 @@ def __init__(self, **kwargs):
246247

247248
if self.args.program.lower() == "crest":
248249
_ = check_xtb(self)
250+
_ = check_crest(self)
249251

250252
if self.args.smi is None and self.args.input == "":
251253
self.args.log.write("\nx Program requires either a SMILES or an input file to proceed! Please look up acceptable file formats. Specify: smi='CCC' (or input='filename.csv')")
@@ -351,7 +353,12 @@ def load_jobs(self, csearch_file):
351353

352354
# Prepare the jobs
353355
prepare_function = Extension2inputgen[file_format]
354-
job_inputs = prepare_function(self.args, csearch_file)
356+
try:
357+
job_inputs = prepare_function(self.args, csearch_file)
358+
except FileNotFoundError:
359+
self.args.log.write(f'\nx File {os.path.basename(csearch_file)} was not found! In the "input" option, make sure that 1) the PATH to the files is correct and 2) the PATH doesn\'t start with "/".')
360+
self.args.log.finalize()
361+
sys.exit()
355362

356363
return job_inputs
357364

aqme/csearch/crest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def xtb_opt_main(
239239
run_command(command, f"{xyzin.split('.')[0]}_xtb1.out")
240240
os.rename(str(dat_dir) + "/xtbopt.xyz", xyzoutxtb1)
241241
except FileNotFoundError:
242-
self.args.log.write(f"\nx There was an error during the xTB pre-optimization. This error is related to parallelization of xTB jobs and is normally observed when using metal complexes in some operative systems/OpenMP versions. AQME is switching to using one processor (nprocs=1).\n")
242+
self.args.log.write(f"\nx There was an error during the xTB pre-optimization. This error is related to parallelization of xTB jobs and is normally observed when using metal complexes in some operative systems/OpenMP versions. AQME is switching to using one processor (nprocs=1).\n")
243243
self.args.nprocs = 1
244244
try:
245245
if self.args.xtb_keywords is None:
@@ -252,9 +252,9 @@ def xtb_opt_main(
252252
os.rename(str(dat_dir) + "/xtbopt.xyz", xyzoutxtb1)
253253
except FileNotFoundError:
254254
if self.args.program.lower() == "crest":
255-
self.args.log.write(f"\nx There was another error during the xTB pre-optimization that could not be fixed. Trying CREST directly with no xTB preoptimization.\n")
255+
self.args.log.write(f"\nx There was another error during the xTB pre-optimization that could not be fixed. Trying CREST directly with no xTB preoptimization.\n")
256256
else:
257-
self.args.log.write(f"\nx There was another error during the xTB pre-optimization that could not be fixed (this molecule will be skipped).\n")
257+
self.args.log.write(f"\nx There was another error during the xTB pre-optimization that could not be fixed (this molecule will be skipped).\n")
258258
cmin_valid = False
259259
mol_rd = None
260260

@@ -324,7 +324,7 @@ def xtb_opt_main(
324324
else:
325325
shutil.copy(str(dat_dir) + "/crest_conformers.xyz", xyzoutall)
326326
except FileNotFoundError:
327-
self.args.log.write("\nx CREST conformer sampling failed! Please, try other options (i.e. include constrains, change the crest_keywords option, etc.)")
327+
self.args.log.write("\nx CREST conformer sampling failed! Please, try other options (i.e. include constrains, change the crest_keywords option, etc.)")
328328
cmin_valid = False
329329

330330
if cmin_valid:

aqme/filter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,15 @@ def filters(mol, log, molwt_cutoff):
325325
# Filter 1
326326
molwt_cutoff = float(molwt_cutoff)
327327
if Descriptors.MolWt(mol) >= molwt_cutoff and molwt_cutoff > 0:
328-
log.write(f"x Skipping this molecule as total molar mass > {molwt_cutoff}")
328+
log.write(f"x Skipping this molecule as total molar mass > {molwt_cutoff}")
329329
return False
330330

331331
# Filter 2
332332
symbols = [atom.GetSymbol() for atom in mol.GetAtoms()]
333333

334334
unknown_atoms = list(set(symbols) - set(periodic_table()))
335335
if unknown_atoms:
336-
log.write(f" Exiting as atoms [{','.join(unknown_atoms)}] are not in the periodic table")
336+
log.write(f"x Exiting as atoms [{','.join(unknown_atoms)}] are not in the periodic table")
337337
return False
338338

339339
# Passed

aqme/qcorr_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ def get_json_data(self, file, cclib_data):
617617
cclib_data["metadata"]["keywords line"] = keywords_line[1:].rstrip("\n")
618618
calc_type = "ground_state"
619619
for keyword in keywords_line.split():
620-
if keyword.lower() in ["OptTS",'NEB-TS']:
620+
if keyword.lower() in ["optts",'neb-ts']:
621621
calc_type = "transition_state"
622622
break
623623
if keyword.lower()[0:3] == 'pal':

0 commit comments

Comments
 (0)