OpenMS
MassExplainer.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: Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
12 
13 #include <OpenMS/CONCEPT/Types.h>
14 
16 #include <OpenMS/OpenMSConfig.h>
17 
18 namespace OpenMS
19 {
20  class Compomer;
21 
28  class OPENMS_DLLAPI MassExplainer
29  {
30 
31 public:
32 
33  typedef Adduct::AdductsType AdductsType; //vector<Adduct>
34  typedef std::vector<Compomer>::const_iterator CompomerIterator;
35 
37 
38  MassExplainer();
40 
42  MassExplainer(AdductsType adduct_base);
43 
45  MassExplainer(Int q_min, Int q_max, Int max_span, double thresh_logp);
46 
48  MassExplainer(AdductsType adduct_base, Int q_min, Int q_max, Int max_span, double thresh_logp, Size max_neutrals);
49 
50 
51 private:
54  void init_(bool init_thresh_p);
55 public:
58 
60  virtual ~MassExplainer();
62 
63 
65  void compute();
66 
67 
68  //@name Accessors
70 
72  void setAdductBase(AdductsType adduct_base);
75 
77  const Compomer& getCompomerById(Size id) const;
79 
80 
88  SignedSize query(const Int net_charge,
89  const float mass_to_explain,
90  const float mass_delta,
91  const float thresh_log_p,
92  std::vector<Compomer>::const_iterator& firstExplanation,
93  std::vector<Compomer>::const_iterator& lastExplanation) const;
94 protected:
95 
97  bool compomerValid_(const Compomer& cmp) const;
98 
100  Adduct createAdduct_(const String& formula, const Int charge, const double p) const;
101 
103  std::vector<Compomer> explanations_;
113  double thresh_p_;
116 
117  };
118 
119 
120 } // namespace OpenMS
121 
Definition: Adduct.h:19
std::vector< Adduct > AdductsType
Definition: Adduct.h:22
Holds information on an edge connecting two features from a (putative) charge ladder.
Definition: Compomer.h:33
computes empirical formulas for given mass differences using a set of allowed elements
Definition: MassExplainer.h:29
MassExplainer(AdductsType adduct_base)
Constructor.
Adduct createAdduct_(const String &formula, const Int charge, const double p) const
create a proper adduct from formula and charge and probability
Int q_max_
maximal expected charge
Definition: MassExplainer.h:109
MassExplainer & operator=(const MassExplainer &rhs)
Assignment operator.
void compute()
fill map with possible mass-differences along with their explanation
Int q_min_
minimal expected charge
Definition: MassExplainer.h:107
SignedSize query(const Int net_charge, const float mass_to_explain, const float mass_delta, const float thresh_log_p, std::vector< Compomer >::const_iterator &firstExplanation, std::vector< Compomer >::const_iterator &lastExplanation) const
const Compomer & getCompomerById(Size id) const
return a compomer by its Id (useful after a query() ).
AdductsType getAdductBase() const
Returns the set of adducts.
AdductsType adduct_base_
all allowed adducts, whose combination explains the mass difference
Definition: MassExplainer.h:105
void init_(bool init_thresh_p)
MassExplainer(Int q_min, Int q_max, Int max_span, double thresh_logp)
Constructor.
MassExplainer(AdductsType adduct_base, Int q_min, Int q_max, Int max_span, double thresh_logp, Size max_neutrals)
Constructor.
void setAdductBase(AdductsType adduct_base)
Sets the set of possible adducts.
Size max_neutrals_
Maximum number of neutral(q=0) adducts.
Definition: MassExplainer.h:115
double thresh_p_
minimum required probability of a compound (all other compounds are discarded)
Definition: MassExplainer.h:113
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:111
virtual ~MassExplainer()
Destructor.
std::vector< Compomer > explanations_
store possible explanations (as formula) for a certain ChargeDifference and MassDifference
Definition: MassExplainer.h:103
bool compomerValid_(const Compomer &cmp) const
check if the generated compomer is valid judged by its probability, charges etc
Adduct::AdductsType AdductsType
Definition: MassExplainer.h:33
std::vector< Compomer >::const_iterator CompomerIterator
Definition: MassExplainer.h:34
A more convenient string class.
Definition: String.h:34
int Int
Signed integer type.
Definition: Types.h:76
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:108
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22