"""Unified representation, format round-trip and reversible transformations (no database needed).""" import sys; from pathlib import Path; sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from ase.build import bulk, molecule from core.io import dumps, loads from core.representation import MatterStructure from discovery import transformations as tf ms = MatterStructure.from_ase(molecule("CH3OH")) print(ms.formula(), "electrons:", ms.n_electrons(), "bonds:", len(ms.graph()["edges"])) print("SDF round trip ok:", loads(dumps(ms, "sdf"), "sdf").content_hash() == ms.content_hash()) cu = MatterStructure.from_ase(bulk("Cu", "fcc", a=3.6, cubic=True)) print("space group:", cu.symmetry()["international"]) s = tf.substitute(cu, 0, "Au"); print("substituted:", s.formula(), "lineage:", s.lineage[-1]["operation"]) print("inverted back:", tf.invert(s).formula())