OpenMS
Adduct.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Chris Bielow $
6 // $Authors: $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/OpenMSConfig.h>
12 #include <OpenMS/CONCEPT/Types.h>
14 
15 namespace OpenMS
16 {
17 
18  class OPENMS_DLLAPI Adduct
19  {
20 public:
21 
22  typedef std::vector<Adduct> AdductsType;
23 
25  Adduct();
26 
28  Adduct(Int charge);
29 
31  Adduct(Int charge, Int amount, double singleMass, const String& formula, double log_prob, double rt_shift, const String& label = "");
32 
34  Adduct operator*(const Int m) const;
36  Adduct operator+(const Adduct& rhs);
38  void operator+=(const Adduct& rhs);
39 
40 
42  friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Adduct& a);
43 
45  friend OPENMS_DLLAPI bool operator==(const Adduct& a, const Adduct& b);
46 
48  const Int& getCharge() const;
49 
50  void setCharge(const Int& charge);
51 
52  const Int& getAmount() const;
53  void setAmount(const Int& amount);
54 
55  const double& getSingleMass() const;
56  void setSingleMass(const double& singleMass);
57 
58  const double& getLogProb() const;
59  void setLogProb(const double& log_prob);
60 
61  const String& getFormula() const;
62  void setFormula(const String& formula);
63 
64  const double& getRTShift() const;
65  const String& getLabel() const;
66 
67  // convert a ion string to adduct string with charge information (eg. ion_string = "Na1", charge = "1" --> "[M+Na]+")
68  String toAdductString(const String& ion_string, const Int& charge);
69  //}
70 
71 private:
74  double singleMass_;
75  double log_prob_;
77  double rt_shift_;
79 
80  String checkFormula_(const String& formula);
81 
82  };
83 
84 } // namespace OpenMS
85 
86 
Definition: Adduct.h:19
void setLogProb(const double &log_prob)
String checkFormula_(const String &formula)
Adduct operator+(const Adduct &rhs)
Add two adducts amount if they are equal (defined by equal formula)
Adduct()
Default C'tor.
double log_prob_
log probability of observing a single entity of this adduct
Definition: Adduct.h:75
void setCharge(const Int &charge)
Adduct operator*(const Int m) const
Increase amount of this adduct by factor.
friend bool operator==(const Adduct &a, const Adduct &b)
Comparator.
String formula_
chemical formula (parsable by EmpiricalFormula)
Definition: Adduct.h:76
void setAmount(const Int &amount)
String toAdductString(const String &ion_string, const Int &charge)
void operator+=(const Adduct &rhs)
Add other adducts amount to *this (equal formula required!)
const double & getLogProb() const
Adduct(Int charge)
C'tor with initial charge.
String label_
Label for this adduct (can be used to indicate heavy labels)
Definition: Adduct.h:78
double rt_shift_
RT shift induced by a single entity of this adduct (this is for adducts attached prior to ESI,...
Definition: Adduct.h:77
const String & getLabel() const
std::vector< Adduct > AdductsType
Definition: Adduct.h:22
void setSingleMass(const double &singleMass)
const String & getFormula() const
Adduct(Int charge, Int amount, double singleMass, const String &formula, double log_prob, double rt_shift, const String &label="")
C'tor for all members.
void setFormula(const String &formula)
const double & getSingleMass() const
double singleMass_
mass of a single entity
Definition: Adduct.h:74
const Int & getAmount() const
const Int & getCharge() const
Int amount_
number of entities
Definition: Adduct.h:73
const double & getRTShift() const
Int charge_
usually +1
Definition: Adduct.h:72
friend std::ostream & operator<<(std::ostream &os, const Adduct &a)
Print the contents of an Adduct to a stream.
A more convenient string class.
Definition: String.h:34
int Int
Signed integer type.
Definition: Types.h:76
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22