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

ChargePair.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: Chris Bielow $
00032 // $Authors: $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_DATASTRUCTURES_CHARGEPAIR_H
00036 #define OPENMS_DATASTRUCTURES_CHARGEPAIR_H
00037 
00038 #include <iostream>
00039 #include <vector>
00040 
00041 #include <OpenMS/KERNEL/FeatureMap.h>
00042 #include <OpenMS/DATASTRUCTURES/Compomer.h>
00043 
00044 namespace OpenMS
00045 {
00046 
00057   class OPENMS_DLLAPI ChargePair
00058   {
00059 
00060 public:
00062 
00063 
00064     ChargePair() :
00065       feature0_index_(0),
00066       feature1_index_(0),
00067       feature0_charge_(0),
00068       feature1_charge_(0),
00069       compomer_(),
00070       mass_diff_(0),
00071       score_(1),
00072       is_active_(false)
00073     {
00074     }
00075 
00077     ChargePair(const Size & index0,
00078                const Size & index1,
00079                const Int & charge0,
00080                const Int & charge1,
00081                const Compomer & compomer,
00082                const DoubleReal & mass_diff,
00083                const bool active) :
00084       feature0_index_(index0),
00085       feature1_index_(index1),
00086       feature0_charge_(charge0),
00087       feature1_charge_(charge1),
00088       compomer_(compomer),
00089       mass_diff_(mass_diff),
00090       score_(1),
00091       is_active_(active)
00092     {
00093     }
00094 
00096     ChargePair(const ChargePair & rhs) :
00097       feature0_index_(rhs.feature0_index_),
00098       feature1_index_(rhs.feature1_index_),
00099       feature0_charge_(rhs.feature0_charge_),
00100       feature1_charge_(rhs.feature1_charge_),
00101       compomer_(rhs.compomer_),
00102       mass_diff_(rhs.mass_diff_),
00103       score_(rhs.score_),
00104       is_active_(rhs.is_active_)
00105     {
00106     }
00107 
00109     ChargePair & operator=(const ChargePair & rhs)
00110     {
00111       if (&rhs == this) return *this;
00112 
00113       feature0_index_ = rhs.feature0_index_;
00114       feature1_index_ = rhs.feature1_index_;
00115       feature0_charge_ = rhs.feature0_charge_;
00116       feature1_charge_ = rhs.feature1_charge_;
00117       compomer_ = rhs.compomer_;
00118       mass_diff_ = rhs.mass_diff_;
00119       score_ = rhs.score_;
00120       is_active_ = rhs.is_active_;
00121 
00122       return *this;
00123     }
00124 
00126     virtual ~ChargePair()
00127     {
00128     }
00129 
00131 
00132     //@name Accessors
00134 
00135     Int getCharge(UInt pairID) const
00136     {
00137       if (pairID == 0) return feature0_charge_;
00138       else return feature1_charge_;
00139     }
00140 
00142     void setCharge(UInt pairID, Int e)
00143     {
00144       if (pairID == 0) feature0_charge_ = e;
00145       else feature1_charge_ = e;
00146     }
00147 
00149     Size getElementIndex(UInt pairID) const
00150     {
00151       if (pairID == 0) return feature0_index_;
00152       else return feature1_index_;
00153     }
00154 
00156     void setElementIndex(UInt pairID, Size e)
00157     {
00158       if (pairID == 0) feature0_index_ = e;
00159       else feature1_index_ = e;
00160     }
00161 
00163     const Compomer & getCompomer() const
00164     {
00165       return compomer_;
00166     }
00167 
00169     void setCompomer(const Compomer & compomer)
00170     {
00171       compomer_ = compomer;
00172     }
00173 
00175     DoubleReal getMassDiff() const
00176     {
00177       return mass_diff_;
00178     }
00179 
00181     void setMassDiff(DoubleReal mass_diff)
00182     {
00183       mass_diff_ = mass_diff;
00184     }
00185 
00187     DoubleReal getEdgeScore() const
00188     {
00189       return score_;
00190     }
00191 
00193     void setEdgeScore(DoubleReal score)
00194     {
00195       score_ = score;
00196     }
00197 
00199     bool isActive() const
00200     {
00201       return is_active_;
00202     }
00203 
00204     void setActive(const bool active)
00205     {
00206       is_active_ = active;
00207     }
00208 
00210 
00212     virtual bool operator==(const ChargePair & i) const
00213     {
00214       return (feature0_index_ == i.feature0_index_) &&
00215              (feature1_index_ == i.feature1_index_) &&
00216              (feature0_charge_ == i.feature0_charge_) &&
00217              (feature1_charge_ == i.feature1_charge_) &&
00218              (compomer_ == i.compomer_) &&
00219              (mass_diff_ == i.mass_diff_) &&
00220              (is_active_ == i.is_active_);
00221     }
00222 
00224     virtual bool operator!=(const ChargePair & i) const
00225     {
00226       return !(this->operator==(i));
00227     }
00228 
00229 protected:
00230 
00232     Size feature0_index_;
00234     Size feature1_index_;
00236     Int feature0_charge_;
00238     Int feature1_charge_;
00240     Compomer compomer_;
00242     DoubleReal mass_diff_;
00244     DoubleReal score_;
00246     bool is_active_;
00247   };
00248 
00250   OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const ChargePair & cons);
00251 
00252 } // namespace OpenMS
00253 
00254 #endif // OPENMS_DATASTRUCTURES_CHARGEPAIR_H

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