OpenMS
MzXMLHandler Class Reference

#include <OpenMS/FORMAT/HANDLERS/MzXMLHandler.h>

Inheritance diagram for MzXMLHandler:
[legend]
Collaboration diagram for MzXMLHandler:
[legend]

Classes

struct  SpectrumData
 Data necessary to generate a single spectrum. More...
 

Constructors and destructor

typedef MapType::PeakType PeakType
 Peak type. More...
 
typedef MSSpectrum SpectrumType
 Spectrum type. More...
 
MapTypeexp_
 map pointer for reading More...
 
const MapTypecexp_
 map pointer for writing More...
 
PeakFileOptions options_
 Options for loading and storing. More...
 
 MzXMLHandler (MapType &exp, const String &filename, const String &version, ProgressLogger &logger)
 Constructor for a read-only handler. More...
 
 MzXMLHandler (const MapType &exp, const String &filename, const String &version, const ProgressLogger &logger)
 Constructor for a write-only handler. More...
 
 ~MzXMLHandler () override
 Destructor. More...
 
LOADDETAIL getLoadDetail () const override
 handler which support partial loading, implement this method More...
 
void setLoadDetail (const LOADDETAIL d) override
 handler which support partial loading, implement this method More...
 
void endElement (const XMLCh *const uri, const XMLCh *const local_name, const XMLCh *const qname) override
 
void startElement (const XMLCh *const uri, const XMLCh *const local_name, const XMLCh *const qname, const xercesc::Attributes &attributes) override
 
void characters (const XMLCh *const chars, const XMLSize_t length) override
 
void writeTo (std::ostream &os) override
 Write the contents to a stream. More...
 
void setOptions (const PeakFileOptions &options)
 Sets the options. More...
 
UInt getScanCount () const
 Gets the scan count. More...
 
void setMSDataConsumer (Interfaces::IMSDataConsumer *consumer)
 Set the IMSDataConsumer consumer which will consume the read data. More...
 

temporary data structures to hold parsed data

Int nesting_level_
 
std::vector< SpectrumDataspectrum_data_
 Vector of spectrum data stored for later parallel processing. More...
 
bool skip_spectrum_
 Flag that indicates whether this spectrum should be skipped (due to options) More...
 
UInt spec_write_counter_
 spectrum counter (spectra without peaks are not written) More...
 
Interfaces::IMSDataConsumerconsumer_
 Consumer class to work on spectra. More...
 
UInt scan_count_
 Consumer class to work on spectra. More...
 
const ProgressLoggerlogger_
 Progress logging class. More...
 
std::vector< boost::shared_ptr< DataProcessing > > data_processing_
 data processing auxiliary variable More...
 
bool writeAttributeIfExists_ (std::ostream &os, const MetaInfoInterface &meta, const String &metakey, const String &attname)
 
void writeUserParam_ (std::ostream &os, const MetaInfoInterface &meta, int indent=4, const String &tag="nameValue")
 write metaInfo to xml (usually in nameValue-tag) More...
 
void doPopulateSpectraWithData_ (SpectrumData &spectrum_data)
 Fill a single spectrum with data from input. More...
 
void populateSpectraWithData_ ()
 Populate all spectra on the stack with data from input. More...
 
 MzXMLHandler ()
 Not implemented. More...
 
void init_ ()
 initialize members (call from C'tor) More...
 

Additional Inherited Members

- Public Types inherited from XMLHandler
enum  ActionMode { LOAD , STORE }
 Action to set the current mode (for error messages) More...
 
enum  LOADDETAIL { LD_ALLDATA , LD_RAWCOUNTS , LD_COUNTS_WITHOPTIONS }
 
- Public Member Functions inherited from XMLHandler
 XMLHandler (const String &filename, const String &version)
 Default constructor. More...
 
 ~XMLHandler () override
 Destructor. More...
 
void reset ()
 Release internal memory used for parsing (call. More...
 
void fatalError (const xercesc::SAXParseException &exception) override
 
void error (const xercesc::SAXParseException &exception) override
 
void warning (const xercesc::SAXParseException &exception) override
 
void fatalError (ActionMode mode, const String &msg, UInt line=0, UInt column=0) const
 Fatal error handler. Throws a ParseError exception. More...
 
void error (ActionMode mode, const String &msg, UInt line=0, UInt column=0) const
 Error handler for recoverable errors. More...
 
void warning (ActionMode mode, const String &msg, UInt line=0, UInt column=0) const
 Warning handler. More...
 
void characters (const XMLCh *const chars, const XMLSize_t length) override
 Parsing method for character data. More...
 
void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const xercesc::Attributes &attrs) override
 Parsing method for opening tags. More...
 
void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname) override
 Parsing method for closing tags. More...
 
String errorString ()
 Returns the last error description. More...
 
void checkUniqueIdentifiers_ (const std::vector< ProteinIdentification > &prot_ids) const
 
- Static Public Member Functions inherited from XMLHandler
static String writeXMLEscape (const String &to_escape)
 Escapes a string and returns the escaped string. More...
 
static DataValue fromXSDString (const String &type, const String &value)
 Convert an XSD type (e.g. 'xsd:double') to a DataValue. More...
 
- Protected Member Functions inherited from XMLHandler
void writeUserParam_ (const String &tag_name, std::ostream &os, const MetaInfoInterface &meta, UInt indent) const
 Writes the content of MetaInfoInterface to the file. More...
 
Int asInt_ (const String &in) const
 Conversion of a String to an integer value. More...
 
Int asInt_ (const XMLCh *in) const
 Conversion of a Xerces string to an integer value. More...
 
UInt asUInt_ (const String &in) const
 Conversion of a String to an unsigned integer value. More...
 
double asDouble_ (const String &in) const
 Conversion of a String to a double value. More...
 
float asFloat_ (const String &in) const
 Conversion of a String to a float value. More...
 
bool asBool_ (const String &in) const
 Conversion of a string to a boolean value. More...
 
DateTime asDateTime_ (String date_string) const
 Conversion of a xs:datetime string to a DateTime value. More...
 
bool equal_ (const XMLCh *a, const XMLCh *b) const
 Returns if two Xerces strings are equal. More...
 
SignedSize cvStringToEnum_ (const Size section, const String &term, const char *message, const SignedSize result_on_error=0)
 
String attributeAsString_ (const xercesc::Attributes &a, const char *name) const
 Converts an attribute to a String. More...
 
Int attributeAsInt_ (const xercesc::Attributes &a, const char *name) const
 Converts an attribute to a Int. More...
 
double attributeAsDouble_ (const xercesc::Attributes &a, const char *name) const
 Converts an attribute to a double. More...
 
DoubleList attributeAsDoubleList_ (const xercesc::Attributes &a, const char *name) const
 Converts an attribute to a DoubleList. More...
 
IntList attributeAsIntList_ (const xercesc::Attributes &a, const char *name) const
 Converts an attribute to an IntList. More...
 
StringList attributeAsStringList_ (const xercesc::Attributes &a, const char *name) const
 Converts an attribute to an StringList. More...
 
bool optionalAttributeAsString_ (String &value, const xercesc::Attributes &a, const char *name) const
 Assigns the attribute content to the String value if the attribute is present. More...
 
bool optionalAttributeAsInt_ (Int &value, const xercesc::Attributes &a, const char *name) const
 Assigns the attribute content to the Int value if the attribute is present. More...
 
bool optionalAttributeAsUInt_ (UInt &value, const xercesc::Attributes &a, const char *name) const
 Assigns the attribute content to the UInt value if the attribute is present. More...
 
bool optionalAttributeAsDouble_ (double &value, const xercesc::Attributes &a, const char *name) const
 Assigns the attribute content to the double value if the attribute is present. More...
 
bool optionalAttributeAsDoubleList_ (DoubleList &value, const xercesc::Attributes &a, const char *name) const
 Assigns the attribute content to the DoubleList value if the attribute is present. More...
 
bool optionalAttributeAsStringList_ (StringList &value, const xercesc::Attributes &a, const char *name) const
 Assigns the attribute content to the StringList value if the attribute is present. More...
 
bool optionalAttributeAsIntList_ (IntList &value, const xercesc::Attributes &a, const char *name) const
 Assigns the attribute content to the IntList value if the attribute is present. More...
 
String attributeAsString_ (const xercesc::Attributes &a, const XMLCh *name) const
 Converts an attribute to a String. More...
 
Int attributeAsInt_ (const xercesc::Attributes &a, const XMLCh *name) const
 Converts an attribute to a Int. More...
 
double attributeAsDouble_ (const xercesc::Attributes &a, const XMLCh *name) const
 Converts an attribute to a double. More...
 
DoubleList attributeAsDoubleList_ (const xercesc::Attributes &a, const XMLCh *name) const
 Converts an attribute to a DoubleList. More...
 
IntList attributeAsIntList_ (const xercesc::Attributes &a, const XMLCh *name) const
 Converts an attribute to a IntList. More...
 
StringList attributeAsStringList_ (const xercesc::Attributes &a, const XMLCh *name) const
 Converts an attribute to a StringList. More...
 
bool optionalAttributeAsString_ (String &value, const xercesc::Attributes &a, const XMLCh *name) const
 Assigns the attribute content to the String value if the attribute is present. More...
 
bool optionalAttributeAsInt_ (Int &value, const xercesc::Attributes &a, const XMLCh *name) const
 Assigns the attribute content to the Int value if the attribute is present. More...
 
bool optionalAttributeAsUInt_ (UInt &value, const xercesc::Attributes &a, const XMLCh *name) const
 Assigns the attribute content to the UInt value if the attribute is present. More...
 
bool optionalAttributeAsDouble_ (double &value, const xercesc::Attributes &a, const XMLCh *name) const
 Assigns the attribute content to the double value if the attribute is present. More...
 
bool optionalAttributeAsDoubleList_ (DoubleList &value, const xercesc::Attributes &a, const XMLCh *name) const
 Assigns the attribute content to the DoubleList value if the attribute is present. More...
 
bool optionalAttributeAsIntList_ (IntList &value, const xercesc::Attributes &a, const XMLCh *name) const
 Assigns the attribute content to the IntList value if the attribute is present. More...
 
bool optionalAttributeAsStringList_ (StringList &value, const xercesc::Attributes &a, const XMLCh *name) const
 Assigns the attribute content to the StringList value if the attribute is present. More...
 
- Protected Attributes inherited from XMLHandler
String error_message_
 Error message of the last error. More...
 
String file_
 File name. More...
 
String version_
 Schema version. More...
 
StringManager sm_
 Helper class for string conversion. More...
 
std::vector< Stringopen_tags_
 Stack of open XML tags. More...
 
LOADDETAIL load_detail_
 parse only until total number of scans and chroms have been determined from attributes More...
 
std::vector< std::vector< String > > cv_terms_
 Array of CV term lists (one sublist denotes one term and it's children) More...
 

Class Documentation

◆ OpenMS::Internal::MzXMLHandler::SpectrumData

struct OpenMS::Internal::MzXMLHandler::SpectrumData

Data necessary to generate a single spectrum.

Small struct holds all data necessary to populate a spectrum at a later timepoint (since reading of the base64 data and generation of spectra can be done at distinct timepoints).

Collaboration diagram for MzXMLHandler::SpectrumData:
[legend]
Class Members
String char_rest_
String compressionType_
UInt peak_count_
String precision_
bool skip_data
SpectrumType spectrum

Member Typedef Documentation

◆ PeakType

typedef MapType::PeakType PeakType
protected

Peak type.

◆ SpectrumType

typedef MSSpectrum SpectrumType
protected

Spectrum type.

Constructor & Destructor Documentation

◆ MzXMLHandler() [1/3]

MzXMLHandler ( MapType exp,
const String filename,
const String version,
ProgressLogger logger 
)

Constructor for a read-only handler.

◆ MzXMLHandler() [2/3]

MzXMLHandler ( const MapType exp,
const String filename,
const String version,
const ProgressLogger logger 
)

Constructor for a write-only handler.

◆ ~MzXMLHandler()

~MzXMLHandler ( )
inlineoverride

Destructor.

◆ MzXMLHandler() [3/3]

MzXMLHandler ( )
private

Not implemented.

Member Function Documentation

◆ characters()

void characters ( const XMLCh *const  chars,
const XMLSize_t  length 
)
override

◆ doPopulateSpectraWithData_()

void doPopulateSpectraWithData_ ( SpectrumData spectrum_data)
protected

Fill a single spectrum with data from input.

Note
Do not modify any internal state variables of the class since this function will be executed in parallel.

◆ endElement()

void endElement ( const XMLCh *const  uri,
const XMLCh *const  local_name,
const XMLCh *const  qname 
)
override

◆ getLoadDetail()

LOADDETAIL getLoadDetail ( ) const
overridevirtual

handler which support partial loading, implement this method

Reimplemented from XMLHandler.

◆ getScanCount()

UInt getScanCount ( ) const
inline

Gets the scan count.

◆ init_()

void init_ ( )
private

initialize members (call from C'tor)

◆ populateSpectraWithData_()

void populateSpectraWithData_ ( )
protected

Populate all spectra on the stack with data from input.

Will populate all spectra on the current work stack with data (using multiple threads if available) and append them to the result.

◆ setLoadDetail()

void setLoadDetail ( const LOADDETAIL  d)
overridevirtual

handler which support partial loading, implement this method

Reimplemented from XMLHandler.

◆ setMSDataConsumer()

void setMSDataConsumer ( Interfaces::IMSDataConsumer consumer)
inline

Set the IMSDataConsumer consumer which will consume the read data.

◆ setOptions()

void setOptions ( const PeakFileOptions options)
inline

Sets the options.

◆ startElement()

void startElement ( const XMLCh *const  uri,
const XMLCh *const  local_name,
const XMLCh *const  qname,
const xercesc::Attributes &  attributes 
)
override

◆ writeAttributeIfExists_()

bool writeAttributeIfExists_ ( std::ostream &  os,
const MetaInfoInterface meta,
const String metakey,
const String attname 
)
inlineprotected

write metaInfo to xml (usually in nameValue-tag) returns true if metavalue existed and data was written to the stream

◆ writeTo()

void writeTo ( std::ostream &  os)
overridevirtual

Write the contents to a stream.

Reimplemented from XMLHandler.

◆ writeUserParam_()

void writeUserParam_ ( std::ostream &  os,
const MetaInfoInterface meta,
int  indent = 4,
const String tag = "nameValue" 
)
inlineprotected

write metaInfo to xml (usually in nameValue-tag)

Member Data Documentation

◆ cexp_

const MapType* cexp_
protected

map pointer for writing

◆ consumer_

Interfaces::IMSDataConsumer* consumer_
protected

Consumer class to work on spectra.

◆ data_processing_

std::vector< boost::shared_ptr< DataProcessing> > data_processing_
protected

data processing auxiliary variable

◆ exp_

MapType* exp_
protected

map pointer for reading

◆ logger_

const ProgressLogger& logger_
protected

Progress logging class.

◆ nesting_level_

Int nesting_level_
protected

◆ options_

PeakFileOptions options_
protected

Options for loading and storing.

◆ scan_count_

UInt scan_count_
protected

Consumer class to work on spectra.

◆ skip_spectrum_

bool skip_spectrum_
protected

Flag that indicates whether this spectrum should be skipped (due to options)

◆ spec_write_counter_

UInt spec_write_counter_
protected

spectrum counter (spectra without peaks are not written)

◆ spectrum_data_

std::vector< SpectrumData > spectrum_data_
protected

Vector of spectrum data stored for later parallel processing.