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 #ifndef OPENMS_FILTERING_TRANSFORMERS_NEUTRALLOSSMARKER_H
00028 #define OPENMS_FILTERING_TRANSFORMERS_NEUTRALLOSSMARKER_H
00029
00030 #include <OpenMS/FILTERING/TRANSFORMERS/PeakMarker.h>
00031
00032 #include <map>
00033 #include <cmath>
00034
00035 namespace OpenMS
00036 {
00044 class NeutralLossMarker
00045 : public PeakMarker
00046 {
00047 public:
00048
00049
00050
00052 NeutralLossMarker();
00053
00055 NeutralLossMarker(const NeutralLossMarker& source);
00056
00058 virtual ~NeutralLossMarker();
00059
00060
00061
00062
00064 NeutralLossMarker& operator = (const NeutralLossMarker& source);
00065
00066
00067
00068
00070 static PeakMarker* create() { return new NeutralLossMarker(); }
00071
00073 template <typename SpectrumType> void apply(std::map<double, bool>& marked, SpectrumType& spectrum)
00074 {
00075
00076 double marks = (double)param_.getValue("marks");
00077 double tolerance = (double)param_.getValue("tolerance");
00078 std::map<double, int> ions_w_neutrallosses;
00079 spectrum.getContainer().sortByPosition();
00080 for (uint i = 0; i < spectrum.size(); ++i)
00081 {
00082 double mz = spectrum.getContainer()[i].getPosition()[0];
00083 double intensity = spectrum.getContainer()[i].getIntensity();
00084 int j = i - 1;
00085 while (j >= 0)
00086 {
00087 double curmz = spectrum.getContainer()[j].getPosition()[0];
00088 double curIntensity = spectrum.getContainer()[j].getIntensity();
00089
00090
00091 if (std::fabs(mz - curmz - 17) < tolerance || std::fabs(mz - curmz - 18) < tolerance)
00092 {
00093
00094 if (curIntensity < intensity)
00095 {
00096 ions_w_neutrallosses[mz]++;
00097
00098
00099 }
00100 }
00101 else
00102 {
00103 if (mz - curmz > 18.3)
00104 {
00105 break;
00106 }
00107 }
00108 --j;
00109 }
00110 }
00111
00112 for (std::map<double, int>::const_iterator cmit = ions_w_neutrallosses.begin(); cmit != ions_w_neutrallosses.end(); ++cmit)
00113 {
00114 if (cmit->second >= marks)
00115 {
00116 marked.insert(std::make_pair<double, bool>(cmit->first, true));
00117 }
00118 }
00119 return;
00120 }
00121
00123 static const String getProductName()
00124 {
00125 return "NeutralLossMarker";
00126 }
00127
00128
00129 };
00130
00131 }
00132 #endif //OPENMS_FILTERING_TRANSFORMERS_NEUTRALLOSSMARKER_H