IntegerPackingEncoding
#
- class biotite.structure.io.pdbx.IntegerPackingEncoding(byte_count: ..., src_size: ... = None, is_unsigned: ... = None)[source]#
Bases:
Encoding
Encoding that compresses an array of 32-bit integers into an array of smaller sized integers.
If a value does not fit into smaller integer type, the integer is represented by a sum of consecutive elements in the compressed array.
- Parameters:
- byte_countint
The number of bytes the packed integers should occupy. Supported values are 1 and 2 for 8-bit and 16-bit integers, respectively.
- src_sizeint, optional
The size of the array to be encoded. If omitted, the size is determined from the data the first time
encode()
is called.- is_unsignedbool, optional
Whether the values should be packed into signed or unsigned integers. If omitted, first time
encode()
is called, determines whether the values fit into unsigned integers.
Examples
>>> data = np.array([1, 2, -3, 128]) >>> print(data) [ 1 2 -3 128] >>> print(IntegerPackingEncoding(byte_count=1).encode(data)) [ 1 2 -3 127 1]
- Attributes:
- byte_countint
- src_sizeint
- is_unsignedbool
- decode#
- classmethod 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.
- encode(data)#
Apply this encoding to the given data.
- Parameters:
- datandarray
The data to be encoded.
- Returns:
- encoded_datandarray or bytes
The encoded 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.