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-2015.
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 
99  String getLabel() const
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() const
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 
129  double getScore() const
130  {
131  return feat_score_;
132  }
133 
134  void setScore(const double & 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<double> getAllIntensities(bool smoothed = false) const
150  {
151  std::vector<double> 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 
161  double getCentroidMZ() const
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 
171  double getCentroidRT() const
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  return iso_pattern_[0]->getCentroidRT();
178  }
179 
180  double getFWHM() const
181  {
182  if (iso_pattern_.empty())
183  {
184  return 0.0;
185  }
186  return iso_pattern_[0]->getFWHM();
187  }
188 
190  void addMassTrace(MassTrace &);
191  double getMonoisotopicFeatureIntensity(bool) const;
192  double getSummedFeatureIntensity(bool) const;
193 
194  Size getNumFeatPoints() const;
195  std::vector<ConvexHull2D> getConvexHulls() const;
196 
197 private:
198  // pointers of MassTraces contained in isotopic pattern
199  std::vector<const MassTrace *> iso_pattern_;
200  double feat_score_;
201 
203 
204 };
205 
206 
207 class OPENMS_DLLAPI CmpHypothesesByScore
208 {
209 public:
210 
212  {
213  return x.getScore() > y.getScore();
214  }
215 
216 };
217 
218 
219 
220 class OPENMS_DLLAPI FeatureFindingMetabo :
221  public DefaultParamHandler,
222  public ProgressLogger
223 {
224 public:
227 
229  virtual ~FeatureFindingMetabo();
230 
231 
233  void run(std::vector<MassTrace> &, FeatureMap &);
234 
235 
236 protected:
237  virtual void updateMembers_();
238 
239 
240 private:
242  double computeOLSCoeff_(const std::vector<double> &, const std::vector<double> &);
243  double computeCosineSim_(const std::vector<double> &, const std::vector<double> &);
244 
245  svm_model * isotope_filt_svm_;
246  std::vector<double> svm_feat_centers_;
247  std::vector<double> svm_feat_scales_;
248  bool isLegalIsotopePattern_(FeatureHypothesis &);
249  bool isLegalIsotopePattern2_(FeatureHypothesis &);
250 
251  //bool isLegalAveraginePattern(FeatureHypothesis&);
252  void loadIsotopeModel_(const String&);
253 
255 
256  double scoreMZ_(const MassTrace &, const MassTrace &, Size, Size);
257  double scoreMZ2_(const MassTrace &, const MassTrace &, Size, Size);
258  double scoreRT_(const MassTrace &, const MassTrace &);
259 
260  double computeAveragineSimScore_(const std::vector<double> &, const double &);
261 
262  // double scoreTraceSim_(MassTrace, MassTrace);
263  // double scoreIntRatio_(double, double, Size);
264  void findLocalFeatures_(std::vector<MassTrace *> &, std::vector<FeatureHypothesis> &);
265 
266 
272  //double mass_error_ppm_;
273  double chrom_fwhm_;
274 
280 
281 };
282 
283 
284 }
285 
286 
287 
288 
289 #endif // OPENMS_FILTERING_DATAREDUCTION_FEATUREFINDINGMETABO_H
A more convenient string class.
Definition: String.h:57
String metabo_iso_noisemodel_
Definition: FeatureFindingMetabo.h:278
Definition: FeatureFindingMetabo.h:207
bool disable_isotope_filtering_
Definition: FeatureFindingMetabo.h:276
double local_mz_range_
Definition: FeatureFindingMetabo.h:269
double getFWHM() const
Definition: FeatureFindingMetabo.h:180
A container for features.
Definition: FeatureMap.h:93
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:128
bool operator()(FeatureHypothesis x, FeatureHypothesis y) const
Definition: FeatureFindingMetabo.h:211
double getScore() const
Definition: FeatureFindingMetabo.h:129
SignedSize getCharge() const
Definition: FeatureFindingMetabo.h:139
bool use_smoothed_intensities_
Definition: FeatureFindingMetabo.h:279
Definition: FeatureFindingMetabo.h:77
double local_rt_range_
parameter stuff
Definition: FeatureFindingMetabo.h:268
double chrom_fwhm_
Definition: FeatureFindingMetabo.h:273
double getCentroidMZ() const
Returns the centroid m/z.
Definition: MassTrace.h:158
void setCharge(const SignedSize &ch)
Definition: FeatureFindingMetabo.h:144
double getCentroidRT() const
Definition: FeatureFindingMetabo.h:171
std::vector< String > getLabels() const
Definition: FeatureFindingMetabo.h:117
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
std::vector< const MassTrace * > iso_pattern_
Definition: FeatureFindingMetabo.h:199
void setScore(const double &score)
Definition: FeatureFindingMetabo.h:134
Size charge_upper_bound_
Definition: FeatureFindingMetabo.h:271
Size charge_lower_bound_
Definition: FeatureFindingMetabo.h:270
String isotope_model_
Definition: FeatureFindingMetabo.h:277
String getLabel() const
Definition: FeatureFindingMetabo.h:99
SignedSize charge_
Definition: FeatureFindingMetabo.h:202
Invalid value exception.
Definition: Exception.h:336
double feat_score_
Definition: FeatureFindingMetabo.h:200
bool operator()(MassTrace x, MassTrace y) const
Definition: FeatureFindingMetabo.h:69
bool report_summed_ints_
Definition: FeatureFindingMetabo.h:275
std::vector< double > svm_feat_centers_
Definition: FeatureFindingMetabo.h:246
double getCentroidMZ() const
Definition: FeatureFindingMetabo.h:161
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
double total_intensity_
Definition: FeatureFindingMetabo.h:254
Size getSize() const
Definition: FeatureFindingMetabo.h:94
svm_model * isotope_filt_svm_
Definition: FeatureFindingMetabo.h:245
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
std::vector< double > getAllIntensities(bool smoothed=false) const
Definition: FeatureFindingMetabo.h:149
std::vector< double > svm_feat_scales_
Definition: FeatureFindingMetabo.h:247
A container type that gathers peaks similar in m/z and moving along retention time.
Definition: MassTrace.h:59
Definition: FeatureFindingMetabo.h:220

OpenMS / TOPP release 2.0.0 Documentation generated on Wed Mar 30 2016 16:18:39 using doxygen 1.8.5