set_structure#

biotite.structure.io.pdbx.set_structure(pdbx_file: CIFFile | CIFBlock | BinaryCIFFile | BinaryCIFBlock, array: AtomArray[N] | AtomArrayStack[M, N] | Iterable[AtomArray[N]], data_block: str | None = None, extra_fields: Iterable[str] = []) → None[source]#

Set the atom_site category with atom information from an AtomArray or AtomArrayStack.

This will save the coordinates, the mandatory annotation categories and the optional annotation categories b_factor, occupancy, charge and entity_id. If the atom array (stack) contains the annotation 'atom_id', these values will be used for atom numbering instead of continuous numbering. Furthermore, inter-residue bonds will be written into the struct_conn category.

Parameters:
pdbx_fileCIFFile or CIFBlock or BinaryCIFFile or BinaryCIFBlock

The file object.

arrayAtomArray or AtomArrayStack or iterable of AtomArray

The structure to be written. If a stack or an iterable of AtomArray is given, multiple models will be written.

data_blockstr, optional

The name of the data block. Default is the first (and most times only) data block of the file. If the data block object is passed directly to pdbx_file, this parameter is ignored. If the file is empty, a new data block will be created.

extra_fieldslist of str, optional

List of additional fields from the atom_site category that should be written into the file. Default is an empty list.

Notes

In some cases, the written inter-residue bonds cannot be read again due to ambiguity to which atoms the bond refers. This is the case, when two equal residues in the same chain have the same (or a masked) res_id.

Examples

>>> import os.path
>>> file = CIFFile()
>>> set_structure(file, atom_array)
>>> file.write(os.path.join(path_to_directory, "structure.cif"))