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 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/FeatureFinder.h>
00028
00029 #ifndef OPENMS_TRANSFORMATIONS_FEATUREFINDER_SIMPLESEEDER_H
00030 #define OPENMS_TRANSFORMATIONS_FEATUREFINDER_SIMPLESEEDER_H
00031
00032 #include <OpenMS/CONCEPT/Types.h>
00033 #include <OpenMS/CONCEPT/Exception.h>
00034 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/FeaFiModule.h>
00035
00036
00037 #include <algorithm>
00038 #include <vector>
00039 #include <iostream>
00040
00041 namespace OpenMS
00042 {
00053 template<class PeakType, class FeatureType> class SimpleSeeder :
00054 public FeaFiModule<PeakType, FeatureType>,
00055 public FeatureFinderDefs
00056 {
00057 public:
00058 typedef FeaFiModule<PeakType,FeatureType> Base;
00059
00061 SimpleSeeder(const MSExperiment<PeakType>* map, FeatureMap<FeatureType>* features, FeatureFinder* ff) :
00062 Base(map,features,ff),
00063 initialized_(false)
00064 {
00065 this->setName("SimpleSeeder");
00066 this->defaults_.setValue("min_intensity",1.0f, "Absolute value for the minimum intensity of a seed. If set to 0, a fixed percentage of the intensity of the largest peak is taken (see intensity_perc).", false);
00067 this->defaults_.setMinFloat("min_intensity",0.0);
00068 this->defaults_.setValue("intensity_perc",20.0f, "Minimum percentage of the intensity of the largest peak that a seed has to have (used only if min_intensity is set to 0).", false);
00069 this->defaults_.setMinFloat("intensity_perc",0.0);
00070 this->defaults_.setMaxFloat("intensity_perc",100.0);
00071
00072 this->defaultsToParam_();
00073 }
00075 virtual ~SimpleSeeder()
00076 {
00077 }
00078
00080 IndexPair nextSeed() throw (NoSuccessor)
00081 {
00082 if (!initialized_)
00083 {
00084 initialize_();
00085 }
00086
00087
00088 while (current_peak_ != indices_.end() && this->ff_->getPeakFlag(*current_peak_) == USED)
00089 {
00090 ++current_peak_;
00091 }
00092
00093 if (current_peak_ == indices_.end())
00094 {
00095 throw NoSuccessor(__FILE__, __LINE__,__PRETTY_FUNCTION__, *current_peak_);
00096 }
00097
00098 this->ff_->setProgress(current_peak_-indices_.begin());
00099
00100
00101 this->ff_->getPeakFlag(*current_peak_) = USED;
00102
00103 return *(current_peak_++);
00104 }
00105
00106 protected:
00107
00108 void initialize_()
00109 {
00110
00111 typename FeatureType::IntensityType noise_threshold = this->param_.getValue("min_intensity");
00112 if (noise_threshold == 0.0)
00113 {
00114 noise_threshold =
00115 typename FeatureType::IntensityType(this->param_.getValue("intensity_perc"))
00116 * (*this->map_).getMaxInt()
00117 / 100.0;
00118 }
00119
00120 std::cout << "Threshold: " << noise_threshold << std::endl;
00121
00122
00123
00124 IndexPair tmp = std::make_pair(0,0);
00125 while (tmp.first < (*this->map_).size())
00126 {
00127 tmp.second = 0;
00128 while (tmp.second < (*this->map_)[tmp.first].size())
00129 {
00130 if (this->getPeakIntensity(tmp)>noise_threshold)
00131 {
00132 indices_.push_back(tmp);
00133 }
00134 ++tmp.second;
00135 }
00136 ++tmp.first;
00137 }
00138
00139
00140 std::cout << "Number of peaks above threshold (" << noise_threshold << "): " << indices_.size() << std::endl;
00141
00142
00143
00144 sort(indices_.begin(),indices_.end(),
00145 reverseComparator(Internal::IntensityLess<Base>(*this))
00146 );
00147
00148
00149 this->ff_->startProgress(0, indices_.size() , "FeatureFinder");
00150
00151 current_peak_ = indices_.begin();
00152
00153 initialized_ = true;
00154 return;
00155 }
00156
00158 std::vector<IndexPair> indices_;
00159
00161 std::vector<IndexPair>::const_iterator current_peak_;
00162
00164 bool initialized_;
00165
00166 private:
00168 SimpleSeeder();
00170 SimpleSeeder& operator=(const SimpleSeeder&);
00172 SimpleSeeder(const SimpleSeeder&);
00173
00174 };
00175
00176 }
00177
00178 #endif // OPENMS_TRANSFORMATIONS_FEATUREFINDER_SIMPLESEEDER_H
00179