FixedPointEncoding
#
- class biotite.structure.io.pdbx.FixedPointEncoding(factor: ..., src_type: ... = TypeCode.FLOAT32)[source]#
Bases:
Encoding
Lossy encoding that multiplies floating point values with a given factor and subsequently rounds them to the nearest integer.
- Parameters:
- factorfloat
The factor by which the data is multiplied before rounding.
- src_typedtype or TypeCode, optional
The data type of the array to be encoded. Either a NumPy dtype or a BinaryCIF type code is accepted. The dtype must be a float type. If omitted, 32-bit floats are assumed.
Examples
>>> data = np.array([9.87, 6.543]) >>> print(data) [9.870 6.543] >>> print(FixedPointEncoding(factor=100).encode(data)) [987 654]
- Attributes:
- factorfloat
- src_typeTypeCode
- decode(data)#
Apply the inverse of this encoding to the given data.
- Parameters:
- datandarray or bytes
The data to be decoded.
- Returns:
- decoded_datandarray
The decoded data.
- 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.
- src_type: ... = 32#
- 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.
Gallery#
BinaryCIF as trajectory format