Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
PILISCrossValidation.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-2013.
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: Andreas Bertsch $
32 // $Authors: Andreas Bertsch $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_ANALYSIS_ID_PILISCROSSVALIDATION_H
36 #define OPENMS_ANALYSIS_ID_PILISCROSSVALIDATION_H
37 
40 
41 #include <iostream>
42 #include <vector>
43 
44 namespace OpenMS
45 {
46  class PeakSpectrumCompareFunctor;
47  class PILISModel;
48 
49 
58  class OPENMS_DLLAPI PILISCrossValidation :
59  public DefaultParamHandler
60  {
61 
62 public:
63 
67  struct Peptide
68  {
69  Peptide() :
70  charge(0)
71  {
72 
73  }
74 
75  Peptide(const Peptide & rhs) :
76  sequence(rhs.sequence),
77  charge(rhs.charge),
78  spec(rhs.spec),
79  hits(rhs.hits)
80  {
81  }
82 
83  virtual ~Peptide()
84  {
85  }
86 
87  Peptide & operator=(const Peptide & rhs)
88  {
89  if (&rhs != this)
90  {
91  sequence = rhs.sequence;
92  charge = rhs.charge;
93  spec = rhs.spec;
94  hits = rhs.hits;
95  }
96  return *this;
97  }
98 
102 
103  std::vector<PeptideHit> hits;
104 
105  bool operator<(const Peptide & peptide) const
106  {
107  if (sequence < peptide.sequence)
108  {
109  return true;
110  }
111  else
112  {
113  if (sequence == peptide.sequence)
114  {
115  return charge < peptide.charge;
116  }
117  }
118  return false;
119  }
120 
121  };
122 
126  struct Option
127  {
129  enum Type
130  {
131  INT = 0,
132  DOUBLE = 1,
133  BOOL = 2,
134  STRINGLIST = 3
135  };
136 
138  Option() :
139  type(INT),
140  int_min(0),
141  int_max(0),
142  int_stepsize(0),
143  dbl_min(0),
144  dbl_max(0),
145  dbl_stepsize(0)
146  {
147  }
148 
150  Option(const Option & rhs) :
151  type(rhs.type),
152  int_min(rhs.int_min),
153  int_max(rhs.int_max),
154  int_stepsize(rhs.int_stepsize),
155  dbl_min(rhs.dbl_min),
156  dbl_max(rhs.dbl_max),
157  dbl_stepsize(rhs.dbl_stepsize)
158  {
159  }
160 
162  Option(Type t, DoubleReal min, DoubleReal max, DoubleReal stepsize)
163  {
164  type = t;
165  if (type == INT)
166  {
167  int_min = (Int)min;
168  int_max = (Int)max;
169  int_stepsize = (Int)stepsize;
170  }
171  else
172  {
173  if (type == DOUBLE)
174  {
175  dbl_min = min;
176  dbl_max = max;
177  dbl_stepsize = stepsize;
178  }
179  else
180  {
181  std::cerr << "Type: " << t << " is not known!" << std::endl;
182  }
183  }
184  }
185 
187  Option & operator=(const Option & rhs)
188  {
189  if (&rhs != this)
190  {
191  type = rhs.type;
192  int_min = rhs.int_min;
193  int_max = rhs.int_max;
194  int_stepsize = rhs.int_stepsize;
195  dbl_min = rhs.dbl_min;
196  dbl_max = rhs.dbl_max;
197  dbl_stepsize = rhs.dbl_stepsize;
198  }
199  return *this;
200  }
201 
209  };
210 
211 
217 
220 
222  virtual ~PILISCrossValidation();
223 
225  PILISCrossValidation & operator=(const PILISCrossValidation & rhs);
227 
231  void setOptions(const Map<String, Option> & rhs)
233  {
234  cv_options_ = rhs;
235  }
236 
238  void setOption(const String & name, const Option & option)
239  {
240  cv_options_[name] = option;
241  }
242 
244  void apply(Param & PILIS_param, const PILISModel & base_model, const std::vector<Peptide> & peptides);
245 
247  DoubleReal scoreHits(const std::vector<std::vector<std::vector<RichPeakSpectrum> > > & sim_spectra, const std::vector<std::vector<RichPeakSpectrum> > & exp_spectra);
249 
250 protected:
251 
252  DoubleReal scoreSpectra_(const RichPeakSpectrum & spec1, const RichPeakSpectrum & spec2);
253 
254  void partition_(std::vector<std::vector<Peptide> > & parts, const std::vector<Peptide> & source);
255 
256  void generateParameters_(const Param & param, const Map<String, Option> & options, std::vector<Param> & parameters);
257 
259 
260  void updateMembers_();
261 
263  };
264 }
265 
266 #endif
Peptide(const Peptide &rhs)
Definition: PILISCrossValidation.h:75
A more convenient string class.
Definition: String.h:56
Int int_stepsize
Definition: PILISCrossValidation.h:205
Peptide & operator=(const Peptide &rhs)
Definition: PILISCrossValidation.h:87
DoubleReal dbl_stepsize
Definition: PILISCrossValidation.h:208
bool operator<(const Peptide &peptide) const
Definition: PILISCrossValidation.h:105
PeakSpectrumCompareFunctor * pscf_
Definition: PILISCrossValidation.h:262
Representation of a peptide/protein sequence.
Definition: AASequence.h:84
DoubleReal dbl_min
Definition: PILISCrossValidation.h:206
Int charge
Definition: PILISCrossValidation.h:100
this struct represents a peptide spectrum pair
Definition: PILISCrossValidation.h:67
Option & operator=(const Option &rhs)
assignment operator
Definition: PILISCrossValidation.h:187
AASequence sequence
Definition: PILISCrossValidation.h:99
RichPeakSpectrum spec
Definition: PILISCrossValidation.h:101
Map< String, Option > cv_options_
Definition: PILISCrossValidation.h:258
Int int_min
Definition: PILISCrossValidation.h:203
Peptide()
Definition: PILISCrossValidation.h:69
This struct represents a cross validation option.
Definition: PILISCrossValidation.h:126
Type
Type of the parameters.
Definition: PILISCrossValidation.h:129
Option(const Option &rhs)
copy constructor
Definition: PILISCrossValidation.h:150
virtual ~Peptide()
Definition: PILISCrossValidation.h:83
This class implements the simulation of the spectra from PILIS.
Definition: PILISModel.h:67
void setOption(const String &name, const Option &option)
sets a option to be used for the cross validation
Definition: PILISCrossValidation.h:238
Management and storage of parameters / INI files.
Definition: Param.h:69
Int int_max
Definition: PILISCrossValidation.h:204
Option(Type t, DoubleReal min, DoubleReal max, DoubleReal stepsize)
detailed constructors
Definition: PILISCrossValidation.h:162
Base class for compare functors of spectra, that return a similiarity value for two spectra...
Definition: PeakSpectrumCompareFunctor.h:53
Option()
Default constructor.
Definition: PILISCrossValidation.h:138
Type type
Definition: PILISCrossValidation.h:202
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:90
std::vector< PeptideHit > hits
Definition: PILISCrossValidation.h:103
DoubleReal dbl_max
Definition: PILISCrossValidation.h:207
int Int
Signed integer type.
Definition: Types.h:100
Map class based on the STL map (containing serveral convenience functions)
Definition: Map.h:50
Implementation of a cross valdidation training for the PILIS model.
Definition: PILISCrossValidation.h:58

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:19 using doxygen 1.8.5