Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_FILTERING_DATAREDUCTION_FEATUREFINDINGMETABO_H
00036 #define OPENMS_FILTERING_DATAREDUCTION_FEATUREFINDINGMETABO_H
00037
00038 #include <OpenMS/KERNEL/MassTrace.h>
00039 #include <OpenMS/KERNEL/FeatureMap.h>
00040 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
00041 #include <OpenMS/CONCEPT/ProgressLogger.h>
00042
00043 #include <vector>
00044 #include <svm.h>
00045
00046 namespace OpenMS
00047 {
00065 class OPENMS_DLLAPI CmpMassTraceByMZ
00066 {
00067 public:
00068
00069 bool operator()(MassTrace x, MassTrace y) const
00070 {
00071 return x.getCentroidMZ() < y.getCentroidMZ();
00072 }
00073
00074 };
00075
00076
00077 class OPENMS_DLLAPI FeatureHypothesis
00078 {
00079 public:
00081 FeatureHypothesis();
00082
00084 ~FeatureHypothesis();
00085
00087 FeatureHypothesis(const FeatureHypothesis &);
00088
00090 FeatureHypothesis & operator=(const FeatureHypothesis & rhs);
00091
00092
00093
00094 Size getSize() const
00095 {
00096 return iso_pattern_.size();
00097 }
00098
00099 String getLabel()
00100 {
00101 String label;
00102
00103 if (iso_pattern_.size() > 0)
00104 {
00105 label = iso_pattern_[0]->getLabel();
00106 }
00107
00108 for (Size i = 1; i < iso_pattern_.size(); ++i)
00109 {
00110 String tmp_str = "_" + iso_pattern_[i]->getLabel();
00111 label += tmp_str;
00112 }
00113
00114 return label;
00115 }
00116
00117 std::vector<String> getLabels()
00118 {
00119 std::vector<String> tmp_labels;
00120
00121 for (Size i = 0; i < iso_pattern_.size(); ++i)
00122 {
00123 tmp_labels.push_back(iso_pattern_[i]->getLabel());
00124 }
00125
00126 return tmp_labels;
00127 }
00128
00129 DoubleReal getScore()
00130 {
00131 return feat_score_;
00132 }
00133
00134 void setScore(const DoubleReal & score)
00135 {
00136 feat_score_ = score;
00137 }
00138
00139 SignedSize getCharge()
00140 {
00141 return charge_;
00142 }
00143
00144 void setCharge(const SignedSize & ch)
00145 {
00146 charge_ = ch;
00147 }
00148
00149 std::vector<DoubleReal> getAllIntensities(bool smoothed = false)
00150 {
00151 std::vector<DoubleReal> tmp;
00152
00153 for (Size i = 0; i < iso_pattern_.size(); ++i)
00154 {
00155 tmp.push_back(iso_pattern_[i]->getIntensity(smoothed));
00156 }
00157
00158 return tmp;
00159 }
00160
00161 DoubleReal getCentroidMZ()
00162 {
00163 if (iso_pattern_.empty())
00164 {
00165 throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "FeatureHypothesis is empty, no centroid MZ!", String(iso_pattern_.size()));
00166 }
00167
00168 return iso_pattern_[0]->getCentroidMZ();
00169 }
00170
00171 DoubleReal getCentroidRT()
00172 {
00173 if (iso_pattern_.empty())
00174 {
00175 throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "FeatureHypothesis is empty, no centroid RT!", String(iso_pattern_.size()));
00176 }
00177
00178
00179
00180 return iso_pattern_[0]->getCentroidRT();
00181 }
00182
00183 DoubleReal getFWHM(bool use_smoothed_ints = false)
00184 {
00185 if (iso_pattern_.empty())
00186 {
00187 return 0.0;
00188 }
00189
00190 return iso_pattern_[0]->estimateFWHM(use_smoothed_ints);
00191 }
00192
00194 void addMassTrace(MassTrace &);
00195 DoubleReal getMonoisotopicFeatureIntensity(bool);
00196 DoubleReal getSummedFeatureIntensity(bool);
00197
00198
00199 Size getNumFeatPoints() const;
00200 std::vector<ConvexHull2D> getConvexHulls() const;
00201
00202 private:
00203
00204 std::vector<MassTrace *> iso_pattern_;
00205 DoubleReal feat_score_;
00206
00207 SignedSize charge_;
00208
00209 };
00210
00211
00212 class OPENMS_DLLAPI CmpHypothesesByScore
00213 {
00214 public:
00215
00216 bool operator()(FeatureHypothesis x, FeatureHypothesis y) const
00217 {
00218 return x.getScore() > y.getScore();
00219 }
00220
00221 };
00222
00223
00224
00225 class OPENMS_DLLAPI FeatureFindingMetabo :
00226 public DefaultParamHandler,
00227 public ProgressLogger
00228 {
00229 public:
00231 FeatureFindingMetabo();
00232
00234 virtual ~FeatureFindingMetabo();
00235
00236
00238 void run(std::vector<MassTrace> &, FeatureMap<> &);
00239
00240
00241 protected:
00242 virtual void updateMembers_();
00243
00244
00245 private:
00247 DoubleReal computeOLSCoeff_(const std::vector<DoubleReal> &, const std::vector<DoubleReal> &);
00248 DoubleReal computeCosineSim_(const std::vector<DoubleReal> &, const std::vector<DoubleReal> &);
00249
00250 svm_model * isotope_filt_svm_;
00251 std::vector<DoubleReal> svm_feat_centers_;
00252 std::vector<DoubleReal> svm_feat_scales_;
00253 bool isLegalIsotopePattern_(FeatureHypothesis &);
00254 bool isLegalIsotopePattern2_(FeatureHypothesis &);
00255
00256
00257 void loadIsotopeModel_(const String&);
00258
00259 DoubleReal total_intensity_;
00260
00261 DoubleReal scoreMZ_(const MassTrace &, const MassTrace &, Size, Size);
00262 DoubleReal scoreRT_(const MassTrace &, const MassTrace &);
00263
00264 DoubleReal computeAveragineSimScore_(const std::vector<DoubleReal> &, const DoubleReal &);
00265
00266
00267
00268 void findLocalFeatures_(std::vector<MassTrace *> &, std::vector<FeatureHypothesis> &);
00269
00270
00272 DoubleReal local_rt_range_;
00273 DoubleReal local_mz_range_;
00274 Size charge_lower_bound_;
00275 Size charge_upper_bound_;
00276
00277 DoubleReal chrom_fwhm_;
00278
00279 bool report_summed_ints_;
00280 bool disable_isotope_filtering_;
00281 String isotope_model_;
00282 bool use_smoothed_intensities_;
00283
00284 };
00285
00286
00287 }
00288
00289
00290
00291
00292 #endif // OPENMS_FILTERING_DATAREDUCTION_FEATUREFINDINGMETABO_H