OpenMS  2.7.0
Compomer.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/CONCEPT/Types.h>
39 #include <OpenMS/OpenMSConfig.h>
40 
41 #include <map>
42 #include <vector>
43 
44 namespace OpenMS
45 {
46 
47  class Adduct;
48  class String;
49 
58  class OPENMS_DLLAPI Compomer
59  {
60 public:
62  enum SIDE {LEFT, RIGHT, BOTH};
63 
64  typedef std::map<String, Adduct> CompomerSide;
65  typedef std::vector<CompomerSide> CompomerComponents;
66 
69 
71  Compomer(Int net_charge, double mass, double log_p);
72 
74  Compomer(const Compomer& p);
75 
77  Compomer& operator=(const Compomer& source);
78 
80  void add(const Adduct& a, UInt side);
81 
88  bool isConflicting(const Compomer& cmp, UInt side_this, UInt side_other) const;
89 
91  void setID(const Size& id);
93  const Size& getID() const;
96 
98  const Int& getNetCharge() const;
99 
101  const double& getMass() const;
102 
104  const Int& getPositiveCharges() const;
105 
107  const Int& getNegativeCharges() const;
108 
110  const double& getLogP() const;
111 
113  const double& getRTShift() const;
114 
117 
121 
123  bool isSingleAdduct(Adduct& a, const UInt side) const;
124 
131  Compomer removeAdduct(const Adduct& a) const;
132 
139  Compomer removeAdduct(const Adduct& a, const UInt side) const;
140 
147  StringList getLabels(const UInt side) const;
148 
149 
151  void add(const CompomerSide& add_side, UInt side);
152 
154  friend OPENMS_DLLAPI bool operator<(const Compomer& c1, const Compomer& c2);
155 
157  friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const Compomer& cmp);
158 
160  friend OPENMS_DLLAPI bool operator==(const Compomer& a, const Compomer& b);
161 
162 private:
163 
166  double mass_;
169  double log_p_;
170  double rt_shift_;
172 
173  }; // \Compomer
174 
175 } // namespace OpenMS
176 
Definition: Adduct.h:45
Holds information on an edge connecting two features from a (putative) charge ladder.
Definition: Compomer.h:59
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:166
std::map< String, Adduct > CompomerSide
adducts and their abundance etc
Definition: Compomer.h:64
double log_p_
log probability of compomer
Definition: Compomer.h:169
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:164
Int neg_charges_
net charges on the left
Definition: Compomer.h:168
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:167
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:170
String getAdductsAsString(UInt side) const
Int net_charge_
net charge (right - left)
Definition: Compomer.h:165
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:65
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:171
SIDE
side of compomer (LEFT ^ subtract; RIGHT ^ add)
Definition: Compomer.h:62
Compomer()
Default Constructor.
const double & getRTShift() const
return log probability
A more convenient string class.
Definition: String.h:61
int Int
Signed integer type.
Definition: Types.h:102
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47