OpenMS  3.0.0
MassExplainer.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-2022.
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 
38 
39 #include <OpenMS/CONCEPT/Types.h>
40 
42 #include <OpenMS/OpenMSConfig.h>
43 
44 namespace OpenMS
45 {
46  class Compomer;
47 
54  class OPENMS_DLLAPI MassExplainer
55  {
56 
57 public:
58 
59  typedef Adduct::AdductsType AdductsType; //vector<Adduct>
60  typedef std::vector<Compomer>::const_iterator CompomerIterator;
61 
63 
64  MassExplainer();
66 
68  MassExplainer(AdductsType adduct_base);
69 
71  MassExplainer(Int q_min, Int q_max, Int max_span, double thresh_logp);
72 
74  MassExplainer(AdductsType adduct_base, Int q_min, Int q_max, Int max_span, double thresh_logp, Size max_neutrals);
75 
76 
77 private:
80  void init_(bool init_thresh_p);
81 public:
83  MassExplainer& operator=(const MassExplainer& rhs);
84 
86  virtual ~MassExplainer();
88 
89 
91  void compute();
92 
93 
94  //@name Accessors
96 
98  void setAdductBase(AdductsType adduct_base);
100  AdductsType getAdductBase() const;
101 
103  const Compomer& getCompomerById(Size id) const;
105 
106 
114  SignedSize query(const Int net_charge,
115  const float mass_to_explain,
116  const float mass_delta,
117  const float thresh_log_p,
118  std::vector<Compomer>::const_iterator& firstExplanation,
119  std::vector<Compomer>::const_iterator& lastExplanation) const;
120 protected:
121 
123  bool compomerValid_(const Compomer& cmp) const;
124 
126  Adduct createAdduct_(const String& formula, const Int charge, const double p) const;
127 
129  std::vector<Compomer> explanations_;
139  double thresh_p_;
142 
143  };
144 
145 
146 } // namespace OpenMS
147 
OpenMS::Adduct::AdductsType
std::vector< Adduct > AdductsType
Definition: Adduct.h:48
Types.h
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::MassExplainer::q_min_
Int q_min_
minimal expected charge
Definition: MassExplainer.h:133
OpenMS::Compomer
Holds information on an edge connecting two features from a (putative) charge ladder.
Definition: Compomer.h:58
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::MassExplainer
computes empirical formulas for given mass differences using a set of allowed elements
Definition: MassExplainer.h:54
OpenMS::MassExplainer::max_span_
Int max_span_
maximal span (in terms of charge) for co-features, e.g. a cluster with q={3,6} has span=4
Definition: MassExplainer.h:137
OpenMS::MassExplainer::CompomerIterator
std::vector< Compomer >::const_iterator CompomerIterator
Definition: MassExplainer.h:60
OpenMS::MassExplainer::max_neutrals_
Size max_neutrals_
Maximum number of neutral(q=0) adducts.
Definition: MassExplainer.h:141
OpenMS::MassExplainer::explanations_
std::vector< Compomer > explanations_
store possible explanations (as formula) for a certain ChargeDifference and MassDifference
Definition: MassExplainer.h:129
OpenMS::MassExplainer::AdductsType
Adduct::AdductsType AdductsType
Definition: MassExplainer.h:59
OpenMS::MassExplainer::thresh_p_
double thresh_p_
minimum required probability of a compound (all other compounds are discarded)
Definition: MassExplainer.h:139
OpenMS::MassExplainer::q_max_
Int q_max_
maximal expected charge
Definition: MassExplainer.h:135
OpenMS::Adduct
Definition: Adduct.h:44
OpenMS::SignedSize
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
String.h
Adduct.h
OpenMS::MassExplainer::adduct_base_
AdductsType adduct_base_
all allowed adducts, whose combination explains the mass difference
Definition: MassExplainer.h:131