Module: MmtfUtils

mmtf utils module.

Methods


<static> decodeDelta(dataArray)

perform delta decoding of the input array by iterativly adding the ith element's value to the i+1th example: dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ] return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]
Parameters:
Name Type Description
dataArray TypedArray | Array delta encoded input array
Returns:
decoded array
Type
TypedArray | Array

<static> decodeFloatRunLength(array, divisor, dataArray)

perform run-length decoding followed (@see decodeRunLength) by decoding integers into floats using given divisor (@see decodeIntegerToFloat) example: array: [ 320, 3, 100, 2 ] divisor: 100 return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]
Parameters:
Name Type Description
array Uint8Array run-length encoded int32 array as bytes in big endian format
divisor Integer number to devide the integers to obtain floats
dataArray Float32Array pre-allocated output array
Returns:
decoded array
Type
Float32Array

<static> decodeFloatSplitListDelta(bigArray, smallArray, divisor, dataArray)

perform split-list delta decoding followed (@see decodeSplitListDelta) by decoding integers into floats using given divisor (@see decodeIntegerToFloat) example: bigArray: [ 100, 3, -200, 2 ] smallArray: [ 0, 2, -1, -3, 5 ] divisor: 100 return: [ 1.00, 1.00, 1.02, 1.01, -0.99, -1.02, -0.97 ]
Parameters:
Name Type Description
bigArray Uint8Array int32 array as bytes in big endian format, pairs of large delta values and number of following small delta values to be read from smallArray
smallArray Uint8Array int16 array as bytes in big endian format, small delta values
divisor Integer number to devide the integers to obtain floats
dataArray Float32Array pre-allocated output array
Returns:
decoded array
Type
Float32Array

<static> decodeIntegerToFloat(intArray, divisor, dataArray)

decode integers into floats using given divisor example: intArray: [ 12, 34, 543, 687, 2, 0, 4689 ] divisor: 100 return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]
Parameters:
Name Type Argument Description
intArray TypedArray | Array input array containing integers
divisor Number number to devide the integers to obtain floats
dataArray Float32Array <optional>
pre-allocated output array
Returns:
decoded array
Type
Float32Array

<static> decodeRunLength(array, dataArray)

perform run-length decoding of input array example: array: [ 0, 2, 3, 5 ] // pairs of values and length of a run return: [ 0, 0, 3, 3, 3, 3, 3 ]
Parameters:
Name Type Argument Description
array TypedArray | Array run-length encoded input array
dataArray TypedArray | Array <optional>
pre-allocated output array
Returns:
decoded array
Type
TypedArray | Array

<static> decodeSplitListDelta(bigArray, smallArray, dataArray)

perform split-list delta decoding i.e. the delta values are split between two lists example: bigArray: [ 200, 3, 100, 2 ] smallArray: [ 0, 2, -1, -3, 5 ] return: [ 200, 200, 202, 201, 301, 298, 303 ]
Parameters:
Name Type Description
bigArray Uint8Array int32 array as bytes in big endian format, pairs of large delta values and number of following small delta values to be read from smallArray
smallArray Uint8Array int16 array as bytes in big endian format, small delta values
dataArray Int32Array pre-allocated output array
Returns:
decoded array
Type
Int32Array

<static> getInt8View(dataArray)

get an Int8Array view on the input array memory
Parameters:
Name Type Description
dataArray TypedArray input array
Returns:
new view on the input array memory
Type
Int8Array

<static> getInt16(view, dataArray)

get an Int16Array copy of the the input array data
Parameters:
Name Type Argument Description
view TypedArray input data in big endian format
dataArray Int16Array <optional>
pre-allocated output array
Returns:
copy of the input array data
Type
Int16Array

<static> getInt32(view, dataArray)

get an Int32Array copy of the the input array data
Parameters:
Name Type Argument Description
view TypedArray input data in big endian format
dataArray Int32Array <optional>
pre-allocated output array
Returns:
copy of the input array data
Type
Int32Array

<static> getInt32View(dataArray)

get an Int32Array view on the input array memory
Parameters:
Name Type Description
dataArray TypedArray input array
Returns:
new view on the input array memory
Type
Int32Array

<static> getUint8View(dataArray)

get an Uint8Array view on the input array memory
Parameters:
Name Type Description
dataArray TypedArray input array
Returns:
new view on the input array memory
Type
Uint8Array

<static> makeInt16Buffer(array)

make big endian buffer of an int16 array
Parameters:
Name Type Description
array Array | TypedArray array of int16 values
Returns:
big endian buffer
Type
ArrayBuffer

<static> makeInt32Buffer(array)

make big endian buffer of an int32 array
Parameters:
Name Type Description
array Array | TypedArray array of int32 values
Returns:
big endian buffer
Type
ArrayBuffer