Quick Startο
Parsing an mmCIF Fileο
from sloth import MMCIFHandler
handler = MMCIFHandler()
mmcif = handler.read("1abc.cif")
# Access data with dot notation
block = mmcif.data_1ABC
print(block._struct.title[0])
print(block._atom_site.Cartn_x[0])
Selective Parsingο
Load only the categories you need:
mmcif = handler.read("1abc.cif", categories=["_atom_site", "_entity"])
Writing mmCIF Filesο
handler.write(mmcif, "output.cif")
Quick JSON Exportο
# Export to nested JSON with resolved relationships
json_str = handler.export(mmcif, indent=2)
# Export directly to file
handler.export(mmcif, file_path="output.json", indent=2)
Quick JSON Importο
# Import from JSON (automatically flattens nested structure)
mmcif = handler.load("output.json")