Skip to content

Commit 6e1fce2

Browse files
committed
Verifies if mol2 files have 3d coordinates to avoid running if there are no 3d coordinates and gives out a warning.
1 parent df7115d commit 6e1fce2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

scripts/multi_component_hydrogen_bond_propensity/multi_component_hydrogen_bond_propensity_report.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import tempfile
2222
import subprocess
2323
import json
24+
import warnings
2425

2526
import matplotlib
2627

@@ -32,8 +33,6 @@
3233
from ccdc.descriptors import CrystalDescriptors
3334

3435
try:
35-
import warnings
36-
3736
with warnings.catch_warnings():
3837
warnings.simplefilter("ignore", category=DeprecationWarning)
3938
import docxtpl
@@ -344,6 +343,11 @@ def main(structure, work_directory, failure_directory, library, csdrefcode, forc
344343
# for each coformer in the library, make a pair file for the api/coformer and run a HBP calculation
345344
for i, f in enumerate(coformer_files):
346345
molecule_file, coformer_name = make_pair_file(api_molecule, tempdir, f, i + 1)
346+
if not io.CrystalReader(f)[0].molecule.is_3d:
347+
failure_warning = f"Could not run for {coformer_name} no 3d coordinates present."
348+
failures.append(failure_warning)
349+
warnings.warn(failure_warning)
350+
continue
347351
print(coformer_name)
348352
crystal_reader = io.CrystalReader(molecule_file)
349353
crystal = crystal_reader[0]
@@ -366,7 +370,7 @@ def main(structure, work_directory, failure_directory, library, csdrefcode, forc
366370
print("Propensity calculation failure for %s!" % coformer_name)
367371
print(error_message)
368372
mc_dictionary[coformer_name] = ["N/A", "N/A", "N/A", "N/A", "N/A", crystal.identifier]
369-
failures.append(f"coformer_name: {error_message}")
373+
failures.append(f"{coformer_name}: {error_message}")
370374

371375
# Make sense of the outputs of all the calculations
372376
mc_hbp_screen = sorted(mc_dictionary.items(), key=lambda e: 0 if e[1][0] == 'N/A' else e[1][0], reverse=True)

0 commit comments

Comments
 (0)