|
20 | 20 | import argparse
|
21 | 21 | import tempfile
|
22 | 22 | import subprocess
|
| 23 | +import json |
23 | 24 |
|
24 | 25 | import matplotlib
|
25 | 26 |
|
@@ -344,16 +345,24 @@ def main(structure, work_directory, library, csdrefcode):
|
344 | 345 | crystal = crystal_reader[0]
|
345 | 346 |
|
346 | 347 | directory = os.path.join(os.path.abspath(work_directory), crystal.identifier)
|
347 |
| - |
348 |
| - try: |
349 |
| - propensities, donors, acceptors = propensity_calc(crystal, directory) |
350 |
| - coordination_scores = coordination_scores_calc(crystal, directory) |
351 |
| - pair_output(crystal.identifier, propensities, donors, acceptors, coordination_scores, directory) |
352 |
| - mc_dictionary[coformer_name] = get_mc_scores(propensities, crystal.identifier) |
353 |
| - |
354 |
| - except RuntimeError: |
355 |
| - print("Propensity calculation failure for %s!" % coformer_name) |
356 |
| - mc_dictionary[coformer_name] = ["N/A", "N/A", "N/A", "N/A", "N/A", crystal.identifier] |
| 348 | + if os.path.exists(os.path.join(directory, "success.json")): |
| 349 | + with open(os.path.join(directory, "success.json"), "r") as file: |
| 350 | + tloaded = json.load(file) |
| 351 | + mc_dictionary[coformer_name] = tloaded |
| 352 | + else: |
| 353 | + try: |
| 354 | + propensities, donors, acceptors = propensity_calc(crystal, directory) |
| 355 | + coordination_scores = coordination_scores_calc(crystal, directory) |
| 356 | + pair_output(crystal.identifier, propensities, donors, acceptors, coordination_scores, directory) |
| 357 | + with open(os.path.join(directory, "success.json"), "w") as file: |
| 358 | + tdata = get_mc_scores(propensities, crystal.identifier) |
| 359 | + json.dump(tdata, file) |
| 360 | + mc_dictionary[coformer_name] = get_mc_scores(propensities, crystal.identifier) |
| 361 | + print(get_mc_scores(propensities, crystal.identifier)) |
| 362 | + except RuntimeError: |
| 363 | + print("Propensity calculation failure for %s!" % coformer_name) |
| 364 | + mc_dictionary[coformer_name] = ["N/A", "N/A", "N/A", "N/A", "N/A", crystal.identifier] |
| 365 | + failures.append(coformer_name) |
357 | 366 |
|
358 | 367 | # Make sense of the outputs of all the calculations
|
359 | 368 | 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