cgcnn
cgcnn copied to clipboard
struct = Structure.from_dict(entry["structure"]) # Pymatgen structure KeyError: 'structure'
when i want to run make_cifs.py it will have the errors. how to solve it import os import json from pymatgen.core import Structure
------Settings------#
struct_json_path = "qmof.json" # path to structure json cif_folder_path = "qmof_cif" # path to folder where CIFs will be stored write_site_props = True # if site properties should be written to CIF only_ddec_charge = False # set to True if you only want _atom_site_charge flags
------Settings------#
Make new folder to store CIFs
if not os.path.exists(cif_folder_path): os.mkdir(cif_folder_path)
Read in structure data
with open("E:\GANN-main\qmof_database\qmof.json") as f: qmof_struct_data = json.load(f)
Loop over structures and write each one out to a CIF
qmof_structs = {} for entry in qmof_struct_data:
qmof_id = entry["qmof_id"] # name for CIF
print(f"Writing {qmof_id}")
struct = Structure.from_dict(entry["structure"]) # Pymatgen structure
cif_path = os.path.join(cif_folder_path, f"{qmof_id}.cif") # path to write CIF
struct.to(filename=cif_path) # write CIF
properties = dict(sorted(struct.site_properties.items())) # fetch site properties