OpenMS
Compomer.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, 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: Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/CONCEPT/Types.h>
13 #include <OpenMS/OpenMSConfig.h>
14 
15 #include <map>
16 #include <vector>
17 
18 namespace OpenMS
19 {
20 
21  class Adduct;
22  class String;
23 
32  class OPENMS_DLLAPI Compomer
33  {
34 public:
36  enum SIDE {LEFT, RIGHT, BOTH};
37 
38  typedef std::map<String, Adduct> CompomerSide;
39  typedef std::vector<CompomerSide> CompomerComponents;
40 
43 
45  Compomer(Int net_charge, double mass, double log_p);
46 
48  Compomer(const Compomer& p);
49 
51  Compomer& operator=(const Compomer& source);
52 
54  void add(const Adduct& a, UInt side);
55 
62  bool isConflicting(const Compomer& cmp, UInt side_this, UInt side_other) const;
63 
65  void setID(const Size& id);
67  const Size& getID() const;
70 
72  const Int& getNetCharge() const;
73 
75  const double& getMass() const;
76 
78  const Int& getPositiveCharges() const;
79 
81  const Int& getNegativeCharges() const;
82 
84  const double& getLogP() const;
85 
87  const double& getRTShift() const;
88 
91 
95 
97  bool isSingleAdduct(Adduct& a, const UInt side) const;
98 
105  Compomer removeAdduct(const Adduct& a) const;
106 
113  Compomer removeAdduct(const Adduct& a, const UInt side) const;
114 
121  StringList getLabels(const UInt side) const;
122 
123 
125  void add(const CompomerSide& add_side, UInt side);
126 
128  friend OPENMS_DLLAPI bool operator<(const Compomer& c1, const Compomer& c2);
129 
131  friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Compomer& cmp);
132 
134  friend OPENMS_DLLAPI bool operator==(const Compomer& a, const Compomer& b);
135 
136 private:
137 
140  double mass_;
143  double log_p_;
144  double rt_shift_;
146 
147  }; // \Compomer
148 
149 } // namespace OpenMS
150 
Definition: Adduct.h:19
Holds information on an edge connecting two features from a (putative) charge ladder.
Definition: Compomer.h:33
Compomer & operator=(const Compomer &source)
Assignment Operator.
bool isConflicting(const Compomer &cmp, UInt side_this, UInt side_other) const
StringList getLabels(const UInt side) const
Returns the adduct labels from side (LEFT or RIGHT)
const CompomerComponents & getComponent() const
left and right adducts of this compomer
double mass_
net mass (right - left)
Definition: Compomer.h:140
std::map< String, Adduct > CompomerSide
adducts and their abundance etc
Definition: Compomer.h:38
double log_p_
log probability of compomer
Definition: Compomer.h:143
Compomer(const Compomer &p)
Copy C'tor.
const double & getLogP() const
return log probability
void add(const Adduct &a, UInt side)
Add a.amount of Adduct.
CompomerComponents cmp_
adducts of left and right side
Definition: Compomer.h:138
Int neg_charges_
net charges on the left
Definition: Compomer.h:142
Compomer removeAdduct(const Adduct &a) const
Remove all adducts of type a.
Compomer(Int net_charge, double mass, double log_p)
Constructor with net-charge and mass.
const double & getMass() const
mass of all contained adducts
String getAdductsAsString() const
get adducts with their abundance as compact string for both sides
const Int & getNegativeCharges() const
summed negative charges of contained adducts
friend bool operator==(const Compomer &a, const Compomer &b)
Comparator.
bool isSingleAdduct(Adduct &a, const UInt side) const
check if Compomer only contains a single adduct on side side
const Size & getID() const
return Id which allows unique identification of this compomer
Int pos_charges_
net charges on the right
Definition: Compomer.h:141
friend std::ostream & operator<<(std::ostream &os, const Compomer &cmp)
Print the contents of a Compomer to a stream.
double rt_shift_
expected net RT shift of compomer (-shift_leftside + shift_rightside)
Definition: Compomer.h:144
String getAdductsAsString(UInt side) const
Int net_charge_
net charge (right - left)
Definition: Compomer.h:139
void add(const CompomerSide &add_side, UInt side)
Adds add_side to this compomer.
const Int & getPositiveCharges() const
summed positive charges of contained adducts
Compomer removeAdduct(const Adduct &a, const UInt side) const
Remove all adducts of type a from side (LEFT or RIGHT)
const Int & getNetCharge() const
net charge of compomer (i.e. difference between left and right side of compomer)
std::vector< CompomerSide > CompomerComponents
container for the two sides [0]=left, [1]=right
Definition: Compomer.h:39
friend bool operator<(const Compomer &c1, const Compomer &c2)
Sort compomer by (in order of importance): net-charge, mass, probability.
void setID(const Size &id)
set an Id which allows unique identification of a compomer
Size id_
Definition: Compomer.h:145
SIDE
side of compomer (LEFT ^ subtract; RIGHT ^ add)
Definition: Compomer.h:36
Compomer()
Default Constructor.
const double & getRTShift() const
return log probability
A more convenient string class.
Definition: String.h:34
int Int
Signed integer type.
Definition: Types.h:72
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:44
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
@ BOTH
combine COMPACT and ONE_BY_ONE