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_KERNEL_CONSENSUSFEATURE_H
00036 #define OPENMS_KERNEL_CONSENSUSFEATURE_H
00037
00038 #include <OpenMS/DATASTRUCTURES/DRange.h>
00039 #include <OpenMS/KERNEL/BaseFeature.h>
00040 #include <OpenMS/KERNEL/FeatureHandle.h>
00041 #include <OpenMS/KERNEL/FeatureMap.h>
00042
00043 #include <set>
00044
00045 namespace OpenMS
00046 {
00059 class OPENMS_DLLAPI ConsensusFeature :
00060 public BaseFeature,
00061 public std::set<FeatureHandle, FeatureHandle::IndexLess>
00062 {
00063 public:
00065
00066 typedef std::set<FeatureHandle, FeatureHandle::IndexLess> HandleSetType;
00068
00070 struct SizeLess :
00071 std::binary_function<ConsensusFeature, ConsensusFeature, bool>
00072 {
00073 inline bool operator()(ConsensusFeature const & left, ConsensusFeature const & right) const
00074 {
00075 return left.size() < right.size();
00076 }
00077
00078 inline bool operator()(ConsensusFeature const & left, UInt64 const & right) const
00079 {
00080 return left.size() < right;
00081 }
00082
00083 inline bool operator()(UInt64 const & left, ConsensusFeature const & right) const
00084 {
00085 return left < right.size();
00086 }
00087
00088 inline bool operator()(const UInt64 & left, const UInt64 & right) const
00089 {
00090 return left < right;
00091 }
00092
00093 };
00094
00096 struct MapsLess :
00097 std::binary_function<ConsensusFeature, ConsensusFeature, bool>
00098 {
00099 inline bool operator()(ConsensusFeature const & left, ConsensusFeature const & right) const
00100 {
00101 return std::lexicographical_compare(left.begin(), left.end(), right.begin(), right.end(), FeatureHandle::IndexLess());
00102 }
00103
00104 };
00105
00107 struct Ratio
00108 {
00109 Ratio()
00110 {
00111 }
00112
00113 Ratio(const Ratio & rhs)
00114 {
00115 ratio_value_ = rhs.ratio_value_;
00116 denominator_ref_ = rhs.denominator_ref_;
00117 numerator_ref_ = rhs.numerator_ref_;
00118 description_ = rhs.description_;
00119 }
00120
00121 virtual ~Ratio()
00122 {
00123 }
00124
00125 Ratio & operator=(const Ratio & rhs)
00126 {
00127 if (&rhs != this)
00128 {
00129 ratio_value_ = rhs.ratio_value_;
00130 denominator_ref_ = rhs.denominator_ref_;
00131 numerator_ref_ = rhs.numerator_ref_;
00132 description_ = rhs.description_;
00133 }
00134 return *this;
00135 }
00136
00137 DoubleReal ratio_value_;
00138 String denominator_ref_;
00139 String numerator_ref_;
00140 std::vector<String> description_;
00141
00142 };
00143
00145
00146
00147 ConsensusFeature();
00148
00150 ConsensusFeature(const ConsensusFeature & rhs);
00151
00153 explicit ConsensusFeature(const BaseFeature & feature);
00154
00161 ConsensusFeature(UInt64 map_index, const Peak2D & element, UInt64 element_index);
00162
00169 ConsensusFeature(UInt64 map_index, const BaseFeature & element);
00170
00172 ConsensusFeature & operator=(const ConsensusFeature & rhs);
00173
00175 virtual ~ConsensusFeature();
00177
00178
00180
00181
00187 void insert(const FeatureHandle & handle);
00188
00190 void insert(const HandleSetType & handle_set);
00191
00198 void insert(UInt64 map_index, const Peak2D & element, UInt64 element_index);
00199
00206 void insert(UInt64 map_index, const BaseFeature & element);
00207
00209 const HandleSetType & getFeatures() const;
00211
00213
00214
00215 DRange<2> getPositionRange() const;
00217 DRange<1> getIntensityRange() const;
00218
00220
00230 void computeConsensus();
00231
00241 void computeMonoisotopicConsensus();
00242
00256 void computeDechargeConsensus(const FeatureMap<> & fm, bool intensity_weighted_averaging = false);
00257
00265 void addRatio(const Ratio & r);
00266
00274 void setRatios(std::vector<Ratio> & rs);
00275
00279 std::vector<Ratio> getRatios() const;
00280
00284 std::vector<Ratio> & getRatios();
00285
00286 private:
00287 std::vector<Ratio> ratios_;
00288
00289 };
00290
00292 OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const ConsensusFeature & cons);
00293
00294 }
00295
00296 #endif // OPENMS_KERNEL_CONSENSUSFEATURE_H