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_TRANSFORMERS_BERNNORM_H
00036 #define OPENMS_FILTERING_TRANSFORMERS_BERNNORM_H
00037
00038 #include <OpenMS/KERNEL/StandardTypes.h>
00039
00040 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
00041
00042 #include <map>
00043
00044 namespace OpenMS
00045 {
00057 class OPENMS_DLLAPI BernNorm :
00058 public DefaultParamHandler
00059 {
00060 public:
00061
00062
00064
00065 BernNorm();
00066
00068 BernNorm(const BernNorm & source);
00069
00071 virtual ~BernNorm();
00073
00074
00075
00077 BernNorm & operator=(const BernNorm & source);
00079
00080
00081
00082
00084 template <typename SpectrumType>
00085 void filterSpectrum(SpectrumType & spectrum)
00086 {
00087 typedef typename SpectrumType::Iterator Iterator;
00088 typedef typename SpectrumType::ConstIterator ConstIterator;
00089
00090 c1_ = (DoubleReal)param_.getValue("C1");
00091 c2_ = (DoubleReal)param_.getValue("C2");
00092 th_ = (DoubleReal)param_.getValue("threshold");
00093
00094 spectrum.sortByPosition();
00095
00096
00097 double maxint = 0;
00098 std::map<double, Size> peakranks;
00099 for (ConstIterator it = spectrum.begin(); it != spectrum.end(); ++it)
00100 {
00101 peakranks[it->getIntensity()] = 0;
00102 if (it->getIntensity() > maxint)
00103 {
00104 maxint = it->getIntensity();
00105 }
00106 }
00107 UInt rank = 0;
00108 for (std::map<double, Size>::reverse_iterator mit = peakranks.rbegin(); mit != peakranks.rend(); ++mit)
00109 {
00110 mit->second = ++rank;
00111 }
00112
00113
00114 double maxmz = 0;
00115 for (SignedSize i = spectrum.size() - 1; i >= 0; --i)
00116 {
00117 if (spectrum[i].getIntensity() > maxint * th_)
00118 {
00119 maxmz = spectrum[i].getMZ();
00120 break;
00121 }
00122 }
00123
00124
00125 for (Iterator it = spectrum.begin(); it != spectrum.end(); )
00126 {
00127 double newint = c1_ - (c2_ / maxmz) * peakranks[it->getIntensity()];
00128 if (newint < 0)
00129 {
00130 it = spectrum.erase(it);
00131 }
00132 else
00133 {
00134 it->setIntensity(newint);
00135 ++it;
00136 }
00137 }
00138 return;
00139 }
00140
00141 void filterPeakSpectrum(PeakSpectrum & spectrum);
00142
00143 void filterPeakMap(PeakMap & exp);
00144
00145
00146 private:
00147 DoubleReal c1_;
00148 DoubleReal c2_;
00149 DoubleReal th_;
00150
00151
00152
00153 };
00154
00155 }
00156
00157 #endif //OPENMS_FILTERING_TRANSFORMERS_BERNNORM_H