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 class to read an indexedmzML file. More...

#include <OpenMS/FORMAT/IndexedMzMLFile.h>

Public Member Functions

 IndexedMzMLFile ()
 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)
 sets whether to skip some XML checks 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_
 

Detailed Description

A class to read an indexedmzML file.

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.

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 ( )
inline

Constructor.

IndexedMzMLFile ( String  filename)
explicit

Constructor.

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

IndexedMzMLFile ( const IndexedMzMLFile source)

Copy constructor.

Destructor.

Member Function Documentation

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< PeakT, ChromatogramPeakT >::getChromatogram(), and OnDiscMSExperiment< PeakT, ChromatogramPeakT >::getChromatogramById().

size_t getNrChromatograms ( ) const

Returns the number of chromatograms available.

Referenced by OnDiscMSExperiment< PeakT, ChromatogramPeakT >::getNrChromatograms().

size_t getNrSpectra ( ) const
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< PeakT, ChromatogramPeakT >::openFile().

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< PeakT, ChromatogramPeakT >::getSpectrum(), and OnDiscMSExperiment< PeakT, ChromatogramPeakT >::getSpectrumById().

void openFile ( String  filename)

Open a file.

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

Referenced by OnDiscMSExperiment< PeakT, ChromatogramPeakT >::openFile().

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.

void setSkipXMLChecks ( bool  skip)
inline

sets whether to skip some XML checks and be fast instead

Referenced by OnDiscMSExperiment< PeakT, ChromatogramPeakT >::setSkipXMLChecks().

Member Data Documentation

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

Binary offsets to all chromatograms.

String filename_
private

Name of the file.

std::ifstream filestream_
private

The current filestream (opened by openFile)

std::streampos index_offset_
private

offset to the <indexList> element

bool parsing_success_
private

Whether parsing the indexedmzML file was successful.

bool skip_xml_checks_
private
bool spectra_before_chroms_
private

Whether spectra are written before chromatograms in this file.

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

Binary offsets to all spectra.


OpenMS / TOPP release 2.0.0 Documentation generated on Tue Aug 25 2015 05:54:01 using doxygen 1.8.9.1