| | |
The MassDataCborMassSpectrumHandler class provides features to handle mass spectrum data using the CBOR (Concise Binary Object Representation) container streaming classes. More...
| Header: | #include <MassDataCborMassSpectrumHandler.hpp> |
| Inherits: | MsXpS::libXpertMassCore::MassDataCborBaseHandler |
| MassDataCborMassSpectrumHandler(QObject *parent_p) | |
| MassDataCborMassSpectrumHandler(QObject *parent_p, const pappso::Trace &trace) | |
| virtual | ~MassDataCborMassSpectrumHandler() |
| void | clearTrace() |
| pappso::Trace | getTrace() const |
| QByteArray | getTraceColor() const |
| QString | getXLabel() const |
| QString | getYLabel() const |
| void | setTrace(const pappso::Trace &trace) |
| void | setTraceColor(const QByteArray &color_byte_array) |
| void | setXLabel(const QString &label) |
| void | setYLabel(const QString &label) |
| virtual bool | readByteArray(const QByteArray &byte_array) override |
| virtual bool | readFile(const QString &input_file_name = QString()) override |
| virtual void | writeByteArray(QByteArray &byte_array) override |
| virtual bool | writeFile(const QString &output_file_name = QString()) override |
| virtual bool | decodeStream(MsXpS::libXpertMassCore::QCborStreamReaderSPtr &reader_sp) override |
The data transported using CBOR is first qualified using the Enums::MassDataType::MASS_SPECTRUM value. The data are packed following that mass data type specification.
The format for this kind of CBOR mass spectrum data is the following:
The whole file is actually a map that contains the key/value pairs below.
All the text string values below are described in this way in the CBOR Qt implementation specification: "Major type 3: a text string, specifically a string of Unicode characters that is encoded as UTF-8 (that is, not a QByteArray, but a QString)".
The containers, map, strings and byte arrays dot not need the reader's next() call.
The simple value, like integers, do need the reader's next() call.
In this format, the whole data set in the CBOR container is a map with the following key/value pairs:
start_map
end_map
All the data above fully qualify a mass spectrum in order to display it as a trace (that is, a graph) in a mass spectrometric data visualization/exploration program like MineXpert, from http://www.msxpertsuite.org/.
Constructs a MassDataCborMassSpectrumHandler instance setting parent to parent_p.
Constructs a MassDataCborMassSpectrumHandler instance initializing the member trace to trace and setting parent to parent_p.
Note: The trace is considered the mass spectrum data to be streamed to a file as a CBOR container.
[virtual noexcept] MassDataCborMassSpectrumHandler::~MassDataCborMassSpectrumHandler()Destructs the MassDataCborMassSpectrumHandler instance.
Clears the mass spectrum data.
[override virtual protected] bool MassDataCborMassSpectrumHandler::decodeStream(MsXpS::libXpertMassCore::QCborStreamReaderSPtr &reader_sp)Reimplements: MassDataCborBaseHandler::decodeStream(MsXpS::libXpertMassCore::QCborStreamReaderSPtr &reader_sp).
Decodes the data stream from reader_sp.
The CBOR container consists in a succession of map key/value pairs. The very first key/value pair is "DATA_TYPE"/Enums::MassDataType::MASS_SPECTRUM. The following key/value pairs contain data like the title of the mass spectrum, the color for tracing the mass spectrum, the x (m/z) data and the y (intensity) data. See the class documentation for details.
Data decoded from the reader_sp stream are set to member data for later consumption.
Returns true if the decoding was successful, false otherwise.
See also writeFile().
Returns the mass spectrum data.
Returns the color with which the mass spectrum data must be displayed.
Returns the abscissae label for the mass spectrum data.
Returns the ordinates label for the mass spectrum data.
[override virtual] bool MassDataCborMassSpectrumHandler::readByteArray(const QByteArray &byte_array)Reimplements: MassDataCborBaseHandler::readByteArray(const QByteArray &byte_array).
Reads data from the byte array byte_array.
The data in byte_array are packed in a CBOR container. These data have typically travelled over the network and the receiving end needs to unpack the data in that byte_array. This is what this function does.
The data unpacked from byte_array are stored in this object member variables for later consumption by the user of this function.
A CBOR stream reader is allocated and set to decode byte_array. The actual decoding occurs in decodeStream().
Returns true if the operations was successful, false otherwise.
[override virtual] bool MassDataCborMassSpectrumHandler::readFile(const QString &input_file_name = QString())Reimplements: MassDataCborBaseHandler::readFile(const QString &input_file_name).
Reads the data in file input_file_name by decoding the data stream read from it. This function first decodes the data in the CBOR container stored in the file. Then it decodes the Base64-encoded x and y axis data into the member pappso::Trace object.
Returns true if the operation was successful, false, otherwise.
See also decodeStream() and readByteArray().
Sets the mass spectrum data to trace.
Sets the color with which the mass spectrum data must be displayed. The color i encoded as the color_byte_array byte array.
Sets the abscissae label for the mass spectrum data.
Sets the ordinates label for the mass spectrum data.
[override virtual] void MassDataCborMassSpectrumHandler::writeByteArray(QByteArray &byte_array)Reimplements: MassDataCborBaseHandler::writeByteArray(QByteArray &byte_array).
Writes member data to byte array byte_array.
Note: The member data are packed in a CBOR container and streamed to the byte array as a set of key/value pairs that form the CBOR map being streamed to the byte array.
[override virtual] bool MassDataCborMassSpectrumHandler::writeFile(const QString &output_file_name = QString())Reimplements: MassDataCborBaseHandler::writeFile(const QString &output_file_name).
Writes member data to file output_file_name.
Note: The member data are packed in a CBOR container and streamed to the file as a set of key/value pairs that form the CBOR map being streamed to the file.
Returns true if the operation was successful, false, otherwise.