From 7722b0f990d95ccd6ffa5adeb1e77727f24603af Mon Sep 17 00:00:00 2001 From: Isaac Sugden Date: Fri, 3 Jul 2026 16:53:18 +0100 Subject: [PATCH 1/2] example script for creating csv files from existing CSD entries NO_JIRA --- existing_CSD_data.py | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 existing_CSD_data.py diff --git a/existing_CSD_data.py b/existing_CSD_data.py new file mode 100644 index 0000000..d9c7687 --- /dev/null +++ b/existing_CSD_data.py @@ -0,0 +1,56 @@ +import ccdc +import sys +import os +import numpy as np + +entries = ccdc.io.EntryReader('CSD') +family = sys.argv[1] +common_name = sys.argv[2] +Polymorphs = [] +volumes_by_polymorph = {} +temperature_by_polymorph = {} +Refcode_by_polymorph = {} +dois_by_polymorph = {} +for i in range(9): + if i == 0: + num = "" + else: + num = "%02i" % i + full_name = f"{family}{num}" + print(full_name) + try: + entry = entries.entry(full_name) + except Exception as e: + print(f"Could not retrieve crystal for {full_name}: {e}") + break + polymorph = entry.polymorph if entry.polymorph else "Unknown" + volume = entry.crystal.cell_volume + if volume is not None: + if polymorph not in volumes_by_polymorph: + volumes_by_polymorph[polymorph] = [] + volumes_by_polymorph[polymorph].append(volume) + temperature = entry.temperature if entry.temperature else "Unknown" + if temperature is not None: + if polymorph not in temperature_by_polymorph: + temperature_by_polymorph[polymorph] = [] + temperature_by_polymorph[polymorph].append(temperature) + refcode = entry.identifier + if polymorph not in Refcode_by_polymorph: + Refcode_by_polymorph[polymorph] = [] + Refcode_by_polymorph[polymorph].append(refcode) + doi = entry.publication.doi if entry.publication and entry.publication.doi else "Unknown" + if polymorph not in dois_by_polymorph: + dois_by_polymorph[polymorph] = [] + dois_by_polymorph[polymorph].append(doi) +if os.path.exists(common_name): + print(f"folder {common_name} exists.") +else: + print(f"making folder {common_name}") + os.mkdir(common_name) + +for polymorph, volumes in volumes_by_polymorph.items(): + output_file = open(os.path.join(common_name, f"{polymorph}_volume.csv"), 'w') + output_file.write("%s\n" % (Refcode_by_polymorph[polymorph][0])) # should be best R factor refcode rather than first really + output_file.write("Identifier, Property , Value (Angstrom^3), Std, N, Name, Reference , Comment\n") + output_file.write(f"1, Unit Cell Volume @ {temperature_by_polymorph[polymorph][0]}, {np.mean(volumes):.2f}, {np.std(volumes):.2f}, {len(volumes)}, ,{dois_by_polymorph[polymorph][0]}, generated by automatic script; add Name and double check temperature etc.\n") + From f8a32b0cb1fd53e3938f04adecb894bb329a4c96 Mon Sep 17 00:00:00 2001 From: Isaac Sugden Date: Fri, 3 Jul 2026 16:54:36 +0100 Subject: [PATCH 2/2] example output from the script NO_JIRA --- Pyrazinamide/alpha polymorph_volume.csv | 3 +++ Pyrazinamide/beta polymorph_volume.csv | 3 +++ Pyrazinamide/delta polymorph_volume.csv | 3 +++ Pyrazinamide/gamma polymorph_volume.csv | 3 +++ 4 files changed, 12 insertions(+) create mode 100644 Pyrazinamide/alpha polymorph_volume.csv create mode 100644 Pyrazinamide/beta polymorph_volume.csv create mode 100644 Pyrazinamide/delta polymorph_volume.csv create mode 100644 Pyrazinamide/gamma polymorph_volume.csv diff --git a/Pyrazinamide/alpha polymorph_volume.csv b/Pyrazinamide/alpha polymorph_volume.csv new file mode 100644 index 0000000..9dcb813 --- /dev/null +++ b/Pyrazinamide/alpha polymorph_volume.csv @@ -0,0 +1,3 @@ +PYRZIN +Identifier, Property , Value (Angstrom^3), Std, N, Name, Reference , Comment +1, Unit Cell Volume @ Unknown, 568.67, 1.15, 2, , 10.1107/S0365110X60001680, generated by automatic script, add Name and double check temperature etc. diff --git a/Pyrazinamide/beta polymorph_volume.csv b/Pyrazinamide/beta polymorph_volume.csv new file mode 100644 index 0000000..bb24c6e --- /dev/null +++ b/Pyrazinamide/beta polymorph_volume.csv @@ -0,0 +1,3 @@ +PYRZIN01 +Identifier, Property , Value (Angstrom^3), Std, N, Name, Reference , Comment +1, Unit Cell Volume @ Unknown, 559.73, 0.00, 1, , 10.1107/S0567740872003589, generated by automatic script, add Name and double check temperature etc. diff --git a/Pyrazinamide/delta polymorph_volume.csv b/Pyrazinamide/delta polymorph_volume.csv new file mode 100644 index 0000000..6341730 --- /dev/null +++ b/Pyrazinamide/delta polymorph_volume.csv @@ -0,0 +1,3 @@ +PYRZIN02 +Identifier, Property , Value (Angstrom^3), Std, N, Name, Reference , Comment +1, Unit Cell Volume @ Unknown, 279.56, 0.00, 1, , 10.1107/S0567740872004856, generated by automatic script, add Name and double check temperature etc. diff --git a/Pyrazinamide/gamma polymorph_volume.csv b/Pyrazinamide/gamma polymorph_volume.csv new file mode 100644 index 0000000..7a1c65d --- /dev/null +++ b/Pyrazinamide/gamma polymorph_volume.csv @@ -0,0 +1,3 @@ +PYRZIN03 +Identifier, Property , Value (Angstrom^3), Std, N, Name, Reference , Comment +1, Unit Cell Volume @ Unknown, 277.59, 2.45, 2, , 10.1107/S0365110X61002102, generated by automatic script, add Name and double check temperature etc.