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-2013.
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 {
65 class OPENMS_DLLAPI CmpMassTraceByMZ
66 {
67 public:
68 
69  bool operator()(MassTrace x, MassTrace y) const
70  {
71  return x.getCentroidMZ() < y.getCentroidMZ();
72  }
73 
74 };
75 
76 
77 class OPENMS_DLLAPI FeatureHypothesis
78 {
79 public:
82 
85 
88 
90  FeatureHypothesis & operator=(const FeatureHypothesis & rhs);
91 
92 
93  // getter & setter
94  Size getSize() const
95  {
96  return iso_pattern_.size();
97  }
98 
100  {
101  String label;
102 
103  if (iso_pattern_.size() > 0)
104  {
105  label = iso_pattern_[0]->getLabel();
106  }
107 
108  for (Size i = 1; i < iso_pattern_.size(); ++i)
109  {
110  String tmp_str = "_" + iso_pattern_[i]->getLabel();
111  label += tmp_str;
112  }
113 
114  return label;
115  }
116 
117  std::vector<String> getLabels()
118  {
119  std::vector<String> tmp_labels;
120 
121  for (Size i = 0; i < iso_pattern_.size(); ++i)
122  {
123  tmp_labels.push_back(iso_pattern_[i]->getLabel());
124  }
125 
126  return tmp_labels;
127  }
128 
130  {
131  return feat_score_;
132  }
133 
134  void setScore(const DoubleReal & score)
135  {
136  feat_score_ = score;
137  }
138 
140  {
141  return charge_;
142  }
143 
144  void setCharge(const SignedSize & ch)
145  {
146  charge_ = ch;
147  }
148 
149  std::vector<DoubleReal> getAllIntensities(bool smoothed = false)
150  {
151  std::vector<DoubleReal> tmp;
152 
153  for (Size i = 0; i < iso_pattern_.size(); ++i)
154  {
155  tmp.push_back(iso_pattern_[i]->getIntensity(smoothed));
156  }
157 
158  return tmp;
159  }
160 
162  {
163  if (iso_pattern_.empty())
164  {
165  throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "FeatureHypothesis is empty, no centroid MZ!", String(iso_pattern_.size()));
166  }
167 
168  return iso_pattern_[0]->getCentroidMZ();
169  }
170 
172  {
173  if (iso_pattern_.empty())
174  {
175  throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "FeatureHypothesis is empty, no centroid RT!", String(iso_pattern_.size()));
176  }
177 
178  // iso_pattern_[0]->updateWeightedMeanRT();
179 
180  return iso_pattern_[0]->getCentroidRT();
181  }
182 
183  DoubleReal getFWHM(bool use_smoothed_ints = false)
184  {
185  if (iso_pattern_.empty())
186  {
187  return 0.0;
188  }
189 
190  return iso_pattern_[0]->estimateFWHM(use_smoothed_ints);
191  }
192 
194  void addMassTrace(MassTrace &);
195  DoubleReal getMonoisotopicFeatureIntensity(bool);
196  DoubleReal getSummedFeatureIntensity(bool);
197 
198 
199  Size getNumFeatPoints() const;
200  std::vector<ConvexHull2D> getConvexHulls() const;
201 
202 private:
203  // pointers of MassTraces contained in isotopic pattern
204  std::vector<MassTrace *> iso_pattern_;
206 
208 
209 };
210 
211 
212 class OPENMS_DLLAPI CmpHypothesesByScore
213 {
214 public:
215 
217  {
218  return x.getScore() > y.getScore();
219  }
220 
221 };
222 
223 
224 
225 class OPENMS_DLLAPI FeatureFindingMetabo :
226  public DefaultParamHandler,
227  public ProgressLogger
228 {
229 public:
232 
234  virtual ~FeatureFindingMetabo();
235 
236 
238  void run(std::vector<MassTrace> &, FeatureMap<> &);
239 
240 
241 protected:
242  virtual void updateMembers_();
243 
244 
245 private:
247  DoubleReal computeOLSCoeff_(const std::vector<DoubleReal> &, const std::vector<DoubleReal> &);
248  DoubleReal computeCosineSim_(const std::vector<DoubleReal> &, const std::vector<DoubleReal> &);
249 
250  svm_model * isotope_filt_svm_;
251  std::vector<DoubleReal> svm_feat_centers_;
252  std::vector<DoubleReal> svm_feat_scales_;
253  bool isLegalIsotopePattern_(FeatureHypothesis &);
254  bool isLegalIsotopePattern2_(FeatureHypothesis &);
255 
256  //bool isLegalAveraginePattern(FeatureHypothesis&);
257  void loadIsotopeModel_(const String&);
258 
260 
261  DoubleReal scoreMZ_(const MassTrace &, const MassTrace &, Size, Size);
262  DoubleReal scoreMZ2_(const MassTrace &, const MassTrace &, Size, Size);
263  DoubleReal scoreRT_(const MassTrace &, const MassTrace &);
264 
265  DoubleReal computeAveragineSimScore_(const std::vector<DoubleReal> &, const DoubleReal &);
266 
267  // DoubleReal scoreTraceSim_(MassTrace, MassTrace);
268  // DoubleReal scoreIntRatio_(DoubleReal, DoubleReal, Size);
269  void findLocalFeatures_(std::vector<MassTrace *> &, std::vector<FeatureHypothesis> &);
270 
271 
277  //DoubleReal mass_error_ppm_;
279 
285 
286 };
287 
288 
289 }
290 
291 
292 
293 
294 #endif // OPENMS_FILTERING_DATAREDUCTION_FEATUREFINDINGMETABO_H
DoubleReal getFWHM(bool use_smoothed_ints=false)
Definition: FeatureFindingMetabo.h:183
DoubleReal chrom_fwhm_
Definition: FeatureFindingMetabo.h:278
A more convenient string class.
Definition: String.h:56
String metabo_iso_noisemodel_
Definition: FeatureFindingMetabo.h:283
Definition: FeatureFindingMetabo.h:212
bool disable_isotope_filtering_
Definition: FeatureFindingMetabo.h:281
DoubleReal getCentroidRT()
Definition: FeatureFindingMetabo.h:171
DoubleReal feat_score_
Definition: FeatureFindingMetabo.h:205
DoubleReal getScore()
Definition: FeatureFindingMetabo.h:129
std::vector< MassTrace * > iso_pattern_
Definition: FeatureFindingMetabo.h:204
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:151
bool operator()(FeatureHypothesis x, FeatureHypothesis y) const
Definition: FeatureFindingMetabo.h:216
bool use_smoothed_intensities_
Definition: FeatureFindingMetabo.h:284
std::vector< DoubleReal > svm_feat_scales_
Definition: FeatureFindingMetabo.h:252
Definition: FeatureFindingMetabo.h:77
void setScore(const DoubleReal &score)
Definition: FeatureFindingMetabo.h:134
String getLabel()
Definition: FeatureFindingMetabo.h:99
DoubleReal total_intensity_
Definition: FeatureFindingMetabo.h:259
std::vector< DoubleReal > getAllIntensities(bool smoothed=false)
Definition: FeatureFindingMetabo.h:149
SignedSize getCharge()
Definition: FeatureFindingMetabo.h:139
void setCharge(const SignedSize &ch)
Definition: FeatureFindingMetabo.h:144
DoubleReal getCentroidMZ()
Definition: FeatureFindingMetabo.h:161
std::vector< DoubleReal > svm_feat_centers_
Definition: FeatureFindingMetabo.h:251
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:65
Size charge_upper_bound_
Definition: FeatureFindingMetabo.h:276
Size charge_lower_bound_
Definition: FeatureFindingMetabo.h:275
String isotope_model_
Definition: FeatureFindingMetabo.h:282
SignedSize charge_
Definition: FeatureFindingMetabo.h:207
Invalid value exception.
Definition: Exception.h:336
DoubleReal getCentroidMZ()
Returns the centroid m/z.
Definition: MassTrace.h:157
bool operator()(MassTrace x, MassTrace y) const
Definition: FeatureFindingMetabo.h:69
bool report_summed_ints_
Definition: FeatureFindingMetabo.h:280
DoubleReal local_rt_range_
parameter stuff
Definition: FeatureFindingMetabo.h:273
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:144
Base class for all classes that want to report their progess.
Definition: ProgressLogger.h:56
DoubleReal local_mz_range_
Definition: FeatureFindingMetabo.h:274
Size getSize() const
Definition: FeatureFindingMetabo.h:94
svm_model * isotope_filt_svm_
Definition: FeatureFindingMetabo.h:250
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:90
A container type that gathers peaks similar in m/z and moving along retention time.
Definition: MassTrace.h:59
std::vector< String > getLabels()
Definition: FeatureFindingMetabo.h:117
Definition: FeatureFindingMetabo.h:225

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:13 using doxygen 1.8.5