Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct = Structure.from_dict(entry["structure"]) # Pymatgen structure KeyError: 'structure' #44

Open
xiaowangfeng opened this issue May 26, 2024 · 0 comments

Comments

@xiaowangfeng
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant