Go to the documentation of this file.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
00029
00030
00031
00032
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