Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
FeatureFindingMetabo.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-2016.
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: Erhan Kenar $
32 // $Authors: Erhan Kenar, Holger Franken $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_FILTERING_DATAREDUCTION_FEATUREFINDINGMETABO_H
36 #define OPENMS_FILTERING_DATAREDUCTION_FEATUREFINDINGMETABO_H
37 
42 
43 #include <vector>
44 #include <svm.h>
45 
46 namespace OpenMS
47 {
48 
57  class OPENMS_DLLAPI FeatureHypothesis
58  {
59 public:
62 
65 
68 
70  FeatureHypothesis& operator=(const FeatureHypothesis& rhs);
71 
72  // getter & setter
73  Size getSize() const
74  {
75  return iso_pattern_.size();
76  }
77 
78  String getLabel() const
79  {
80  String label;
81 
82  if (iso_pattern_.size() > 0)
83  {
84  label = iso_pattern_[0]->getLabel();
85  }
86 
87  for (Size i = 1; i < iso_pattern_.size(); ++i)
88  {
89  String tmp_str = "_" + iso_pattern_[i]->getLabel();
90  label += tmp_str;
91  }
92 
93  return label;
94  }
95 
96  std::vector<String> getLabels() const
97  {
98  std::vector<String> tmp_labels;
99 
100  for (Size i = 0; i < iso_pattern_.size(); ++i)
101  {
102  tmp_labels.push_back(iso_pattern_[i]->getLabel());
103  }
104 
105  return tmp_labels;
106  }
107 
108  double getScore() const
109  {
110  return feat_score_;
111  }
112 
113  void setScore(const double& score)
114  {
115  feat_score_ = score;
116  }
117 
119  {
120  return charge_;
121  }
122 
123  void setCharge(const SignedSize& ch)
124  {
125  charge_ = ch;
126  }
127 
128  std::vector<double> getAllIntensities(bool smoothed = false) const
129  {
130  std::vector<double> tmp;
131  for (Size i = 0; i < iso_pattern_.size(); ++i)
132  {
133  tmp.push_back(iso_pattern_[i]->getIntensity(smoothed));
134  }
135  return tmp;
136  }
137 
138  double getCentroidMZ() const
139  {
140  if (iso_pattern_.empty())
141  {
142  throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__,
143  "FeatureHypothesis is empty, no centroid MZ!", String(iso_pattern_.size()));
144  }
145  return iso_pattern_[0]->getCentroidMZ();
146  }
147 
148  double getCentroidRT() const
149  {
150  if (iso_pattern_.empty())
151  {
152  throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__,
153  "FeatureHypothesis is empty, no centroid RT!", String(iso_pattern_.size()));
154  }
155  return iso_pattern_[0]->getCentroidRT();
156  }
157 
158  double getFWHM() const
159  {
160  if (iso_pattern_.empty())
161  {
162  return 0.0;
163  }
164  return iso_pattern_[0]->getFWHM();
165  }
166 
168  void addMassTrace(const MassTrace&);
169  double getMonoisotopicFeatureIntensity(bool) const;
170  double getSummedFeatureIntensity(bool) const;
171 
172  Size getNumFeatPoints() const;
173  std::vector<ConvexHull2D> getConvexHulls() const;
174 
175 private:
176 
177  // pointers of MassTraces contained in isotopic pattern
178  std::vector<const MassTrace*> iso_pattern_;
179 
180  double feat_score_;
181 
183  };
184 
185  class OPENMS_DLLAPI CmpMassTraceByMZ
186  {
187 public:
188 
189  bool operator()(MassTrace x, MassTrace y) const
190  {
191  return x.getCentroidMZ() < y.getCentroidMZ();
192  }
193 
194  };
195 
196  class OPENMS_DLLAPI CmpHypothesesByScore
197  {
198 public:
199 
201  {
202  return x.getScore() > y.getScore();
203  }
204 
205  };
206 
232  class OPENMS_DLLAPI FeatureFindingMetabo :
233  public DefaultParamHandler,
234  public ProgressLogger
235  {
236 public:
239 
241  virtual ~FeatureFindingMetabo();
242 
244  void run(std::vector<MassTrace>&, FeatureMap&);
245 
246 protected:
247  virtual void updateMembers_();
248 
249 private:
251 
260  double computeCosineSim_(const std::vector<double>&, const std::vector<double>&) const;
261 
264  double computeOLSCoeff_(const std::vector<double>&, const std::vector<double>&) const;
265 
268  bool isLegalIsotopePattern_(const FeatureHypothesis &) const;
269 
280  bool isLegalIsotopePattern2_(const FeatureHypothesis &) const;
281 
282  void loadIsotopeModel_(const String&);
283 
304  double scoreMZ_(const MassTrace &, const MassTrace &, Size isotopic_position, Size charge) const;
305 
308  double scoreMZ2_(const MassTrace &, const MassTrace &, Size isotopic_position, Size charge) const;
309 
321  double scoreRT_(const MassTrace&, const MassTrace&) const;
322 
329  double computeAveragineSimScore_(const std::vector<double>& intensities, const double& molecular_weight);
330 
339  void findLocalFeatures_(const std::vector<const MassTrace*>& candidates, std::vector<FeatureHypothesis>& output_hypotheses);
340 
342  svm_model* isotope_filt_svm_;
343  std::vector<double> svm_feat_centers_;
344  std::vector<double> svm_feat_scales_;
345 
347 
353  //double mass_error_ppm_;
354  double chrom_fwhm_;
355 
362 
363  };
364 
365 }
366 
367 #endif // OPENMS_FILTERING_DATAREDUCTION_FEATUREFINDINGMETABO_H
A more convenient string class.
Definition: String.h:57
String metabo_iso_noisemodel_
Definition: FeatureFindingMetabo.h:360
Definition: FeatureFindingMetabo.h:196
bool disable_isotope_filtering_
Definition: FeatureFindingMetabo.h:358
double local_mz_range_
Definition: FeatureFindingMetabo.h:350
double getFWHM() const
Definition: FeatureFindingMetabo.h:158
A container for features.
Definition: FeatureMap.h:94
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:135
std::vector< const MassTrace * > iso_pattern_
Definition: FeatureFindingMetabo.h:178
bool operator()(FeatureHypothesis x, FeatureHypothesis y) const
Definition: FeatureFindingMetabo.h:200
double getScore() const
Definition: FeatureFindingMetabo.h:108
SignedSize getCharge() const
Definition: FeatureFindingMetabo.h:118
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
bool use_smoothed_intensities_
Definition: FeatureFindingMetabo.h:361
Internal structure used in FeatureFindingMetabo that keeps track of a feature hypothesis (isotope gro...
Definition: FeatureFindingMetabo.h:57
double local_rt_range_
parameter stuff
Definition: FeatureFindingMetabo.h:349
double chrom_fwhm_
Definition: FeatureFindingMetabo.h:354
double getCentroidMZ() const
Returns the centroid m/z.
Definition: MassTrace.h:179
void setCharge(const SignedSize &ch)
Definition: FeatureFindingMetabo.h:123
bool enable_RT_filtering_
Definition: FeatureFindingMetabo.h:357
double getCentroidRT() const
Definition: FeatureFindingMetabo.h:148
std::vector< String > getLabels() const
Definition: FeatureFindingMetabo.h:96
Definition: FeatureFindingMetabo.h:185
void setScore(const double &score)
Definition: FeatureFindingMetabo.h:113
Size charge_upper_bound_
Definition: FeatureFindingMetabo.h:352
Size charge_lower_bound_
Definition: FeatureFindingMetabo.h:351
String isotope_model_
Definition: FeatureFindingMetabo.h:359
String getLabel() const
Definition: FeatureFindingMetabo.h:78
SignedSize charge_
Definition: FeatureFindingMetabo.h:182
Invalid value exception.
Definition: Exception.h:336
double feat_score_
Definition: FeatureFindingMetabo.h:180
bool operator()(MassTrace x, MassTrace y) const
Definition: FeatureFindingMetabo.h:189
bool report_summed_ints_
Definition: FeatureFindingMetabo.h:356
std::vector< double > svm_feat_centers_
Definition: FeatureFindingMetabo.h:343
double getCentroidMZ() const
Definition: FeatureFindingMetabo.h:138
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
double total_intensity_
Definition: FeatureFindingMetabo.h:346
Size getSize() const
Definition: FeatureFindingMetabo.h:73
svm_model * isotope_filt_svm_
SVM parameters.
Definition: FeatureFindingMetabo.h:342
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
std::vector< double > getAllIntensities(bool smoothed=false) const
Definition: FeatureFindingMetabo.h:128
std::vector< double > svm_feat_scales_
Definition: FeatureFindingMetabo.h:344
A container type that gathers peaks similar in m/z and moving along retention time.
Definition: MassTrace.h:62
Method for the assembly of mass traces belonging to the same isotope pattern, i.e., that are compatible in retention times, mass-to-charge ratios, and isotope abundances.
Definition: FeatureFindingMetabo.h:232

OpenMS / TOPP release 2.0.0 Documentation generated on Tue Jan 31 2017 06:39:44 using doxygen 1.8.8