{"id":6002,"library":"mmcif-pdbx","title":"Python utilities for PDBx/mmCIF storage model","description":"mmcif-pdbx provides a pure Python interface for working with PDBx/mmCIF files, emphasizing simplicity. It allows parsing and serialization of macromolecular crystallographic information files. The library is derived from Python examples provided by the wwPDB and is currently at version 2.0.1, with releases occurring periodically to add features and address issues.","status":"active","version":"2.0.1","language":"en","source_language":"en","source_url":"https://github.com/Electrostatics/mmcif_pdbx","tags":["macromolecular","crystallography","structural biology","PDBx","mmCIF","file format","biophysics"],"install":[{"cmd":"pip install mmcif-pdbx","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"For reading mmCIF files.","symbol":"PdbxReader","correct":"from pdbx.reader import PdbxReader"},{"note":"For writing mmCIF files.","symbol":"PdbxWriter","correct":"from pdbx.writer import PdbxWriter"},{"note":"Represents a data block within an mmCIF file.","symbol":"DataContainer","correct":"from pdbx.containers import DataContainer"},{"note":"Convenience function for parsing a CIF file object.","symbol":"load","correct":"from pdbx import load"},{"note":"Convenience function for parsing a CIF string.","symbol":"loads","correct":"from pdbx import loads"},{"note":"Convenience function for writing DataContainer objects to a CIF file object.","symbol":"dump","correct":"from pdbx import dump"},{"note":"Convenience function for serializing DataContainer objects to a CIF string.","symbol":"dumps","correct":"from pdbx import dumps"}],"quickstart":{"code":"import io\nfrom pdbx import loads, dumps, DataCategory, DataContainer\n\n# Example mmCIF data as a string\nmmcif_data = '''\ndata_testblock\n_entry.id test\nloop_\n_atom_site.id\n_atom_site.type_symbol\n_atom_site.label_atom_id\n1 C CA\n2 O O\n'''\n\n# Parse the mmCIF string\ndata_containers = loads(mmcif_data)\n\n# Access data (assuming one data block)\nif data_containers:\n    data_block = data_containers[0]\n    print(f\"Data block ID: {data_block.name}\")\n\n    # Access a category\n    atom_site_category = data_block.getObj('atom_site')\n    if atom_site_category:\n        print(\"\\nAtom Site Category:\")\n        for i in range(atom_site_category.getRowCount()):\n            atom_id = atom_site_category.getValue('id', i)\n            atom_type = atom_site_category.getValue('type_symbol', i)\n            print(f\"  ID: {atom_id}, Type: {atom_type}\")\n    else:\n        print(\"Atom_site category not found.\")\n\n    # Modify data (example: add a new item to the entry category)\n    entry_category = data_block.getObj('entry')\n    if entry_category:\n        entry_category.setValue('new_item', 0, 'new_value')\n\n    # Serialize the modified data back to a string\n    modified_mmcif_data = dumps(data_containers)\n    print(\"\\nModified mmCIF data:\\n\", modified_mmcif_data)\n\nelse:\n    print(\"No data containers found.\")","lang":"python","description":"This quickstart demonstrates how to parse an mmCIF string, access data within categories, and serialize modified data back to an mmCIF string using the `loads` and `dumps` utility functions, and interacting with `DataContainer` and `DataCategory` objects."},"warnings":[{"fix":"Update code to reflect PEP8 naming conventions and the revised module structure. Consult the 1.0.0 release notes and documentation for specific changes.","message":"Version 1.0.0 introduced significant API changes, breaking compatibility with versions 0.*. These changes include PEP8-compliant class and function naming and simplification of the module structure.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Evaluate your project's performance and feature requirements. If `mmcif-pdbx`'s pure Python approach is sufficient, continue using it. If not, consider migrating to `rcsb/py-mmcif`.","message":"This `mmcif-pdbx` package provides a pure Python interface. For higher performance or more comprehensive features, especially those involving C/C++ acceleration for I/O, consider `rcsb/py-mmcif` (PyPI: `mmcif`), which is described as the 'canonical mmCIF Python package'.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}