OpenMS
Loading...
Searching...
No Matches
ReactionMonitoringTransition.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
15
16#include <functional>
17#include <vector>
18#include <bitset>
19
20namespace OpenMS
21{
22
32 class OPENMS_DLLAPI ReactionMonitoringTransition :
33 public CVTermList
34 {
35
36public:
37
42
49
55
58
61
65
68
71
75 void setName(const String & name);
76
77 const String & getName() const;
78
79 void setNativeID(const String & name);
80
81 const String & getNativeID() const;
82
83 void setPeptideRef(const String & peptide_ref);
84
85 const String & getPeptideRef() const;
86
87 void setCompoundRef(const String & compound_ref);
88
89 const String & getCompoundRef() const;
90
92 void setPrecursorMZ(double mz);
93
95 double getPrecursorMZ() const;
96
98 bool hasPrecursorCVTerms() const;
99
100 void setPrecursorCVTermList(const CVTermList & list);
101
102 void addPrecursorCVTerm(const CVTerm & cv_term);
103
108 const CVTermList & getPrecursorCVTermList() const;
109
110 void setProductMZ(double mz);
111
112 double getProductMZ() const;
113
114 int getProductChargeState() const;
115
116 bool isProductChargeStateSet() const;
117
118 void addProductCVTerm(const CVTerm & cv_term);
119
120 const std::vector<Product> & getIntermediateProducts() const;
121
122 void addIntermediateProduct(const Product& product);
123
124 void setIntermediateProducts(const std::vector<Product> & products);
125
126 void setProduct(Product product);
127
128 const Product & getProduct() const;
129
131 bool hasPrediction() const;
132
133 void setPrediction(const Prediction & prediction);
134
135 void addPredictionTerm(const CVTerm & prediction);
136
141 const Prediction & getPrediction() const;
142
144 DecoyTransitionType getDecoyTransitionType() const;
145
147 void setDecoyTransitionType(const DecoyTransitionType & d);
148
150 double getLibraryIntensity() const;
151
153 void setLibraryIntensity(double intensity);
154
173 void setRetentionTime(RetentionTime rt);
174
182 const RetentionTime & getRetentionTime() const;
183
185
201 bool isDetectingTransition() const;
202
203 void setDetectingTransition(bool val);
205
219 bool isIdentifyingTransition() const;
220
221 void setIdentifyingTransition(bool val);
223
236 bool isQuantifyingTransition() const;
237
238 void setQuantifyingTransition(bool val);
240
242
247 bool operator==(const ReactionMonitoringTransition & rhs) const;
248
250 bool operator!=(const ReactionMonitoringTransition & rhs) const;
252
260 {
262 };
264
271 struct NameLess
272 {
274 };
276
277protected:
278
280
284
286
287 // attributes to a peptide / compound (optional)
290
293
297
301
302 // Precursor
303 // Product
304 // IntermediateProduct
305 // RetentionTime
306 // Prediction
307 // cvparam / userParam
308
311
314
317
319 std::vector<Product> intermediate_products_;
320
323
326
329 std::bitset<3> transition_flags_;
331 };
332} // namespace OpenMS
333
334namespace std
335{
337 template<>
338 struct hash<OpenMS::ReactionMonitoringTransition>
339 {
340 std::size_t operator()(const OpenMS::ReactionMonitoringTransition& rmt) const noexcept
341 {
342 std::size_t seed = 0;
343
344 // Hash base class CVTermList - use the CV terms map
345 for (const auto& [accession, terms] : rmt.getCVTerms())
346 {
348 OpenMS::hash_combine(seed, OpenMS::hash_int(terms.size()));
349 for (const auto& term : terms)
350 {
351 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(term.getAccession()));
352 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(term.getName()));
353 }
354 }
355
356 // Hash name_
358
359 // Hash peptide_ref_
360 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(rmt.getPeptideRef()));
361
362 // Hash compound_ref_
363 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(rmt.getCompoundRef()));
364
365 // Hash precursor_mz_
366 OpenMS::hash_combine(seed, OpenMS::hash_float(rmt.getPrecursorMZ()));
367
368 // Hash precursor_cv_terms_ (pointer - check if present)
369 if (rmt.hasPrecursorCVTerms())
370 {
371 const auto& precursorTerms = rmt.getPrecursorCVTermList();
372 for (const auto& [accession, terms] : precursorTerms.getCVTerms())
373 {
375 OpenMS::hash_combine(seed, OpenMS::hash_int(terms.size()));
376 }
377 }
378 else
379 {
381 }
382
383 // Hash product_ - use getMZ and charge state
384 const auto& product = rmt.getProduct();
385 OpenMS::hash_combine(seed, OpenMS::hash_float(product.getMZ()));
386 if (product.hasCharge())
387 {
388 OpenMS::hash_combine(seed, OpenMS::hash_int(product.getChargeState()));
389 }
390 // Hash product CV terms
391 for (const auto& [accession, terms] : product.getCVTerms())
392 {
394 OpenMS::hash_combine(seed, OpenMS::hash_int(terms.size()));
395 }
396 // Hash configuration list size and interpretation list size
397 OpenMS::hash_combine(seed, OpenMS::hash_int(product.getConfigurationList().size()));
398 OpenMS::hash_combine(seed, OpenMS::hash_int(product.getInterpretationList().size()));
399
400 // Hash intermediate_products_ - use size and individual product m/z values
401 const auto& intermediates = rmt.getIntermediateProducts();
402 OpenMS::hash_combine(seed, OpenMS::hash_int(intermediates.size()));
403 for (const auto& ip : intermediates)
404 {
405 OpenMS::hash_combine(seed, OpenMS::hash_float(ip.getMZ()));
406 if (ip.hasCharge())
407 {
408 OpenMS::hash_combine(seed, OpenMS::hash_int(ip.getChargeState()));
409 }
410 }
411
412 // Hash rts (RetentionTime)
413 const auto& rt = rmt.getRetentionTime();
414 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(rt.software_ref));
415 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(rt.retention_time_unit)));
416 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(rt.retention_time_type)));
417 OpenMS::hash_combine(seed, OpenMS::hash_int(rt.isRTset() ? 1 : 0));
418 if (rt.isRTset())
419 {
420 OpenMS::hash_combine(seed, OpenMS::hash_float(rt.getRT()));
421 }
422 // Hash RetentionTime CV terms
423 for (const auto& [accession, terms] : rt.getCVTerms())
424 {
426 OpenMS::hash_combine(seed, OpenMS::hash_int(terms.size()));
427 }
428
429 // Hash prediction_ (pointer - check if present)
430 if (rmt.hasPrediction())
431 {
432 const auto& pred = rmt.getPrediction();
433 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(pred.software_ref));
434 OpenMS::hash_combine(seed, OpenMS::fnv1a_hash_string(pred.contact_ref));
435 for (const auto& [accession, terms] : pred.getCVTerms())
436 {
438 OpenMS::hash_combine(seed, OpenMS::hash_int(terms.size()));
439 }
440 }
441 else
442 {
444 }
445
446 // Hash library_intensity_
447 OpenMS::hash_combine(seed, OpenMS::hash_float(rmt.getLibraryIntensity()));
448
449 // Hash decoy_type_
450 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(rmt.getDecoyTransitionType())));
451
452 // Hash transition_flags_ (bitset<3>) - use the boolean accessors
453 OpenMS::hash_combine(seed, OpenMS::hash_int(rmt.isDetectingTransition() ? 1 : 0));
454 OpenMS::hash_combine(seed, OpenMS::hash_int(rmt.isIdentifyingTransition() ? 1 : 0));
455 OpenMS::hash_combine(seed, OpenMS::hash_int(rmt.isQuantifyingTransition() ? 1 : 0));
456
457 return seed;
458 }
459 };
460} // namespace std
461
Representation of controlled vocabulary term list.
Definition CVTermList.h:29
Representation of controlled vocabulary term.
Definition CVTerm.h:28
This class stores a SRM/MRM transition.
Definition ReactionMonitoringTransition.h:34
ReactionMonitoringTransition()
default constructor
CVTermList * precursor_cv_terms_
(Other) CV Terms of the Precursor (Q1) of the transition or target
Definition ReactionMonitoringTransition.h:313
DecoyTransitionType
Definition ReactionMonitoringTransition.h:44
@ TARGET
Target transition.
Definition ReactionMonitoringTransition.h:46
@ UNKNOWN
Unknown type.
Definition ReactionMonitoringTransition.h:45
String name_
id, required attribute
Definition ReactionMonitoringTransition.h:285
String peptide_ref_
Reference to a specific peptide.
Definition ReactionMonitoringTransition.h:288
Product product_
Product (Q3) of the transition.
Definition ReactionMonitoringTransition.h:316
String compound_ref_
Reference to a specific compound.
Definition ReactionMonitoringTransition.h:289
ReactionMonitoringTransition(ReactionMonitoringTransition &&) noexcept
Move constructor.
TargetedExperimentHelper::Configuration Configuration
Definition ReactionMonitoringTransition.h:38
TargetedExperimentHelper::Prediction Prediction
Definition ReactionMonitoringTransition.h:41
DecoyTransitionType decoy_type_
specific properties of a transition (e.g. specific CV terms)
Definition ReactionMonitoringTransition.h:295
Prediction * prediction_
Information about a prediction for a suitable transition using some software (optional)
Definition ReactionMonitoringTransition.h:325
double precursor_mz_
A transition has exactly one precursor and it must supply the CV Term 1000827 (isolation window targe...
Definition ReactionMonitoringTransition.h:310
ReactionMonitoringTransition(const ReactionMonitoringTransition &rhs)
copy constructor
std::bitset< 3 > transition_flags_
Definition ReactionMonitoringTransition.h:329
std::vector< Product > intermediate_products_
Intermediate product ion information of the transition when using MS3 or above (optional)
Definition ReactionMonitoringTransition.h:319
TargetedExperimentHelper::TraMLProduct Product
Definition ReactionMonitoringTransition.h:40
double library_intensity_
Intensity of the product (q3) ion (stored in CV Term 1001226 inside the <Transition> tag)
Definition ReactionMonitoringTransition.h:292
TargetedExperimentHelper::RetentionTime RetentionTime
Definition ReactionMonitoringTransition.h:39
RetentionTime rts
Information about predicted or calibrated retention time (optional)
Definition ReactionMonitoringTransition.h:322
A more convenient string class.
Definition String.h:34
This class stores a retention time structure that is used in TargetedExperiment (representing a TraML...
Definition TargetedExperimentHelper.h:101
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
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.
Comparator by name.
Definition ReactionMonitoringTransition.h:272
bool operator()(ReactionMonitoringTransition const &left, ReactionMonitoringTransition const &right) const
Comparator by Product ion MZ.
Definition ReactionMonitoringTransition.h:260
bool operator()(ReactionMonitoringTransition const &left, ReactionMonitoringTransition const &right) const
Definition TargetedExperimentHelper.h:41
Definition TargetedExperimentHelper.h:455
Represents a product ion.
Definition TargetedExperimentHelper.h:548
std::size_t operator()(const OpenMS::ReactionMonitoringTransition &rmt) const noexcept
Definition ReactionMonitoringTransition.h:340