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_FORMAT_PEAKTYPEESTIMATOR_H
00028 #define OPENMS_FORMAT_PEAKTYPEESTIMATOR_H
00029
00030 #include <OpenMS/METADATA/SpectrumSettings.h>
00031
00032 #include <cmath>
00033 #include <limits>
00034
00035 namespace OpenMS
00036 {
00042 class PeakTypeEstimator
00043 {
00044 public:
00050 template <typename PeakConstIterator>
00051 SpectrumSettings::SpectrumType estimateType(const PeakConstIterator& begin, const PeakConstIterator& end) const
00052 {
00053
00054 if (end - begin < 5)
00055 {
00056 return SpectrumSettings::UNKNOWN;
00057 }
00058
00059 DoubleReal min = std::numeric_limits<DoubleReal>::max();
00060 DoubleReal max = std::numeric_limits<DoubleReal>::min();
00061 DoubleReal left = std::numeric_limits<DoubleReal>::min();
00062 DoubleReal right = std::numeric_limits<DoubleReal>::min();
00063
00064 PeakConstIterator it = begin;
00065 PeakConstIterator it2 = begin;
00066 ++it2;
00067 for (; it2!=end; ++it,++it2)
00068 {
00069 min = std::min(min,it2->getMZ()-it->getMZ());
00070 if (max < it2->getMZ()-it->getMZ())
00071 {
00072 left = it->getIntensity();
00073 right = it2->getIntensity();
00074 max = it2->getMZ()-it->getMZ();
00075 }
00076 }
00077
00078
00079
00080
00081
00082
00083
00084 if ((max-min)<0.5)
00085 {
00086 return SpectrumSettings::RAWDATA;
00087 }
00088
00089 else if (left < 2.0 && right < 2.0)
00090 {
00091 return SpectrumSettings::RAWDATA;
00092 }
00093
00094 return SpectrumSettings::PEAKS;
00095 }
00096
00097 };
00098
00099 }
00100
00101 #endif // OPENMS_FORMAT_PEAKTYPEESTIMATOR_H