neurosnap.io.mmcif module#
Parser and writer for mmCIF coordinate files.
This module provides Neurosnap-native parse_mmcif() and
save_cif() helpers for reading and writing
Structure,
StructureEnsemble, and
StructureStack objects.
Parsing follows the atom-site driven mmCIF loop structure while building Neurosnap structures directly in an array-oriented form.
- neurosnap.io.mmcif.parse_mmcif(mmcif, return_type='auto')[source]#
Parse an mmCIF file into Neurosnap structure containers.
The parser reads the
_atom_siteloop directly, using author-provided chain IDs and residue numbering when available and falling back to label identifiers otherwise. Parsed models are first collected into aStructureEnsembleand are optionally converted into aStructureStackat the end.Alternate locations are always ignored. When alternate locations are present, the parser keeps only the highest-occupancy conformer for each atom site and emits a
logger.warning()so the user knows this happened.Unlike
neurosnap.io.pdb.parse_pdb(), this first mmCIF implementation does not currently parse explicit bond tables such as_struct_conn. Parsed structures therefore keep full atom annotations but default to an empty bond list unless bonds are added later by other code.- Parameters:
mmcif (
Union[str,Path,IOBase]) – mmCIF filepath or open file handle.return_type (
Literal['ensemble','stack','auto']) – Output container type."ensemble"always returns aStructureEnsemble,"stack"requires stack-compatible models, and"auto"returns aStructureStackwhen possible or falls back to aStructureEnsemble.
- Return type:
Union[StructureEnsemble,StructureStack]- Returns:
A
StructureEnsembleorStructureStackdepending onreturn_typeand model compatibility.
- neurosnap.io.mmcif.save_cif(structure, cif)[source]#
Save a Neurosnap structure container as an mmCIF file.
- Parameters:
structure (
Union[Structure,StructureEnsemble,StructureStack]) – Structure container to write.cif (
Union[str,Path,IOBase]) – Output filepath or open file handle.
Notes
The writer emits a compact
_atom_siteloop that round-trips throughparse_mmcif(). Multi-model outputs are represented using the_atom_site.pdbx_PDB_model_numcolumn. This initial writer does not yet export bond tables such as_struct_conn.