BinaryCIFColumn
#
- class biotite.structure.io.pdbx.BinaryCIFColumn(data, mask=None)[source]#
Bases:
_Component
This class represents a single column in a
CIFCategory
.- Parameters:
- dataBinaryCIFData or array_like or int or float or str
The data to be stored. If no
BinaryCIFData
is given, the passed argument is coerced into such an object.- maskBinaryCIFData or array_like, dtype=int or int
The mask to be stored. If given, the mask indicates whether the data is inapplicable (
.
) or missing (?
) in some rows. The data presence is indicated by values from theMaskValue
enum. If noBinaryCIFData
is given, the passed argument is coerced into such an object. By default, no mask is created.
Examples
>>> print(BinaryCIFColumn([1, 2, 3]).as_array()) [1 2 3] >>> mask = [MaskValue.PRESENT, MaskValue.INAPPLICABLE, MaskValue.MISSING] >>> # Mask values are only inserted into string arrays >>> print(BinaryCIFColumn([1, 2, 3], mask).as_array(int)) [1 2 3] >>> print(BinaryCIFColumn([1, 2, 3], mask).as_array(str)) ['1' '.' '?'] >>> print(BinaryCIFColumn([1]).as_item()) 1 >>> print(BinaryCIFColumn([1], mask=[MaskValue.MISSING]).as_item()) ?
- Attributes:
- dataBinaryCIFData
The stored data.
- maskBinaryCIFData
The mask that indicates whether certain data elements are inapplicable or missing. If no mask is present, this attribute is
None
.
- as_array(dtype=None, masked_value=None)#
Get the data of this column as an
ndarray
.This is a shortcut to get
BinaryCIFColumn.data.array
. Furthermore, the mask is applied to the data.- Parameters:
- dtypedtype-like, optional
The data type the array should be converted to. By default, the original type is used.
- masked_valuestr or int or float, optional
The value that should be used for masked elements, i.e.
MaskValue.INAPPLICABLE
orMaskValue.MISSING
. By default, masked elements are converted to'.'
or'?'
depending on theMaskValue
.
- as_item()#
Get the only item in the data of this column.
If the data is masked as inapplicable or missing,
'.'
or'?'
is returned, respectively. If the data contains more than one item, an exception is raised.- Returns:
- itemstr or int or float
The item in the data.
- static deserialize(content)#
Create this component by deserializing the given content.
- Parameters:
- contentstr or dict
The content to be deserialized. The type of this parameter depends on the file format. In case of CIF files, this is the text of the lines that represent this component. In case of BinaryCIF files, this is a dictionary parsed from the MessagePack data.
- serialize()#
Convert this component into a Python object that can be written to a file.
- Returns:
- contentstr or dict
The content to be serialized. The type of this return value depends on the file format. In case of CIF files, this is the text of the lines that represent this component. In case of BinaryCIF files, this is a dictionary that can be encoded into MessagePack.
- static subcomponent_class()#
Get the class of the components that are stored in this component.
- Returns:
- subcomponent_classtype
The class of the subcomponent. If this component already represents the lowest level, i.e. it does not contain subcomponents,
None
is returned.
- static supercomponent_class()#
Get the class of the component that contains this component.
- Returns:
- supercomponent_classtype
The class of the supercomponent. If this component present already the highest level, i.e. it is not contained in another component,
None
is returned.