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 #ifndef OPENMS_ANALYSIS_MAPMATCHING_BASEPAIRWISEMAPMATCHER_H
00029 #define OPENMS_ANALYSIS_MAPMATCHING_BASEPAIRWISEMAPMATCHER_H
00030
00031 #include <OpenMS/ANALYSIS/MAPMATCHING/ElementPair.h>
00032 #include <OpenMS/ANALYSIS/MAPMATCHING/Grid.h>
00033 #include <OpenMS/KERNEL/FeatureMap.h>
00034 #include <OpenMS/DATASTRUCTURES/DBoundingBox.h>
00035 #include <OpenMS/CONCEPT/FactoryProduct.h>
00036
00037 #include <utility>
00038 #include <fstream>
00039
00040 namespace OpenMS
00041 {
00042
00063 template < typename MapT = FeatureMap< > >
00064 class BasePairwiseMapMatcher
00065 : public FactoryProduct
00066 {
00067 public:
00069 typedef MapT PointMapType;
00070
00072 typedef typename PointMapType::value_type ElementType;
00073
00075 typedef ElementPair < ElementType > ElementPairType;
00076
00078 typedef std::vector < ElementPairType > ElementPairVectorType;
00079
00081 typedef DPosition < 2 > PositionType;
00082
00084 typedef DBoundingBox< 2> PositionBoundingBoxType;
00085
00087 typedef DoubleReal CoordinateType;
00088
00089
00091 BasePairwiseMapMatcher()
00092 : FactoryProduct("BasePairWiseMapMatcher")
00093 {
00094 element_map_[0] = 0;
00095 element_map_[1] = 0;
00096 defaults_.setValue("number_buckets:RT",1, "To obtain a piecewise defined warping function the retention time dimension can be divided into a number of buckets.",true);
00097 defaults_.setValue("number_buckets:MZ",1, "To obtain a piecewise defined warping function the m/z dimension can be divided into a number of buckets.",true);
00098
00099
00100 }
00101
00102
00104 virtual ~BasePairwiseMapMatcher()
00105 {
00106 }
00107
00109 void setElementMap(UInt const index, const PointMapType& element_map)
00110 {
00111 element_map_[index] = &element_map;
00112 }
00113
00115 const PointMapType& getElementMap(UInt index) const
00116 {
00117 return *element_map_[index];
00118 }
00119
00121 const ElementPairVectorType& getElementPairs() const
00122 {
00123 return all_element_pairs_;
00124 }
00125
00127 const Grid& getGrid() const
00128 {
00129 return grid_;
00130 }
00131
00133 void setNumberBuckets(UInt dim, UInt number)
00134 {
00135 number_buckets_[dim] = number;
00136 param_.setValue(String("number_buckets:") + RawDataPoint2D::shortDimensionName(dim), number);
00137 }
00138
00140 UInt getNumberBuckets(UInt index) const
00141 {
00142 return number_buckets_[index];
00143 }
00144
00146 static void registerChildren();
00147
00149 virtual void run() = 0;
00150
00152 void initGridTransformation(const PointMapType& scene_map)
00153 {
00154 grid_.clear();
00155 bounding_box_scene_map_.clear();
00156
00157
00158 for ( typename PointMapType::const_iterator fm_iter = scene_map.begin();
00159 fm_iter != scene_map.end();
00160 ++fm_iter
00161 )
00162 {
00163 bounding_box_scene_map_.enlarge(fm_iter->getPosition());
00164 }
00165
00166
00167
00168
00169 for (UInt i = 0; i < 2; ++i)
00170 {
00171 box_size_[i] =
00172 (bounding_box_scene_map_.max()[i] - bounding_box_scene_map_.min()[i]) /
00173 ( number_buckets_[i] - 0.01 );
00174 }
00175
00176
00177 for (UInt x_index = 0; x_index < number_buckets_[RawDataPoint2D::RT]; ++x_index)
00178 {
00179 for (UInt y_index = 0; y_index < number_buckets_[RawDataPoint2D::MZ]; ++y_index)
00180 {
00181 CoordinateType x_min = (bounding_box_scene_map_.min())[RawDataPoint2D::RT] + box_size_[RawDataPoint2D::RT]*x_index;
00182 CoordinateType x_max = (bounding_box_scene_map_.min())[RawDataPoint2D::RT] + box_size_[RawDataPoint2D::RT]*(x_index+1);
00183 CoordinateType y_min = (bounding_box_scene_map_.min())[RawDataPoint2D::MZ] + box_size_[RawDataPoint2D::MZ]*y_index;
00184 CoordinateType y_max = (bounding_box_scene_map_.min())[RawDataPoint2D::MZ] + box_size_[RawDataPoint2D::MZ]*(y_index+1);
00185
00186 grid_.push_back(GridCell(x_min, y_min, x_max, y_max));
00187 }
00188 }
00189 }
00190
00191
00192
00193
00194
00195 protected:
00196 virtual void updateMembers_()
00197 {
00198 for ( UInt dim = 0; dim < 2; ++dim)
00199 {
00200 number_buckets_[dim] = param_.getValue(String("number_buckets:") + RawDataPoint2D::shortDimensionName(dim));
00201 }
00202 }
00203
00205 PointMapType const * element_map_[2];
00206
00208 ElementPairVectorType all_element_pairs_;
00209
00211 Grid grid_;
00212
00214 PositionBoundingBoxType bounding_box_scene_map_;
00215
00217 PositionType box_size_;
00218
00220 UInt number_buckets_[2];
00221 }
00222 ;
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 }
00268
00269 #endif // OPENMS_ANALYSIS_MAPMATCHING_BASEPAIRWISEMAPMATCHER_H