Skip to content

Commit

Permalink
Debug some molecule issues
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewcarbone committed Nov 5, 2023
1 parent 55fee47 commit 07741b2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lightshow/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ def from_files_molecule(
for key, path in enumerate(
tqdm(Path(root).rglob(filename), disable=not pbar)
):
key = f"{key:08}"
molecule = Molecule.from_file(path)
structures[key] = molecule.get_boxed_structure(*lattice)
metadata[key] = {"origin": str(path)}
return cls(structure=structures, metadat=metadata, supercells=dict())
return cls(structures=structures, metadata=metadata, supercells=dict())

@classmethod
def from_files(cls, root, filename="CONTCAR", pbar=True):
Expand Down Expand Up @@ -103,6 +104,7 @@ def from_files(cls, root, filename="CONTCAR", pbar=True):
for key, path in enumerate(
tqdm(Path(root).rglob(filename), disable=not pbar)
):
key = f"{key:08}"
struct = Structure.from_file(path)
structures[key] = struct.get_primitive_structure()
metadata[key] = {"origin": str(path)}
Expand Down Expand Up @@ -341,9 +343,13 @@ def _write_origin_paths(self, root, pbar=False):
"""

for key, metadata in tqdm(self._metadata.items(), disable=not pbar):
if "origin" in metadata.keys():
fname = Path(root) / key / "metadata.json"
json.dump(metadata, fname, indent=4, sort_keys=True)
if "origin" not in metadata.keys():
continue
fname = Path(root) / key / "metadata.json"
origin = str(Path(metadata["origin"]).resolve())
new_metadata = {"origin": origin}
with open(fname, "w") as outfile:
json.dump(new_metadata, outfile, indent=4, sort_keys=True)

def write(
self,
Expand Down

0 comments on commit 07741b2

Please sign in to comment.