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_ISOTOPEMARKER_H
00028 #define OPENMS_FILTERING_TRANSFORMERS_ISOTOPEMARKER_H
00029
00030 #include <OpenMS/FILTERING/TRANSFORMERS/PeakMarker.h>
00031 #include <OpenMS/CHEMISTRY/IsotopeDistribution.h>
00032
00033 #include <map>
00034 #include <vector>
00035 #include <cmath>
00036 #include <utility>
00037
00038 namespace OpenMS
00039 {
00040
00048 class IsotopeMarker
00049 : public PeakMarker
00050 {
00051 public:
00052
00053
00054
00056 IsotopeMarker();
00057
00059 IsotopeMarker(const IsotopeMarker& source);
00060
00062 virtual ~IsotopeMarker();
00063
00064
00065
00066
00068 IsotopeMarker& operator=(const IsotopeMarker& source);
00069
00070
00071
00072
00074 static PeakMarker* create() { return new IsotopeMarker();}
00075
00077 template <typename SpectrumType> void apply(std::map<double, bool> marked, SpectrumType& spectrum)
00078 {
00079 double mzvariation = (double)param_.getValue("mz_variation");
00080 double invariation = (double)param_.getValue("in_variation");
00081 uint marks = (unsigned int)param_.getValue("marks");
00082
00083 spectrum.getContainer().sortByPosition();
00084
00085 std::map<double, uint> isotopemarks ;
00086
00087 for (uint i = 0; i < spectrum.size(); ++i)
00088 {
00089 double mz = spectrum.getContainer()[i].getPosition()[0];
00090 double intensity = spectrum.getContainer()[i].getIntensity();
00091 uint j = i+1;
00092
00093
00094 IsotopeDistribution id;
00095 id.estimateFromPeptideWeight(mz);
00096 while (j < spectrum.getContainer().size() && spectrum.getContainer()[j].getPosition()[0] <= mz + 3 + mzvariation)
00097 {
00098 double curmz = spectrum.getContainer()[j].getPosition()[0];
00099 double curIntensity = spectrum.getContainer()[j].getIntensity();
00100 uint iso = (uint)(curmz - mz + 0.499999);
00101 if (iso > 0 && curmz - mz - iso > mzvariation)
00102 {
00103 ++j;
00104 continue;
00105 }
00106 if (std::fabs(id.getContainer().begin()->second * intensity - curIntensity) < invariation * id.getContainer().begin()->second * intensity)
00107 {
00108 isotopemarks[mz]++;
00109 isotopemarks[curmz]++;
00110 }
00111 ++j;
00112 }
00113 }
00114
00115 for (std::map<double, uint>::const_iterator cmit = isotopemarks.begin(); cmit != isotopemarks.end(); ++cmit)
00116 {
00117 if (cmit->second >= marks)
00118 {
00119 marked.insert(std::make_pair<double, bool>(cmit->first, true));
00120 }
00121 }
00122 return;
00123 }
00124
00126 static const String getProductName()
00127 {
00128 return "IsotopeMarker";
00129 }
00130
00131
00132 };
00133
00134 }
00135
00136 #endif //OPENMS_FILTERING_TRANSFORMERS_ISOTOPEMARKER_H