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

PILISCrossValidation.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: Andreas Bertsch $
00032 // $Authors: Andreas Bertsch $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_ANALYSIS_ID_PILISCROSSVALIDATION_H
00036 #define OPENMS_ANALYSIS_ID_PILISCROSSVALIDATION_H
00037 
00038 #include <OpenMS/KERNEL/StandardTypes.h>
00039 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
00040 
00041 #include <iostream>
00042 #include <vector>
00043 
00044 namespace OpenMS
00045 {
00046   class PeakSpectrumCompareFunctor;
00047   class PILISModel;
00048 
00049 
00058   class OPENMS_DLLAPI PILISCrossValidation :
00059     public DefaultParamHandler
00060   {
00061 
00062 public:
00063 
00067     struct Peptide
00068     {
00069       Peptide() :
00070         charge(0)
00071       {
00072 
00073       }
00074 
00075       Peptide(const Peptide & rhs) :
00076         sequence(rhs.sequence),
00077         charge(rhs.charge),
00078         spec(rhs.spec),
00079         hits(rhs.hits)
00080       {
00081       }
00082 
00083       virtual ~Peptide()
00084       {
00085       }
00086 
00087       Peptide & operator=(const Peptide & rhs)
00088       {
00089         if (&rhs != this)
00090         {
00091           sequence = rhs.sequence;
00092           charge = rhs.charge;
00093           spec = rhs.spec;
00094           hits = rhs.hits;
00095         }
00096         return *this;
00097       }
00098 
00099       AASequence sequence;
00100       Int charge;
00101       RichPeakSpectrum spec;
00102 
00103       std::vector<PeptideHit> hits;
00104 
00105       bool operator<(const Peptide & peptide) const
00106       {
00107         if (sequence < peptide.sequence)
00108         {
00109           return true;
00110         }
00111         else
00112         {
00113           if (sequence == peptide.sequence)
00114           {
00115             return charge < peptide.charge;
00116           }
00117         }
00118         return false;
00119       }
00120 
00121     };
00122 
00126     struct Option
00127     {
00129       enum Type
00130       {
00131         INT = 0,
00132         DOUBLE = 1,
00133         BOOL = 2,
00134         STRINGLIST = 3
00135       };
00136 
00138       Option() :
00139         type(INT),
00140         int_min(0),
00141         int_max(0),
00142         int_stepsize(0),
00143         dbl_min(0),
00144         dbl_max(0),
00145         dbl_stepsize(0)
00146       {
00147       }
00148 
00150       Option(const Option & rhs) :
00151         type(rhs.type),
00152         int_min(rhs.int_min),
00153         int_max(rhs.int_max),
00154         int_stepsize(rhs.int_stepsize),
00155         dbl_min(rhs.dbl_min),
00156         dbl_max(rhs.dbl_max),
00157         dbl_stepsize(rhs.dbl_stepsize)
00158       {
00159       }
00160 
00162       Option(Type t, DoubleReal min, DoubleReal max, DoubleReal stepsize)
00163       {
00164         type = t;
00165         if (type == INT)
00166         {
00167           int_min = (Int)min;
00168           int_max = (Int)max;
00169           int_stepsize = (Int)stepsize;
00170         }
00171         else
00172         {
00173           if (type == DOUBLE)
00174           {
00175             dbl_min = min;
00176             dbl_max = max;
00177             dbl_stepsize = stepsize;
00178           }
00179           else
00180           {
00181             std::cerr << "Type: " << t << " is not known!" << std::endl;
00182           }
00183         }
00184       }
00185 
00187       Option & operator=(const Option & rhs)
00188       {
00189         if (&rhs != this)
00190         {
00191           type = rhs.type;
00192           int_min = rhs.int_min;
00193           int_max = rhs.int_max;
00194           int_stepsize = rhs.int_stepsize;
00195           dbl_min = rhs.dbl_min;
00196           dbl_max = rhs.dbl_max;
00197           dbl_stepsize = rhs.dbl_stepsize;
00198         }
00199         return *this;
00200       }
00201 
00202       Type type;
00203       Int int_min;
00204       Int int_max;
00205       Int int_stepsize;
00206       DoubleReal dbl_min;
00207       DoubleReal dbl_max;
00208       DoubleReal dbl_stepsize;
00209     };
00210 
00211 
00215 
00216     PILISCrossValidation();
00217 
00219     PILISCrossValidation(const PILISCrossValidation & rhs);
00220 
00222     virtual ~PILISCrossValidation();
00223 
00225     PILISCrossValidation & operator=(const PILISCrossValidation & rhs);
00227 
00231 
00232     void setOptions(const Map<String, Option> & rhs)
00233     {
00234       cv_options_ = rhs;
00235     }
00236 
00238     void setOption(const String & name, const Option & option)
00239     {
00240       cv_options_[name] = option;
00241     }
00242 
00244     void apply(Param & PILIS_param, const PILISModel & base_model, const std::vector<Peptide> & peptides);
00245 
00247     DoubleReal scoreHits(const std::vector<std::vector<std::vector<RichPeakSpectrum> > > & sim_spectra, const std::vector<std::vector<RichPeakSpectrum> > & exp_spectra);
00249 
00250 protected:
00251 
00252     DoubleReal scoreSpectra_(const RichPeakSpectrum & spec1, const RichPeakSpectrum & spec2);
00253 
00254     void partition_(std::vector<std::vector<Peptide> > & parts, const std::vector<Peptide> & source);
00255 
00256     void generateParameters_(const Param & param, const Map<String, Option> & options, std::vector<Param> & parameters);
00257 
00258     Map<String, Option> cv_options_;
00259 
00260     void updateMembers_();
00261 
00262     PeakSpectrumCompareFunctor * pscf_;
00263   };
00264 }
00265 
00266 #endif

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