Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

FeatureFindingMetabo.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: Erhan Kenar $
00032 // $Authors: Erhan Kenar, Holger Franken $
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     // getter & setter
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         // iso_pattern_[0]->updateWeightedMeanRT();
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     // pointers of MassTraces contained in isotopic pattern
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     //bool isLegalAveraginePattern(FeatureHypothesis&);
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     // DoubleReal scoreTraceSim_(MassTrace, MassTrace);
00267     // DoubleReal scoreIntRatio_(DoubleReal, DoubleReal, Size);
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     //DoubleReal mass_error_ppm_;
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

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:39 using doxygen 1.7.1