OpenMS
Loading...
Searching...
No Matches
MzMLFile.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Marc Sturm, Chris Bielow, Hannes Roest $
7// --------------------------------------------------------------------------
8
9#pragma once
10
16
17#include <OpenMS/DATASTRUCTURES/ListUtils.h> // StringList
19
20#include <map>
21
22namespace OpenMS
23{
31 class OPENMS_DLLAPI MzMLFile :
32 public Internal::XMLFile,
33 public ProgressLogger
34 {
35public:
39 ~MzMLFile() override;
40
43
46
49
59 void load(const std::string& filename, PeakMap& map);
60
69 void loadBuffer(const std::string& buffer, PeakMap& map);
70
81 void loadSize(const std::string & filename, Size& scount, Size& ccount);
82
90 void store(const std::string& filename, const PeakMap& map) const;
91
98 void storeBuffer(std::string & output, const PeakMap& map) const;
99
119 void transform(const std::string& filename_in, Interfaces::IMSDataConsumer * consumer, bool skip_full_count = false, bool skip_first_pass = false);
120
136 void transform(const std::string& filename_in, Interfaces::IMSDataConsumer * consumer, PeakMap& map, bool skip_full_count = false, bool skip_first_pass = false);
137
143 bool isValid(const std::string& filename, std::ostream& os = std::cerr);
144
154 bool isSemanticallyValid(const std::string& filename, StringList& errors, StringList& warnings);
155
163 bool hasIndex(const std::string& filename);
164
165 struct SpecInfo
166 {
167 Size count_centroided = 0;
168 Size count_profile = 0;
169 Size count_unknown = 0;
170 };
171
189 std::map<UInt, SpecInfo> getCentroidInfo(const std::string& filename, const Size first_n_spectra_only = 10);
190
191protected:
192
194 void transformFirstPass_(const std::string& filename_in, Interfaces::IMSDataConsumer * consumer, bool skip_full_count);
195
197 void safeParse_(const std::string & filename, Internal::XMLHandler * handler);
198
199private:
200
203
206 };
207
208} // namespace OpenMS
The interface of a consumer of spectra and chromatograms.
Definition IMSDataConsumer.h:46
Base class for loading and storing XML files via Xerces, with optional schema validation and transpar...
Definition XMLFile.h:38
Base class for XML handlers.
Definition XMLHandler.h:316
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
File adapter for MzML files.
Definition MzMLFile.h:34
void transform(const std::string &filename_in, Interfaces::IMSDataConsumer *consumer, bool skip_full_count=false, bool skip_first_pass=false)
Transforms a map while loading using the supplied MSDataConsumer.
void setOptions(const PeakFileOptions &)
set options for loading/storing
bool isValid(const std::string &filename, std::ostream &os=std::cerr)
Checks if a file validates against the XML schema.
bool hasIndex(const std::string &filename)
Checks if a file is an indexed MzML file or not.
const PeakFileOptions & getOptions() const
Non-mutable access to the options for loading/storing.
std::map< UInt, SpecInfo > getCentroidInfo(const std::string &filename, const Size first_n_spectra_only=10)
Check type of spectra based on their metadata (if available) or by inspecting the peaks itself.
PeakFileOptions options_
Options for loading / storing.
Definition MzMLFile.h:202
MzMLFile()
Default constructor.
std::string indexed_schema_location_
Location of indexed mzML schema.
Definition MzMLFile.h:205
void store(const std::string &filename, const PeakMap &map) const
Stores a map in an MzML file.
PeakFileOptions & getOptions()
Mutable access to the options for loading/storing.
void loadSize(const std::string &filename, Size &scount, Size &ccount)
Only count the number of spectra and chromatograms from a file.
void storeBuffer(std::string &output, const PeakMap &map) const
Stores a map in an output string.
void transform(const std::string &filename_in, Interfaces::IMSDataConsumer *consumer, PeakMap &map, bool skip_full_count=false, bool skip_first_pass=false)
Transforms a map while loading using the supplied MSDataConsumer.
void loadBuffer(const std::string &buffer, PeakMap &map)
Loads a map from a MzML file stored in a buffer (in memory).
~MzMLFile() override
Destructor.
void transformFirstPass_(const std::string &filename_in, Interfaces::IMSDataConsumer *consumer, bool skip_full_count)
Perform first pass through the file and retrieve the meta-data to initialize the consumer.
void safeParse_(const std::string &filename, Internal::XMLHandler *handler)
Safe parse that catches exceptions and handles them accordingly.
bool isSemanticallyValid(const std::string &filename, StringList &errors, StringList &warnings)
Checks if a file is valid with respect to the mapping file and the controlled vocabulary.
void load(const std::string &filename, PeakMap &map)
Loads a map from a MzML file. Spectra and chromatograms are sorted by default (this can be disabled u...
Definition MzMLFile.h:166
Options for loading files containing peak data.
Definition PeakFileOptions.h:22
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
std::vector< std::string > StringList
Vector of String.
Definition ListUtils.h:44
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19