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