Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

ConsensusFeature.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: Erhan Kenar $
00032 // $Authors: $
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       //TODO ratio cv info
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 } // namespace OpenMS
00295 
00296 #endif // OPENMS_KERNEL_CONSENSUSFEATURE_H

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:38 using doxygen 1.7.1