| OpenMS 2.5.0

IndexedMzMLHandler.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2020.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Hannes Roest $
32 // $Authors: Hannes Roest $
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/config.h>
38 #include <OpenMS/CONCEPT/Types.h>
39 #include <OpenMS/DATASTRUCTURES/String.h>
40 #include <OpenMS/INTERFACES/DataStructures.h>
41 #include <OpenMS/INTERFACES/ISpectrumAccess.h>
42 #include <OpenMS/KERNEL/MSSpectrum.h>
43 #include <OpenMS/KERNEL/MSChromatogram.h>
44
45 #include <string>
46 #include <fstream>
47
48 namespace OpenMS
49 {
50
51 namespace Internal
52 {
53
78 class OPENMS_DLLAPI IndexedMzMLHandler
79 {
81 String filename_;
83 std::vector< std::pair<std::string, std::streampos> > spectra_offsets_;
85 std::vector< std::pair<std::string, std::streampos> > chromatograms_offsets_;
87 std::streampos index_offset_;
89 bool spectra_before_chroms_;
91 std::ifstream filestream_;
93 bool parsing_success_;
95 bool skip_xml_checks_;
96
105 void parseFooter_(String filename);
106
107 std::string getChromatogramById_helper_(int id);
108
109 std::string getSpectrumById_helper_(int id);
110
111 public:
112
116 IndexedMzMLHandler();
117
123 explicit IndexedMzMLHandler(const String& filename);
124
126 IndexedMzMLHandler(const IndexedMzMLHandler& source);
127
129 ~IndexedMzMLHandler();
130
136 void openFile(String filename);
137
147 bool getParsingSuccess() const;
148
150 size_t getNrSpectra() const;
151
153 size_t getNrChromatograms() const;
154
163 OpenMS::Interfaces::SpectrumPtr getSpectrumById(int id);
164
173 const OpenMS::MSSpectrum getMSSpectrumById(int id);
174
184 void getMSSpectrumById(int id, OpenMS::MSSpectrum& s);
185
194 OpenMS::Interfaces::ChromatogramPtr getChromatogramById(int id);
195
204 const OpenMS::MSChromatogram getMSChromatogramById(int id);
205
215 void getMSChromatogramById(int id, OpenMS::MSChromatogram& c);
216
218 void setSkipXMLChecks(bool skip)
219 {
220 skip_xml_checks_ = skip;
221 }
222
223 };
224 }
225 }
226
OpenMS::Internal::IndexedMzMLHandler::filename_
String filename_
Name of the file.
Definition: IndexedMzMLHandler.h:81
OpenMS::Internal::IndexedMzMLHandler::chromatograms_offsets_
std::vector< std::pair< std::string, std::streampos > > chromatograms_offsets_
Binary offsets to all chromatograms.
Definition: IndexedMzMLHandler.h:85
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::Internal::IndexedMzMLHandler::filestream_
std::ifstream filestream_
The current filestream (opened by openFile)
Definition: IndexedMzMLHandler.h:91
OpenMS::MSChromatogram
The representation of a chromatogram.
Definition: MSChromatogram.h:54
OpenMS::Internal::IndexedMzMLHandler::parsing_success_
bool parsing_success_
Whether parsing the indexedmzML file was successful.
Definition: IndexedMzMLHandler.h:93
Types.h
OpenMS::Internal::IndexedMzMLHandler::spectra_before_chroms_
bool spectra_before_chroms_
Whether spectra are written before chromatograms in this file.
Definition: IndexedMzMLHandler.h:89
OpenMS::Internal::IndexedMzMLHandler::spectra_offsets_
std::vector< std::pair< std::string, std::streampos > > spectra_offsets_
Binary offsets to all spectra.
Definition: IndexedMzMLHandler.h:83
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
ISpectrumAccess.h
String.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::Internal::IndexedMzMLHandler::index_offset_
std::streampos index_offset_
offset to the <indexList> element
Definition: IndexedMzMLHandler.h:87
OpenMS::Internal::IndexedMzMLHandler::skip_xml_checks_
bool skip_xml_checks_
Whether to skip XML checks.
Definition: IndexedMzMLHandler.h:95
MSSpectrum.h
OpenMS::Constants::c
const double c
OpenMS::Internal::IndexedMzMLHandler
A low-level class to read an indexedmzML file.
Definition: IndexedMzMLHandler.h:78
MSChromatogram.h
OpenMS::Internal::IndexedMzMLHandler::setSkipXMLChecks
void setSkipXMLChecks(bool skip)
Whether to skip some XML checks (removing whitespace from base64 arrays) and be fast instead...
Definition: IndexedMzMLHandler.h:218
OpenMS::Interfaces::ChromatogramPtr
boost::shared_ptr< Chromatogram > ChromatogramPtr
Definition: openms/include/OpenMS/INTERFACES/DataStructures.h:156
OpenMS::Interfaces::SpectrumPtr
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: openms/include/OpenMS/INTERFACES/DataStructures.h:236
DataStructures.h