Source code for boltz_data.cif._read

from pathlib import Path

import gemmi
from smart_open import open as smart_open  # type: ignore[import-untyped]


[docs] def read_single_cif_from_file(path: str | Path, /) -> gemmi.cif.Block: """ Read a CIF file containing a single data block. Supports local files, URLs, and cloud storage paths via smart_open. Args: path: Path or URL to the CIF file. Returns: The single CIF block from the file. Raises: ValueError: If the file contains multiple blocks. """ with smart_open(str(path), "r") as f: document = gemmi.cif.read_string(f.read()) return document.sole_block()
[docs] def read_cif_from_file(path: str | Path, /) -> gemmi.cif.Document: """ Read a CIF file containing multiple data blocks. Supports local files, URLs, and cloud storage paths via smart_open. Args: path: Path or URL to the CIF file. Returns: A CIF document containing all blocks from the file. """ with smart_open(str(path), "r") as f: return gemmi.cif.read_string(f.read())