{"id":4951,"library":"gemmi","title":"Gemmi","description":"Gemmi is a C++ library with comprehensive Python bindings designed for structural biology, particularly macromolecular crystallography. It provides tools for working with various file formats like mmCIF, PDB, MTZ, MRC/CCP4, and general CIF/STAR files, handling macromolecular models, refinement restraints, reflection data, and crystallographic symmetry. Currently at version 0.7.5, it is an actively developed open-source project maintained by CCP4 and Global Phasing Ltd.","status":"active","version":"0.7.5","language":"en","source_language":"en","source_url":"https://github.com/project-gemmi/gemmi","tags":["structural biology","crystallography","chemistry","data processing","PDB","mmCIF","MTZ","MRC"],"install":[{"cmd":"pip install gemmi","lang":"bash","label":"Install Python package"}],"dependencies":[],"imports":[{"symbol":"gemmi","correct":"import gemmi"},{"symbol":"Structure","correct":"import gemmi\nstructure = gemmi.read_pdb('file.pdb')"}],"quickstart":{"code":"import gemmi\nimport os\n\n# Create a dummy PDB file for demonstration\npdb_content = \"\"\"\nATOM      1  N   ALA A   1      29.186  15.021  19.530  1.00 19.34           N\nATOM      2  CA  ALA A   1      28.710  16.299  19.988  1.00 18.23           C\nATOM      3  C   ALA A   1      27.241  16.353  20.306  1.00 17.51           C\nATOM      4  O   ALA A   1      26.702  17.433  20.370  1.00 18.00           O\nATOM      5  CB  ALA A   1      29.417  17.309  19.066  1.00 20.00           C\nTER\n\"\"\"\nwith open(\"test.pdb\", \"w\") as f:\n    f.write(pdb_content)\n\n# Load the PDB file\ndoc = gemmi.read_file(\"test.pdb\")\n\n# Access components of the structure\nmodel = doc.models[0]\nchain = model.chains[0]\nresidue = chain.residues[0]\n\nprint(f\"File contains {len(doc.models)} model(s).\")\nprint(f\"First model has {len(model.chains)} chain(s).\")\nprint(f\"First chain has {len(chain.residues)} residue(s).\")\nprint(f\"First residue is {residue.name} {residue.seqid.num} and has {len(residue.atoms)} atoms.\")\n\n# Clean up the dummy file\nos.remove(\"test.pdb\")","lang":"python","description":"This quickstart demonstrates how to load a PDB file using `gemmi.read_file()` and access basic structural elements like models, chains, residues, and atoms. It creates a dummy PDB file for a self-contained, runnable example."},"warnings":[{"fix":"Review your code for any direct interactions with the binding layer or custom C++ extensions. Recompile any custom extensions using nanobind or the latest Gemmi build system. Primarily affects advanced users and developers of Gemmi extensions.","message":"Gemmi 0.7+ migrated its Python bindings from pybind11 to nanobind. This is a significant change that may break compatibility for users who were previously interacting with the C++ library at a lower level or had custom extensions built against pybind11. Expect internal API changes related to the binding mechanism.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Carefully review any code dealing with crystallographic symmetry operations and `Op` parsing. Explicitly specify the notation kind if ambiguities arise or adapt code to the new consistent behavior.","message":"The behavior of `gemmi.Op` parsing (specifically `parse_triplet(\"h,k,l\")` versus `parse_triplet(\"x,y,z\")`) changed in Gemmi 0.7 to align with `cctbx` and `Pointless` conventions. This affects how crystallographic symmetry operations are interpreted and stored.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Update your code to use the new method names. For `UnitCell` matrices, use `unit_cell.frac.mat` and `unit_cell.orth.mat`. For hydrogen site counting, use `residue.has_hydrogen()` or similar atom-level checks.","message":"Several functions have been deprecated and subsequently removed in Gemmi 0.7+. Notable examples include `UnitCell.fractionalization_matrix` and `UnitCell.orthogonalization_matrix`, which should now be accessed via `frac.mat` and `orth.mat` respectively. `count_hydrogen_sites()` has also been removed, with `has_hydrogen()` as its replacement.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Refer to the main Gemmi documentation (typically the overview and installation sections) or the project's GitHub repository for the most up-to-date information and examples. Use the search box on the main documentation site.","message":"The Python API documentation on `gemmi.readthedocs.io/en/latest/` has not been updated since Gemmi 0.6.7 due to the migration to nanobind. It is currently outdated and may not reflect the latest API changes or available functions in versions 0.7 and newer.","severity":"gotcha","affected_versions":">=0.7.0"},{"fix":"Ensure you `pip install gemmi` for the Python library and its bindings. If you need the standalone command-line tools, install `gemmi-program`.","message":"There are two distinct packages: `gemmi` (the Python extension module) and `gemmi-program` (the command-line executable). Users sometimes confuse them or install the wrong one expecting the other's functionality.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}