Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
IndexedMzMLFile Class Reference

A low-level class to read an indexedmzML file. More...

#include <OpenMS/FORMAT/IndexedMzMLFile.h>

Public Member Functions

 IndexedMzMLFile ()
 Default constructor. More...
 
 IndexedMzMLFile (String filename)
 Constructor. More...
 
 IndexedMzMLFile (const IndexedMzMLFile &source)
 Copy constructor. More...
 
 ~IndexedMzMLFile ()
 Destructor. More...
 
void openFile (String filename)
 Open a file. More...
 
bool getParsingSuccess () const
 Returns whether parsing was successful. More...
 
size_t getNrSpectra () const
 Returns the number of spectra available. More...
 
size_t getNrChromatograms () const
 Returns the number of chromatograms available. More...
 
OpenMS::Interfaces::SpectrumPtr getSpectrumById (int id)
 Retrieve the raw data for the spectrum at position "id". More...
 
OpenMS::Interfaces::ChromatogramPtr getChromatogramById (int id)
 Retrieve the raw data for the chromatogram at position "id". More...
 
void setSkipXMLChecks (bool skip)
 Whether to skip some XML checks (removing whitespace from base64 arrays) and be fast instead. More...
 

Private Member Functions

void parseFooter_ (String filename)
 Try to parse the footer of the indexedmzML. More...
 

Private Attributes

String filename_
 Name of the file. More...
 
std::vector< std::pair< std::string, std::streampos > > spectra_offsets_
 Binary offsets to all spectra. More...
 
std::vector< std::pair< std::string, std::streampos > > chromatograms_offsets_
 Binary offsets to all chromatograms. More...
 
std::streampos index_offset_
 offset to the <indexList> element More...
 
bool spectra_before_chroms_
 Whether spectra are written before chromatograms in this file. More...
 
std::ifstream filestream_
 The current filestream (opened by openFile) More...
 
bool parsing_success_
 Whether parsing the indexedmzML file was successful. More...
 
bool skip_xml_checks_
 Whether to skip XML checks. More...
 

Detailed Description

A low-level class to read an indexedmzML file.

This class provides low-level access to the underlying data structures, if you simply want to read an indexed mzML file you probably want to use IndexedMzMLFileLoader instead.

This class implements access to an indexedmzML file and the contained spectra and chromatogram data through the getSpectrumById and getChromatogramById functions. It thus allows random access to spectra and chromatograms data without having to read the whole file into memory. It does not provide the same interface as MSExperiment, if this is desired, please use IndexedMzMLFileLoader and OnDiscMSExperiment.

Internally, it uses the IndexedMzMLDecoder for initial parsing and extracting all the offsets of the <chromatogram> and <spectrum> tags. These offsets are stored as members of this class as well as the offset to the <indexList> element

Note
This implementation is not thread-safe since it keeps internally a single file access pointer which it moves when accessing a specific data item. The caller is responsible to ensure that access is performed atomically.

Constructor & Destructor Documentation

◆ IndexedMzMLFile() [1/3]

Default constructor.

◆ IndexedMzMLFile() [2/3]

IndexedMzMLFile ( String  filename)
explicit

Constructor.

Tries to parse the file, success can be checked with getParsingSuccess()

◆ IndexedMzMLFile() [3/3]

IndexedMzMLFile ( const IndexedMzMLFile source)

Copy constructor.

◆ ~IndexedMzMLFile()

Destructor.

Member Function Documentation

◆ getChromatogramById()

OpenMS::Interfaces::ChromatogramPtr getChromatogramById ( int  id)

Retrieve the raw data for the chromatogram at position "id".

Exceptions
Exceptionif getParsingSuccess() returns false
Exceptionif id is not within [0, getNrChromatograms()-1]
Returns
The chromatogram at position id

Referenced by OnDiscMSExperiment::getChromatogram(), and OnDiscMSExperiment::getChromatogramById().

◆ getNrChromatograms()

size_t getNrChromatograms ( ) const

Returns the number of chromatograms available.

Referenced by OnDiscMSExperiment::getNrChromatograms().

◆ getNrSpectra()

size_t getNrSpectra ( ) const

Returns the number of spectra available.

Referenced by OnDiscMSExperiment::empty(), and OnDiscMSExperiment::getNrSpectra().

◆ getParsingSuccess()

bool getParsingSuccess ( ) const

Returns whether parsing was successful.

Note
Callable after openFile or the constructor using a filename
It is invalid to call getSpectrumById or getChromatogramById if this function returns false
Returns
Whether the parsing of the file was successful (if false, the file most likely was not an indexed mzML file)

Referenced by OnDiscMSExperiment::openFile().

◆ getSpectrumById()

OpenMS::Interfaces::SpectrumPtr getSpectrumById ( int  id)

Retrieve the raw data for the spectrum at position "id".

Exceptions
Exceptionif getParsingSuccess() returns false
Exceptionif id is not within [0, getNrSpectra()-1]
Returns
The spectrum at position id

Referenced by OnDiscMSExperiment::getSpectrum(), and OnDiscMSExperiment::getSpectrumById().

◆ openFile()

void openFile ( String  filename)

Open a file.

Tries to parse the file, success can be checked with getParsingSuccess()

Referenced by OnDiscMSExperiment::openFile().

◆ parseFooter_()

void parseFooter_ ( String  filename)
private

Try to parse the footer of the indexedmzML.

Upon success, the chromatogram and spectra offsets will be populated and parsing_success_ will be set to true.

Note
You *need* to check getParsingSuccess after calling this!

◆ setSkipXMLChecks()

void setSkipXMLChecks ( bool  skip)
inline

Whether to skip some XML checks (removing whitespace from base64 arrays) and be fast instead.

Referenced by OnDiscMSExperiment::setSkipXMLChecks().

Member Data Documentation

◆ chromatograms_offsets_

std::vector< std::pair<std::string, std::streampos> > chromatograms_offsets_
private

Binary offsets to all chromatograms.

◆ filename_

String filename_
private

Name of the file.

◆ filestream_

std::ifstream filestream_
private

The current filestream (opened by openFile)

◆ index_offset_

std::streampos index_offset_
private

offset to the <indexList> element

◆ parsing_success_

bool parsing_success_
private

Whether parsing the indexedmzML file was successful.

◆ skip_xml_checks_

bool skip_xml_checks_
private

Whether to skip XML checks.

◆ spectra_before_chroms_

bool spectra_before_chroms_
private

Whether spectra are written before chromatograms in this file.

◆ spectra_offsets_

std::vector< std::pair<std::string, std::streampos> > spectra_offsets_
private

Binary offsets to all spectra.


OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:09 using doxygen 1.8.13