public class MSNumpress extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ACC_NUMPRESS_LINEAR |
static String |
ACC_NUMPRESS_PIC |
static String |
ACC_NUMPRESS_SLOF |
Constructor and Description |
---|
MSNumpress() |
Modifier and Type | Method and Description |
---|---|
static Double[] |
decode(String cvAccession,
byte[] data)
Convenience function for decoding binary data encoded by MSNumpress.
|
static double |
decodeFixedPoint(byte[] data)
Decode fixed point.
|
static int |
decodeLinear(byte[] data,
int dataSize,
Double[] result)
Decodes data encoded by encodeLinear.
|
static int |
decodePic(byte[] data,
int dataSize,
Double[] result)
Decodes data encoded by encodePic
Result vector guaranteedly shorter than twice the data length (in nbr of
values).
|
static int |
decodeSlof(byte[] data,
int dataSize,
Double[] result)
Decodes data encoded by encodeSlof.
|
static byte[] |
encode(double[] data,
String cvAccession)
Encode.
|
static void |
encodeFixedPoint(double fixedPoint,
byte[] result)
Encode fixed point.
|
static int |
encodeInt(long x,
byte[] res,
int resOffset)
This encoding works on a 4 byte integer, by truncating initial zeros or
ones.
|
static int |
encodeLinear(double[] data,
int dataSize,
byte[] result,
double fixedPoint)
Encodes the doubles in data by first using a - lossy conversion to a 4
byte 5 decimal fixed point repressentation - storing the residuals from a
linear prediction after first to values - encoding by encodeInt (see
above)
The resulting binary is maximally dataSize * 5 bytes, but much less if
the data is reasonably smooth on the first order.
|
static int |
encodePic(double[] data,
int dataSize,
byte[] result)
Encodes ion counts by simply rounding to the nearest 4 byte integer, and
compressing each integer with encodeInt.
|
static int |
encodeSlof(double[] data,
int dataSize,
byte[] result,
double fixedPoint)
Encodes ion counts by taking the natural logarithm, and storing a fixed
point representation of this.
|
static double |
optimalLinearFixedPoint(double[] data,
int dataSize)
Optimal linear fixed point.
|
static double |
optimalSlofFixedPoint(double[] data,
int dataSize)
Optimal slof fixed point.
|
public static final String ACC_NUMPRESS_LINEAR
public static final String ACC_NUMPRESS_PIC
public static final String ACC_NUMPRESS_SLOF
public static byte[] encode(double[] data, String cvAccession)
data
- the datacvAccession
- the accession numberpublic static Double[] decode(String cvAccession, byte[] data)
cvAccession
- The PSI-MS obo CV accession of the encoded data.data
- array of double to be encodedpublic static int encodeInt(long x, byte[] res, int resOffset)
x
- the int to be encodedres
- the byte array were halfbytes are storedresOffset
- position in res were halfbytes are writtenpublic static void encodeFixedPoint(double fixedPoint, byte[] result)
fixedPoint
- the fixed pointresult
- the encoded resultpublic static double decodeFixedPoint(byte[] data)
data
- the datapublic static double optimalLinearFixedPoint(double[] data, int dataSize)
data
- the datadataSize
- the data sizepublic static int encodeLinear(double[] data, int dataSize, byte[] result, double fixedPoint)
data
- array of double to be encodeddataSize
- number of doubles from data to encoderesult
- array were resulting bytes should be storedfixedPoint
- the scaling factor used for getting the fixed point
repr. This is stored in the binary and automatically extracted on
decoding.public static int decodeLinear(byte[] data, int dataSize, Double[] result)
data
- array of bytes to be decodeddataSize
- number of bytes from data to decoderesult
- array were resulting doubles should be storedpublic static int encodePic(double[] data, int dataSize, byte[] result)
data
- array of doubles to be encodeddataSize
- number of doubles from data to encoderesult
- array were resulting bytes should be storedpublic static int decodePic(byte[] data, int dataSize, Double[] result)
data
- array of bytes to be decoded (need memorycont. repr.)dataSize
- number of bytes from data to decoderesult
- array were resulting doubles should be storedpublic static double optimalSlofFixedPoint(double[] data, int dataSize)
data
- the datadataSize
- the data sizepublic static int encodeSlof(double[] data, int dataSize, byte[] result, double fixedPoint)
data
- array of doubles to be encodeddataSize
- number of doubles from data to encoderesult
- array were resulting bytes should be storedfixedPoint
- the scaling factor used for getting the fixed point
repr. This is stored in the binary and automatically extracted on
decoding.public static int decodeSlof(byte[] data, int dataSize, Double[] result)
data
- array of bytes to be decoded (need memorycont. repr.)dataSize
- number of bytes from data to decoderesult
- array were resulting doubles should be storedCopyright © 2021. All rights reserved.