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_COMPLEMENTMARKER_H
00036 #define OPENMS_FILTERING_TRANSFORMERS_COMPLEMENTMARKER_H
00037
00038 #include <OpenMS/FILTERING/TRANSFORMERS/PeakMarker.h>
00039
00040 #include <map>
00041 #include <cmath>
00042
00043 namespace OpenMS
00044 {
00052 class OPENMS_DLLAPI ComplementMarker :
00053 public PeakMarker
00054 {
00055 public:
00056
00057
00059
00060 ComplementMarker();
00061
00063 ComplementMarker(const ComplementMarker & source);
00064
00066 virtual ~ComplementMarker();
00068
00069
00071
00072 ComplementMarker & operator=(const ComplementMarker & source);
00074
00075
00077
00078 static PeakMarker * create() { return new ComplementMarker(); }
00079
00081 template <typename SpectrumType>
00082 void apply(std::map<double, bool> marked, SpectrumType & spectrum)
00083 {
00084 if (spectrum.size() < 2)
00085 {
00086 return;
00087 }
00088
00089
00090 double marks = (double)param_.getValue("marks");
00091 double parentmass = 0.0;
00092 if (!spectrum.getPrecursors().empty()) parentmass = spectrum.getPrecursors()[0].getMZ();
00093 double tolerance = (double)param_.getValue("tolerance");
00094 std::map<double, int> matching_b_y_ions;
00095
00096 spectrum.sortByPosition();
00097
00098 SignedSize j = spectrum.size() - 1;
00099 for (Size i = 0; i < spectrum.size(); ++i)
00100 {
00101 while (j >= 0 && spectrum[j].getPosition()[0] > (parentmass - spectrum[i].getPosition()[0]) + tolerance)
00102 {
00103 j--;
00104 }
00105
00106
00107 if (j >= 0 && std::fabs(spectrum[i].getPosition()[0] + spectrum[j].getPosition()[0] - parentmass) < tolerance)
00108 {
00109 matching_b_y_ions[spectrum[i].getPosition()[0]]++;
00110 matching_b_y_ions[spectrum[j].getPosition()[0]]++;
00111 j--;
00112 }
00113 }
00114
00115 for (std::map<double, int>::const_iterator cmit = matching_b_y_ions.begin(); cmit != matching_b_y_ions.end(); ++cmit)
00116 {
00117 if (cmit->second >= marks)
00118 {
00119 marked.insert(std::pair<double, bool>(cmit->first, true));
00120 }
00121 }
00122 }
00123
00125 static const String getProductName()
00126 {
00127 return "ComplementMarker";
00128 }
00129
00131
00132 };
00133
00134 }
00135 #endif //OPENMS_FILTERING_TRANSFORMERS_COMPLEMENTMARKER_H