httk.io.cif

Submodules

Functions

asus_from_cif_file(fs)

single_asu_from_cif_file(fs)

read_cif(fs[, pragmatic, allow_cif2, use_types])

Generic cif reader, given a filename / ioadapter it places all data in a python dictionary.

cif_to_struct(fs, *[, separate_noneq_atoms, tol])

Read a CIF file, expand the asymmetric unit, and return the result.

mag_asus_from_mcif_file(fs, *[, error_on_nonmag])

single_mag_asu_from_mcif_file(fs, *[, error_on_nonmag])

Package Contents

httk.io.cif.asus_from_cif_file(fs)[source]
httk.io.cif.single_asu_from_cif_file(fs)[source]
httk.io.cif.read_cif(fs, pragmatic=True, allow_cif2=False, use_types=False)[source]

Generic cif reader, given a filename / ioadapter it places all data in a python dictionary.

It returns a tuple: (header, list) Where list are pairs of data blocks names and data blocks

Each data block is a dictionary with tag_name:value

For loops, value is another dictionary with format column_name:value

The optional parameter pragmatic regulates handling of some counter-intuitive aspects of the cif specification, where the default pragmatic=True handles these features the way people usually use them, whereas pragmatic=False means to read the cif file precisely according to the spec. For example, in a multiline text field:

;
some text
;

Means the string ‘nsome text’. For this specific case pragmatic=True removes the leading newline.

set use_types to True to convert things that look like floats and integers to those respective types

A filename (str or os.PathLike) is opened through httk.core.TextstreamFileView, so a compressed file (.cif.bz2, .cif.gz, …) is decompressed transparently. An already-open text stream or a plain iterable of lines is consumed as-is and left open for the caller.

httk.io.cif.cif_to_struct(fs, *, separate_noneq_atoms=False, tol=1e-06)[source]

Read a CIF file, expand the asymmetric unit, and return the result.

fs is a filename or file-like object (anything accepted by the read_cif layer). When separate_noneq_atoms is true, unique numbers are assigned by CIF label (even for the same element); otherwise numbers are assigned by element symbol. tol controls the expansion consistency tolerance. Returns a dict with the expanded structure data.

httk.io.cif.mag_asus_from_mcif_file(fs, *, error_on_nonmag=False)[source]
httk.io.cif.single_mag_asu_from_mcif_file(fs, *, error_on_nonmag=False)[source]