CIFColumn
#
- class biotite.structure.io.pdbx.CIFColumn(data, mask=None)[source]#
Bases:
object
This class represents a single column in a
CIFCategory
.- Parameters:
- dataCIFData or array_like or int or float or str
The data to be stored. If no
CIFData
is given, the passed argument is coerced into such an object.- maskCIFData 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 noCIFData
is given, the passed argument is coerced into such an object. By default, no mask is created.
Examples
>>> print(CIFColumn([1, 2, 3]).as_array()) ['1' '2' '3'] >>> mask = [MaskValue.PRESENT, MaskValue.INAPPLICABLE, MaskValue.MISSING] >>> print(CIFColumn([1, 2, 3], mask).as_array()) ['1' '.' '?'] >>> print(CIFColumn([1]).as_item()) 1 >>> print(CIFColumn([1], mask=[MaskValue.MISSING]).as_item()) ?
- Attributes:
- dataCIFData
The stored data.
- maskCIFData
The mask that indicates whether certain data elements are inapplicable or missing. If no mask is present, this attribute is
None
.
- as_array(dtype=<class 'str'>, masked_value=None)#
Get the data of this column as an
ndarray
.This is a shortcut to get
CIFColumn.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, a string type is used.
- masked_valuestr, 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
The item in the data.
- static subcomponent_class()#
- static supercomponent_class()#