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_TRANSFORMATIONS_FEATUREFINDER_FEATUREFINDERALGORITHMSIMPLE_H
00036 #define OPENMS_TRANSFORMATIONS_FEATUREFINDER_FEATUREFINDERALGORITHMSIMPLE_H
00037
00038 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/FeatureFinderAlgorithm.h>
00039
00040 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/SimpleSeeder.h>
00041 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/SimpleExtender.h>
00042 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/ModelFitter.h>
00043
00044 namespace OpenMS
00045 {
00061 template <class PeakType, class FeatureType>
00062 class FeatureFinderAlgorithmSimple :
00063 public FeatureFinderAlgorithm<PeakType, FeatureType>,
00064 public FeatureFinderDefs
00065 {
00066
00067 public:
00069 FeatureFinderAlgorithmSimple() :
00070 FeatureFinderAlgorithm<PeakType, FeatureType>()
00071 {
00072 this->defaults_ = getDefaultParameters();
00073 this->check_defaults_ = false;
00074 }
00075
00076 virtual Param getDefaultParameters() const
00077 {
00078 Param tmp;
00079
00080 SimpleSeeder<PeakType, FeatureType> seeder(this->map_, this->features_, this->ff_);
00081 tmp.insert("seeder:", seeder.getParameters());
00082 tmp.setSectionDescription("seeder", "Settings for the seeder (Determines potential feature regions)");
00083
00084 SimpleExtender<PeakType, FeatureType> extender(this->map_, this->features_, this->ff_);
00085 tmp.insert("extender:", extender.getParameters());
00086 tmp.setSectionDescription("extender", "Settings for the extender (Collects all peaks belonging to a feature)");
00087
00088 ModelFitter<PeakType, FeatureType> fitter(this->map_, this->features_, this->ff_);
00089 tmp.insert("fitter:", fitter.getParameters());
00090 tmp.setSectionDescription("fitter", "Settings for the modefitter (Fits a model to the data determinging the probapility that they represent a feature.)");
00091
00092 return tmp;
00093 }
00094
00095 virtual void run()
00096 {
00097 #ifdef DEBUG_FEATUREFINDER
00098 UInt seed_nr = 0;
00099 #endif
00100 SimpleSeeder<PeakType, FeatureType> seeder(this->map_, this->features_, this->ff_);
00101 seeder.setParameters(this->getParameters().copy("seeder:", true));
00102
00103 SimpleExtender<PeakType, FeatureType> extender(this->map_, this->features_, this->ff_);
00104 extender.setParameters(this->getParameters().copy("extender:", true));
00105
00106 ModelFitter<PeakType, FeatureType> fitter(this->map_, this->features_, this->ff_);
00107 Param params;
00108 params.setDefaults(this->getParameters().copy("fitter:", true));
00109 params.setValue("fit_algorithm", "simple");
00110 fitter.setParameters(params);
00111
00113 Summary summary;
00114
00115 try
00116 {
00117 for (;; )
00118 {
00119 #ifdef DEBUG_FEATUREFINDER
00120 std::cout << "===============================" << std::endl;
00121 std::cout << "### Seeder (seed # " << ++seed_nr << ")..." << std::endl;
00122 #endif
00123 IndexPair seed = seeder.nextSeed();
00124
00125 #ifdef DEBUG_FEATUREFINDER
00126 std::cout << "seed ... " << seed.first << " - " << seed.second << std::endl;
00127 std::cout << "### Extender..." << std::endl;
00128 #endif
00129 ChargedIndexSet index_set;
00130 index_set.insert(seed);
00131 ChargedIndexSet region;
00132 extender.extend(index_set, region);
00133
00134 #ifdef DEBUG_FEATUREFINDER
00135 std::cout << "### ModelFitter..." << std::endl;
00136 #endif
00137 try
00138 {
00139 this->features_->push_back(fitter.fit(region));
00140
00141
00142 {
00143 const Feature & f = this->features_->back();
00144
00145
00146 DoubleReal corr = f.getOverallQuality();
00147 summary.corr_mean += corr;
00148 if (corr < summary.corr_min) summary.corr_min = corr;
00149 if (corr > summary.corr_max) summary.corr_max = corr;
00150
00151
00152 UInt ch = f.getCharge();
00153 if (ch >= summary.charge.size())
00154 {
00155 summary.charge.resize(ch + 1);
00156 }
00157 summary.charge[ch]++;
00158
00159
00160 const Param & p = f.getModelDescription().getParam();
00161 ++summary.mz_model[p.getValue("MZ")];
00162
00163
00164 if (p.exists("MZ:isotope:stdev") && p.getValue("MZ:isotope:stdev") != DataValue::EMPTY)
00165 {
00166 ++summary.mz_stdev[p.getValue("MZ:isotope:stdev")];
00167 }
00168 }
00169 }
00170 catch (Exception::UnableToFit ex)
00171 {
00172
00173
00174
00175 for (IndexSet::const_iterator it = region.begin(); it != region.end(); ++it)
00176 {
00177 this->ff_->getPeakFlag(*it) = UNUSED;
00178 }
00179
00180
00181 {
00182 ++summary.no_exceptions;
00183 ++summary.exception[ex.getName()];
00184 }
00185 }
00186 }
00187 }
00188 catch (NoSuccessor ex)
00189 {
00190 }
00191
00192 this->ff_->endProgress();
00193
00194
00195 {
00196 Size size = this->features_->size();
00197 std::cout << size << " features were found. " << std::endl;
00198
00199
00200 summary.corr_mean /= size;
00201
00202 std::cout << "FeatureFinder summary:\n"
00203 << "Correlation:\n\tminimum: " << summary.corr_min << "\n\tmean: " << summary.corr_mean
00204 << "\n\tmaximum: " << summary.corr_max << std::endl;
00205
00206 std::cout << "Exceptions:\n";
00207 for (std::map<String, UInt>::const_iterator it = summary.exception.begin(); it != summary.exception.end(); ++it)
00208 {
00209 std::cout << "\t" << it->first << ": " << it->second * 100 / summary.no_exceptions << "% (" << it->second << ")\n";
00210 }
00211
00212 std::cout << "Chosen mz models:\n";
00213 for (std::map<String, UInt>::const_iterator it = summary.mz_model.begin(); it != summary.mz_model.end(); ++it)
00214 {
00215 std::cout << "\t" << it->first << ": " << it->second * 100 / size << "% (" << it->second << ")\n";
00216 }
00217
00218 std::cout << "Chosen mz stdevs:\n";
00219 for (std::map<float, UInt>::const_iterator it = summary.mz_stdev.begin(); it != summary.mz_stdev.end(); ++it)
00220 {
00221 std::cout << "\t" << it->first << ": " << it->second * 100 / (size - summary.charge[0]) << "% (" << it->second << ")\n";
00222 }
00223
00224 std::cout << "Charges:\n";
00225 for (Size i = 1; i < summary.charge.size(); ++i)
00226 {
00227 if (summary.charge[i] != 0)
00228 {
00229 std::cout << "\t+" << i << ": " << summary.charge[i] * 100 / (size - summary.charge[0]) << "% (" << summary.charge[i] << ")\n";
00230 }
00231 }
00232 }
00233 }
00234
00235 static FeatureFinderAlgorithm<PeakType, FeatureType> * create()
00236 {
00237 return new FeatureFinderAlgorithmSimple();
00238 }
00239
00240 static const String getProductName()
00241 {
00242 return "simple";
00243 }
00244
00245 private:
00247 FeatureFinderAlgorithmSimple & operator=(const FeatureFinderAlgorithmSimple &);
00249 FeatureFinderAlgorithmSimple(const FeatureFinderAlgorithmSimple &);
00250
00251 };
00252
00253 }
00254
00255 #endif // OPENMS_TRANSFORMATIONS_FEATUREFINDER_FEATUREFINDERALGORITHMSIMPLE_H