Overview
Themmcif module provides low-level parsing operations and utilities for working with mmCIF (macromolecular Crystallographic Information File) format. It wraps C++ implementations for efficient parsing and provides Python-friendly interfaces.
Core Classes
Mmcif
Mmcif class (alias for CifDict) represents a parsed mmCIF file as an immutable dictionary-like object. It provides efficient access to mmCIF data categories and items.
Dictionary Access:
Parsing Functions
from_string
str | bytes
required
The contents of an mmCIF file as a string or bytes
parse_multi_data_cif
str
required
CIF string with multiple
data_ recordsChain and Entity Functions
get_chain_type_by_entity_id
Mmcif
required
Parsed mmCIF object
get_internal_to_author_chain_id_map
label_asym_id) to author chain IDs (auth_asym_id).
Mmcif
required
Parsed mmCIF object
Bond Parsing
get_bond_atom_indices
_struct_conn table.
Mmcif
required
Parsed mmCIF object
str
default:"'1'"
Model ID to extract bonds for (from
_atom_site.pdbx_PDB_model_num)(from_atoms, to_atoms) where each is a list of 0-based atom indices
Raises:
BondParsingError: If required tables are missing or bonds reference non-existent atoms
BondParsingError
Atom Data Functions
get_or_infer_type_symbol
Mmcif
required
Parsed mmCIF object
Ccd | None
default:"None"
Chemical Component Dictionary for inferring elements. If None, uses the cached CCD.
_atom_site.type_symbol if present. If not, infers elements from residue names and atom names using the Chemical Component Dictionary.
Example:
Metadata Functions
get_experimental_method
Mmcif
required
Parsed mmCIF object
get_resolution
Mmcif
required
Parsed mmCIF object
_refine.ls_d_res_high(X-ray refinement)_em_3d_reconstruction.resolution(EM reconstruction)_reflns.d_resolution_high(reflection data)
get_release_date
Mmcif
required
Parsed mmCIF object
Chain ID Conversion Functions
int_id_to_str_id
int
required
Positive integer (1-based)
ValueError if num <= 0
Encoding scheme:
- 1 → ‘A’
- 2 → ‘B’
- 26 → ‘Z’
- 27 → ‘AA’
- 28 → ‘BA’
- 52 → ‘ZZ’
- 53 → ‘AAA’
str_id_to_int_id
int_id_to_str_id).
str
required
String chain ID consisting only of uppercase letters A-Z
ValueError if str_id contains non-uppercase letters
Example:
Bioassembly Functions
parse_oper_expr
str
required
Operation expression string from
_pdbx_struct_assembly_gen.oper_expression1,2,3→ Apply transforms 1, 2, or 3 separately (3 copies)(1-3)→ Same as above using range notation(1-3)(4-6)→ Cartesian product: apply all pairs (1,4), (1,5), (1,6), (2,4), (2,5), (2,6), (3,4), (3,5), (3,6) (9 copies)(P)→ Apply single transform with ID ‘P’
ValueError if the expression format is unsupported
Example:
Utility Functions
format_float_array
np.ndarray
required
1D NumPy array of values to format (will be cast to float32)
int
required
Number of decimal places to include (with trailing zeros)
ValueError if array is not 1-dimensional
Note: This is optimized for performance and faster than Python list comprehensions.
Example:
Complete Example
Here’s a comprehensive example showing common mmCIF parsing operations:See Also
- Structure Class - High-level Structure interface
- Parsing Functions - Structure construction from various formats