OpenMS
Loading...
Searching...
No Matches
ChromatogramSettings.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: Andreas Bertsch $
7// --------------------------------------------------------------------------
8
9#pragma once
10
19
20#include <functional>
21#include <map>
22#include <vector>
23
24namespace OpenMS
25{
26
35 class OPENMS_DLLAPI ChromatogramSettings :
37 {
38
39public:
40
56
58 static const char * const ChromatogramNames[SIZE_OF_CHROMATOGRAM_TYPE+1]; // avoid string[], since it gets copied onto heap on initialization
59
68
69 // Assignment operator
73
75 bool operator==(const ChromatogramSettings & rhs) const;
77 bool operator!=(const ChromatogramSettings & rhs) const;
78
80 const String & getNativeID() const;
82 void setNativeID(const String & native_id);
83
85 const String & getComment() const;
87 void setComment(const String & comment);
88
94 void setInstrumentSettings(const InstrumentSettings & instrument_settings);
95
101 void setAcquisitionInfo(const AcquisitionInfo & acquisition_info);
102
104 const SourceFile & getSourceFile() const;
108 void setSourceFile(const SourceFile & source_file);
109
111 const Precursor & getPrecursor() const;
115 void setPrecursor(const Precursor & precursor);
116
118 const Product & getProduct() const;
122 void setProduct(const Product & product);
123
126
129
131 void setDataProcessing(const std::vector< DataProcessingPtr > & data_processing);
132
134 std::vector< DataProcessingPtr > & getDataProcessing();
135
137 const std::vector< std::shared_ptr<const DataProcessing > > getDataProcessing() const;
138
139protected:
140
148 std::vector< DataProcessingPtr > data_processing_;
150 };
151
153 OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const ChromatogramSettings & spec);
154
155} // namespace OpenMS
156
157// Hash function specialization for ChromatogramSettings
158namespace std
159{
178 template<>
179 struct hash<OpenMS::ChromatogramSettings>
180 {
181 std::size_t operator()(const OpenMS::ChromatogramSettings& cs) const noexcept
182 {
183 std::size_t seed = 0;
184
185 // Hash native_id_ and comment_
186 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(cs.getNativeID()));
187 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(cs.getComment()));
188
189 // Hash instrument_settings_
190 const auto& is = cs.getInstrumentSettings();
191 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(is.getScanMode())));
192 OpenMS::hash_combine(seed, OpenMS::hash_int(is.getZoomScan() ? 1 : 0));
193 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(is.getPolarity())));
194 // Hash scan windows
195 const auto& scan_windows = is.getScanWindows();
196 OpenMS::hash_combine(seed, OpenMS::hash_int(scan_windows.size()));
197 for (const auto& sw : scan_windows)
198 {
201 }
202
203 // Hash acquisition_info_
204 const auto& ai = cs.getAcquisitionInfo();
205 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(ai.getMethodOfCombination()));
206 OpenMS::hash_combine(seed, OpenMS::hash_int(ai.size()));
207 for (const auto& acq : ai)
208 {
209 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(acq.getIdentifier()));
210 }
211
212 // Hash source_file_
213 const auto& sf = cs.getSourceFile();
214 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(sf.getNameOfFile()));
215 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(sf.getPathToFile()));
216 OpenMS::hash_combine(seed, OpenMS::hash_float(static_cast<double>(sf.getFileSize())));
217 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(sf.getFileType()));
218 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(sf.getChecksum()));
219 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(sf.getChecksumType())));
220 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(sf.getNativeIDType()));
221 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(sf.getNativeIDTypeAccession()));
222
223 // Hash precursor_
224 const auto& prec = cs.getPrecursor();
225 // Hash activation methods
226 const auto& am = prec.getActivationMethods();
227 OpenMS::hash_combine(seed, OpenMS::hash_int(am.size()));
228 for (const auto& method : am)
229 {
230 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(method)));
231 }
232 OpenMS::hash_combine(seed, OpenMS::hash_float(prec.getActivationEnergy()));
233 OpenMS::hash_combine(seed, OpenMS::hash_float(prec.getIsolationWindowLowerOffset()));
234 OpenMS::hash_combine(seed, OpenMS::hash_float(prec.getIsolationWindowUpperOffset()));
235 OpenMS::hash_combine(seed, OpenMS::hash_float(prec.getDriftTime()));
236 OpenMS::hash_combine(seed, OpenMS::hash_float(prec.getDriftTimeWindowLowerOffset()));
237 OpenMS::hash_combine(seed, OpenMS::hash_float(prec.getDriftTimeWindowUpperOffset()));
238 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(prec.getDriftTimeUnit())));
239 OpenMS::hash_combine(seed, OpenMS::hash_int(prec.getCharge()));
240 // Hash possible charge states
241 const auto& pcs = prec.getPossibleChargeStates();
242 OpenMS::hash_combine(seed, OpenMS::hash_int(pcs.size()));
243 for (const auto& charge : pcs)
244 {
246 }
247 // Hash Peak1D part (MZ and intensity)
248 OpenMS::hash_combine(seed, OpenMS::hash_float(prec.getMZ()));
249 OpenMS::hash_combine(seed, OpenMS::hash_float(prec.getIntensity()));
250
251 // Hash product_ using existing std::hash<Product>
252 OpenMS::hash_combine(seed, std::hash<OpenMS::Product>{}(cs.getProduct()));
253
254 // Hash data_processing_
255 const auto dp = cs.getDataProcessing();
256 OpenMS::hash_combine(seed, OpenMS::hash_int(dp.size()));
257 for (const auto& proc_ptr : dp)
258 {
259 if (proc_ptr)
260 {
261 // Hash software using std::hash<Software>
262 OpenMS::hash_combine(seed, std::hash<OpenMS::Software>{}(proc_ptr->getSoftware()));
263 // Hash processing actions
264 const auto& actions = proc_ptr->getProcessingActions();
265 OpenMS::hash_combine(seed, OpenMS::hash_int(actions.size()));
266 for (const auto& action : actions)
267 {
268 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(action)));
269 }
270 // Hash completion time using std::hash<DateTime>
271 OpenMS::hash_combine(seed, std::hash<OpenMS::DateTime>{}(proc_ptr->getCompletionTime()));
272 }
273 }
274
275 // Hash type_
276 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(cs.getChromatogramType())));
277
278 // Hash MetaInfoInterface base class
279 OpenMS::hash_combine(seed, std::hash<OpenMS::MetaInfoInterface>{}(cs));
280
281 return seed;
282 }
283 };
284} // namespace std
285
Description of the combination of raw data to a single spectrum.
Definition AcquisitionInfo.h:29
Representation of chromatogram settings, e.g. SRM/MRM chromatograms.
Definition ChromatogramSettings.h:37
String comment_
Definition ChromatogramSettings.h:142
void setPrecursor(const Precursor &precursor)
sets the precursors
ChromatogramType type_
Definition ChromatogramSettings.h:149
AcquisitionInfo acquisition_info_
Definition ChromatogramSettings.h:145
Precursor & getPrecursor()
returns a mutable reference to the precursors
SourceFile source_file_
Definition ChromatogramSettings.h:144
void setComment(const String &comment)
sets the free-text comment
const String & getNativeID() const
returns the native identifier for the spectrum, used by the acquisition software.
InstrumentSettings instrument_settings_
Definition ChromatogramSettings.h:143
void setProduct(const Product &product)
sets the products
InstrumentSettings & getInstrumentSettings()
returns a mutable reference to the instrument settings of the current spectrum
std::vector< DataProcessingPtr > & getDataProcessing()
returns a mutable reference to the description of the applied processing
const Product & getProduct() const
returns a const reference to the products
const std::vector< std::shared_ptr< const DataProcessing > > getDataProcessing() const
returns a const reference to the description of the applied processing
void setInstrumentSettings(const InstrumentSettings &instrument_settings)
sets the instrument settings of the current spectrum
Product product_
Definition ChromatogramSettings.h:147
SourceFile & getSourceFile()
returns a mutable reference to the source file
ChromatogramSettings(ChromatogramSettings &&)=default
Move constructor.
ChromatogramSettings(const ChromatogramSettings &)=default
Copy constructor.
Product & getProduct()
returns a mutable reference to the products
ChromatogramSettings & operator=(ChromatogramSettings &&) &=default
Move assignment operator.
ChromatogramType
Definition ChromatogramSettings.h:44
@ ABSORPTION_CHROMATOGRAM
Definition ChromatogramSettings.h:52
@ EMISSION_CHROMATOGRAM
Definition ChromatogramSettings.h:53
@ SELECTED_ION_CURRENT_CHROMATOGRAM
Definition ChromatogramSettings.h:47
@ BASEPEAK_CHROMATOGRAM
Definition ChromatogramSettings.h:48
@ SELECTED_REACTION_MONITORING_CHROMATOGRAM
Definition ChromatogramSettings.h:50
@ TOTAL_ION_CURRENT_CHROMATOGRAM
Definition ChromatogramSettings.h:46
@ ELECTROMAGNETIC_RADIATION_CHROMATOGRAM
Definition ChromatogramSettings.h:51
@ SELECTED_ION_MONITORING_CHROMATOGRAM
Definition ChromatogramSettings.h:49
String native_id_
Definition ChromatogramSettings.h:141
const String & getComment() const
returns the free-text comment
void setSourceFile(const SourceFile &source_file)
sets the source file
ChromatogramSettings()
Constructor.
const InstrumentSettings & getInstrumentSettings() const
returns a const reference to the instrument settings of the current spectrum
AcquisitionInfo & getAcquisitionInfo()
returns a mutable reference to the acquisition info
void setChromatogramType(ChromatogramType type)
sets the chromatogram type
std::vector< DataProcessingPtr > data_processing_
Definition ChromatogramSettings.h:148
void setDataProcessing(const std::vector< DataProcessingPtr > &data_processing)
sets the description of the applied processing
const SourceFile & getSourceFile() const
returns a const reference to the source file
const AcquisitionInfo & getAcquisitionInfo() const
returns a const reference to the acquisition info
Precursor precursor_
Definition ChromatogramSettings.h:146
void setAcquisitionInfo(const AcquisitionInfo &acquisition_info)
sets the acquisition info
bool operator!=(const ChromatogramSettings &rhs) const
Equality operator.
const Precursor & getPrecursor() const
returns a const reference to the precursors
ChromatogramType getChromatogramType() const
returns the chromatogram type, e.g. a SRM chromatogram
ChromatogramSettings & operator=(const ChromatogramSettings &)=default
virtual ~ChromatogramSettings()
Destructor.
void setNativeID(const String &native_id)
sets the native identifier for the spectrum, used by the acquisition software.
bool operator==(const ChromatogramSettings &rhs) const
Equality operator.
Description of the settings a MS Instrument was run with.
Definition InstrumentSettings.h:24
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition MetaInfoInterface.h:36
Precursor meta information.
Definition Precursor.h:37
Product meta information.
Definition Product.h:26
Description of a file location, used to store the origin of (meta) data.
Definition SourceFile.h:23
A more convenient string class.
Definition String.h:34
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
std::size_t hash_int(T value) noexcept
Hash for an integer type.
Definition HashUtils.h:107
void hash_combine(std::size_t &seed, std::size_t value) noexcept
Combine a hash value with additional data using golden ratio mixing.
Definition HashUtils.h:87
std::size_t hash_float(T value) noexcept
Hash for a floating point type (float or double).
Definition HashUtils.h:142
std::size_t fnv1a_hash_string(const std::string &s) noexcept
FNV-1a hash for a string.
Definition HashUtils.h:70
STL namespace.
std::size_t operator()(const OpenMS::ChromatogramSettings &cs) const noexcept
Definition ChromatogramSettings.h:181