httk.io.cif.cif_reader

Attributes

Functions

read_cif(source[, pragmatic, allow_cif2, autocorrect, ...])

Read CIF text as (data_blocks, header).

Module Contents

httk.io.cif.cif_reader.logger[source]
httk.io.cif.cif_reader.read_cif(source, pragmatic=True, allow_cif2=False, *, autocorrect=False, structural_only=False)[source]

Read CIF text as (data_blocks, header).

Paths are opened through httk.core.TextstreamFileView, including compressed CIF files. Open streams and iterables are consumed but left open.

Parameters:
  • source (str | os.PathLike[str] | collections.abc.Iterable[str]) – A filename, open text stream, or iterable of CIF lines.

  • pragmatic (bool) – Accept selected common deviations from strict CIF tokenization.

  • allow_cif2 (bool) – Parse CIF2 list values in addition to CIF1 data.

  • autocorrect (bool) – Drop malformed auxiliary loops and warn about each repair.

  • structural_only (bool) – Retain only tags consumed by httk’s structural adapters and skip auxiliary CIF1 loops.

Returns:

The data blocks and the leading comment header.

Raises:

ValueError – If a loop contains mismatched column value counts.

Return type:

tuple[list[tuple[str, dict[str, Any]]], str]