Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
QTCluster.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2017.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Hendrik Weisser $
32 // $Authors: Steffen Sass, Hendrik Weisser $
33 // --------------------------------------------------------------------------
34 
35 
36 #ifndef OPENMS_DATASTRUCTURES_QTCLUSTER_H
37 #define OPENMS_DATASTRUCTURES_QTCLUSTER_H
38 
39 #include <OpenMS/CONCEPT/Types.h>
41 #include <OpenMS/OpenMSConfig.h>
42 #include <OpenMS/config.h>
43 
44 #include <boost/unordered_map.hpp>
45 
46 #include <map> // for multimap<>
47 #include <vector> // for vector<>
48 #include <set> // for set<>
49 #include <utility> // for pair<>
50 
51 
52 namespace OpenMS
53 {
54  class GridFeature;
55 
56  // Boost switch since with 1.47 several classes got moved into a new
57  // boost::unordered namespace (specifically unordered_map).
58  namespace OpenMSBoost
59  {
60 #if OPENMS_BOOST_VERSION_MINOR > 47
61  using namespace boost::unordered;
62 #else
63  using namespace boost;
64 #endif
65  }
66 
67 
112  class OPENMS_DLLAPI QTCluster
113  {
114 private:
115 
116  // need to store more than one
117  typedef std::multimap<double, GridFeature*> NeighborListType;
118  typedef OpenMSBoost::unordered_map<Size, NeighborListType> NeighborMapMulti;
119 
120  typedef std::pair<double, GridFeature*> NeighborPairType;
121  typedef OpenMSBoost::unordered_map<Size, NeighborPairType> NeighborMap;
122 
125 
130  NeighborMap neighbors_;
131 
139  NeighborMapMulti* tmp_neighbors_;
140 
143 
146 
148  double quality_;
149 
151  bool changed_;
152 
154  bool use_IDs_;
155 
157  bool valid_;
158 
169 
172 
175 
178 
185  std::set<AASequence> annotations_;
186 
188  QTCluster();
189 
191  void computeQuality_();
192 
212  double optimizeAnnotations_();
213 
214 public:
215 
223  QTCluster(GridFeature* center_point, Size num_maps,
224  double max_distance, bool use_IDs,
225  Int x_coord, Int y_coord);
226 
228  virtual ~QTCluster();
229 
231  GridFeature* getCenterPoint();
232 
234  double getCenterRT() const;
235 
237  double getCenterMZ() const;
238 
240  Int getXCoord() const;
241 
243  Int getYCoord() const;
244 
246  Size size() const;
247 
249  bool operator<(QTCluster& cluster);
250 
257  void add(GridFeature* element, double distance);
258 
260  void getElements(OpenMSBoost::unordered_map<Size, GridFeature*>& elements);
261 
269  bool update(const OpenMSBoost::unordered_map<Size, GridFeature*>& removed);
270 
272  double getQuality();
273 
275  const std::set<AASequence>& getAnnotations();
276 
284  void setInvalid();
285 
287  inline bool isInvalid() const
288  {
289  return !valid_;
290  }
291 
293  void initializeCluster();
294 
296  void finalizeCluster();
297 
299  OpenMSBoost::unordered_map<Size, std::vector<GridFeature*> > getAllNeighbors();
300  };
301 } // namespace OpenMS
302 
303 #endif // OPENMS_DATASTRUCTURES_QTCLUSTER_H
std::set< AASequence > annotations_
Set of annotations of the cluster.
Definition: QTCluster.h:185
A representation of a QT cluster used for feature grouping.
Definition: QTCluster.h:112
NeighborMap neighbors_
Map that keeps track of the best current feature for each map.
Definition: QTCluster.h:130
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
GridFeature * center_point_
Pointer to the cluster center.
Definition: QTCluster.h:124
bool operator<(const MultiplexDeltaMasses &dm1, const MultiplexDeltaMasses &dm2)
Representation of a feature in a hash grid.
Definition: GridFeature.h:53
bool use_IDs_
Keep track of peptide IDs and use them for matching?
Definition: QTCluster.h:154
bool collect_annotations_
Whether initial collection of all neighbors is needed.
Definition: QTCluster.h:168
NeighborMapMulti * tmp_neighbors_
Temporary map tracking *all* neighbors.
Definition: QTCluster.h:139
bool finalized_
Whether current cluster is accepting new elements or not (if true, no more new elements allowed) ...
Definition: QTCluster.h:171
Int x_coord_
x coordinate in the grid cell
Definition: QTCluster.h:174
bool changed_
Has the cluster changed (if yes, quality needs to be recomputed)?
Definition: QTCluster.h:151
Int y_coord_
y coordinate in the grid cell
Definition: QTCluster.h:177
std::pair< double, GridFeature * > NeighborPairType
Definition: QTCluster.h:120
OpenMSBoost::unordered_map< Size, NeighborPairType > NeighborMap
Definition: QTCluster.h:121
OpenMSBoost::unordered_map< Size, NeighborListType > NeighborMapMulti
Definition: QTCluster.h:118
Size num_maps_
Number of input maps.
Definition: QTCluster.h:145
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
std::multimap< double, GridFeature * > NeighborListType
Definition: QTCluster.h:117
bool valid_
Whether current cluster is valid.
Definition: QTCluster.h:157
double quality_
Quality of the cluster.
Definition: QTCluster.h:148
bool isInvalid() const
Whether current cluster is invalid.
Definition: QTCluster.h:287
int Int
Signed integer type.
Definition: Types.h:103
double max_distance_
Maximum distance of a point that can still belong to the cluster.
Definition: QTCluster.h:142

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:03 using doxygen 1.8.13