Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
InternalCalibration.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-2017.
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: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_FILTERING_CALIBRATION_INTERNALCALIBRATION_H
36 #define OPENMS_FILTERING_CALIBRATION_INTERNALCALIBRATION_H
37 
44 
45 #include <vector>
46 
47 namespace OpenMS
48 {
49 
50  class FeatureMap;
51 
62  class OPENMS_DLLAPI InternalCalibration
63  : public ProgressLogger
64  {
65  public:
66 
69 
72 
74  struct LockMass
75  {
76  double mz; //< m/z of the lock mass (incl. adducts)
77  unsigned int ms_level; //< MS level where it occurs
78  int charge; //< charge of the ion (to find isotopes)
79 
80  LockMass(double mz_, int lvl_, int charge_)
81  : mz(mz_),
82  ms_level(lvl_),
83  charge(charge_)
84  {}
85  };
86 
87 
88 
111  Size fillCalibrants(const PeakMap exp,
112  const std::vector<InternalCalibration::LockMass>& ref_masses,
113  double tol_ppm,
114  bool lock_require_mono,
115  bool lock_require_iso,
116  CalibrationData& failed_lock_masses,
117  bool verbose = true);
118 
140  Size fillCalibrants(const FeatureMap& fm, double tol_ppm);
141 
157  Size fillCalibrants(const std::vector<PeptideIdentification>& pep_ids, double tol_ppm);
158 
167  const CalibrationData& getCalibrationPoints() const;
168 
193  bool calibrate(PeakMap& exp,
194  const IntList& target_mslvl,
195  MZTrafoModel::MODELTYPE model_type,
196  double rt_chunk,
197  bool use_RANSAC,
198  double post_ppm_median,
199  double post_ppm_MAD,
200  const String& file_models = "",
201  const String& file_models_plot = "",
202  const String& file_residuals = "",
203  const String& file_residuals_plot = "",
204  const String& rscript_executable = "Rscript");
205 
206  /*
207  @brief Transform a precursor's m/z
208 
209  Calibrate m/z of precursors.
210 
211  @param pcs Uncalibrated Precursors
212  @param trafo The calibration function to apply
213  */
214  static void applyTransformation(std::vector<Precursor>& pcs, const MZTrafoModel& trafo);
215 
216  /*
217  @brief Transform a spectrum (data+precursor)
218 
219  See applyTransformation(MSExperiment, ...) for details.
220 
221  @param spec Uncalibrated MSSpectrum
222  @param target_mslvl List (can be unsorted) of MS levels to calibrate
223  @param trafo The calibration function to apply
224  */
225  static void applyTransformation(PeakMap::SpectrumType& spec, const IntList& target_mslvl, const MZTrafoModel& trafo);
226 
227  /*
228  @brief Transform spectra from a whole map (data+precursor)
229 
230  All data peaks and precursor information (if present) are calibrated in m/z.
231 
232  Only spectra whose MS-level is contained in 'target_mslvl' are calibrated.
233  In addition, if a fragmentation spectrum's precursor information originates from an MS level in 'target_mslvl',
234  the precursor (not the spectrum itself) is also subjected to calibration.
235  E.g., If we only have MS and MS/MS spectra: for 'target_mslvl' = {1} then all MS1 spectra and MS2 precursors are calibrated.
236  If 'target_mslvl' = {2}, only MS2 spectra (not their precursors) are calibrated.
237  If 'target_mslvl' = {1,2} all spectra and precursors are calibrated.
238 
239 
240  @param exp Uncalibrated peak map
241  @param target_mslvl List (can be unsorted) of MS levels to calibrate
242  @param trafo The calibration function to apply
243  */
244  static void applyTransformation(PeakMap& exp, const IntList& target_mslvl, const MZTrafoModel& trafo);
245 
246  protected:
262  void fillIDs_( const std::vector<PeptideIdentification>& pep_ids, double tol_ppm );
263 
264  /*
265  @brief Calibrate m/z of a spectrum, ignoring precursors!
266 
267  This method is not exposed as public, because its easy to be misused on spectra while forgetting about the precursors of high-level spectra.
268  */
269  static void applyTransformation_(PeakMap::SpectrumType& spec, const MZTrafoModel& trafo);
270 
271  private:
273 
274 
275  }; // class InternalCalibration
276 
277 } // namespace OpenMS
278 
279 #endif // OPENMS_FILTERING_CALIBRATION_INTERNALCALIBRATION_H
A more convenient string class.
Definition: String.h:57
MODELTYPE
Definition: MZTrafoModel.h:99
A container for features.
Definition: FeatureMap.h:94
A mass recalibration method using linear/quadratic interpolation (robust/weighted) of given reference...
Definition: InternalCalibration.h:62
std::vector< Int > IntList
Vector of signed integers.
Definition: ListUtils.h:59
Create and apply models of a mass recalibration function.
Definition: MZTrafoModel.h:67
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
int charge
Definition: InternalCalibration.h:78
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
~InternalCalibration()
Destructor.
Definition: InternalCalibration.h:71
helper class, describing a lock mass
Definition: InternalCalibration.h:74
A helper class, holding all calibration points.
Definition: CalibrationData.h:65
unsigned int ms_level
Definition: InternalCalibration.h:77
double mz
Definition: InternalCalibration.h:76
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:82
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
CalibrationData cal_data_
Definition: InternalCalibration.h:272
LockMass(double mz_, int lvl_, int charge_)
Definition: InternalCalibration.h:80
int verbose
Verbosity level ( "-v" is 1 and "-V" is 2 )

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:01 using doxygen 1.8.13