OpenMS  2.4.0
MRMScoring.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-2018.
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: Hannes Roest $
32 // $Authors: Hannes Roest$
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <string>
38 #include <boost/math/special_functions/fpclassify.hpp> // for isnan
39 #include <boost/numeric/conversion/cast.hpp>
40 
41 #include <OpenMS/OPENSWATHALGO/OpenSwathAlgoConfig.h>
42 
48 //#include "OpenMS/OPENSWATHALGO/ALGO/DIAHelpers.h"
49 
50 namespace OpenSwath
51 {
52 
74  class OPENSWATHALGO_DLLAPI MRMScoring
75  {
76 
77 public:
78 
80 
84  typedef std::vector<std::vector<XCorrArrayType> > XCorrMatrixType;
85 
86  typedef std::string String;
87 
92 
93  typedef boost::shared_ptr<OpenSwath::IFeature> FeatureType;
95 
98  const XCorrMatrixType& getXCorrMatrix() const;
101 
103  const XCorrMatrixType& getXCorrContrastMatrix() const;
105 
107  const XCorrMatrixType& getXCorrPrecursorContrastMatrix() const;
109 
111  const XCorrMatrixType& getXCorrPrecursorCombinedMatrix() const;
113 
116  void initializeXCorrMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& native_ids);
118 
120  void initializeXCorrContrastMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& native_ids_set1, const std::vector<String>& native_ids_set2);
121 
123  void initializeXCorrPrecursorMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& precursor_ids);
124 
126  void initializeXCorrPrecursorContrastMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& precursor_ids, const std::vector<String>& native_ids);
127 
129  void initializeXCorrPrecursorCombinedMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& precursor_ids, const std::vector<String>& native_ids);
130 
132  double calcXcorrCoelutionScore();
133 
135  double calcXcorrCoelutionWeightedScore(const std::vector<double>& normalized_library_intensity);
136 
138  double calcXcorrContrastCoelutionScore();
139 
141  std::string calcSeparateXcorrContrastCoelutionScore();
142 
144  double calcXcorrPrecursorCoelutionScore();
145 
147  double calcXcorrPrecursorContrastCoelutionScore();
148 
150  double calcXcorrPrecursorCombinedCoelutionScore();
151 
153  double calcXcorrShapeScore();
154 
156  double calcXcorrShapeWeightedScore(const std::vector<double>& normalized_library_intensity);
157 
159  double calcXcorrContrastShapeScore();
160 
162  std::string calcSeparateXcorrContrastShapeScore();
163 
165  double calcXcorrPrecursorShapeScore();
166 
168  double calcXcorrPrecursorContrastShapeScore();
169 
171  double calcXcorrPrecursorCombinedShapeScore();
172 
174  static void calcLibraryScore(OpenSwath::IMRMFeature* mrmfeature,
175  const std::vector<TransitionType>& transitions, double& correlation,
176  double& norm_manhattan, double& manhattan, double& dotprod,
177  double& spectral_angle, double& rmsd);
178 
180  static double calcRTScore(const PeptideType& peptide, double normalized_experimental_rt);
181 
183  // using a vector of SignalToNoiseEstimatorMedian that were calculated for
184  // each chromatogram of the transition_group.
185  static double calcSNScore(OpenSwath::IMRMFeature* mrmfeature,
186  std::vector<OpenSwath::ISignalToNoisePtr>& signal_noise_estimators);
187 
188  static std::string calcSeparateSNScore(OpenSwath::IMRMFeature* mrmfeature,
189  std::vector<OpenSwath::ISignalToNoisePtr>& signal_noise_estimators);
190 
192  const std::vector< std::vector<double> > & getMIMatrix() const;
194 
196  const std::vector< std::vector<double> > & getMIContrastMatrix() const;
198 
200  const std::vector< std::vector<double> > & getMIPrecursorContrastMatrix() const;
202 
204  const std::vector< std::vector<double> > & getMIPrecursorCombinedMatrix() const;
206 
208  void initializeMIMatrix(OpenSwath::IMRMFeature* mrmfeature, std::vector<String> native_ids);
209 
211  void initializeMIContrastMatrix(OpenSwath::IMRMFeature* mrmfeature, std::vector<String> native_ids_set1, std::vector<String> native_ids_set2);
212 
214  void initializeMIPrecursorMatrix(OpenSwath::IMRMFeature* mrmfeature, std::vector<String> precursor_ids);
215 
217  void initializeMIPrecursorContrastMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& precursor_ids, const std::vector<String>& native_ids);
218 
220  void initializeMIPrecursorCombinedMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& precursor_ids, const std::vector<String>& native_ids);
221 
222  double calcMIScore();
223  double calcMIWeightedScore(const std::vector<double>& normalized_library_intensity);
224  double calcMIPrecursorScore();
225  double calcMIPrecursorContrastScore();
226  double calcMIPrecursorCombinedScore();
227  std::string calcSeparateMIContrastScore();
228 
230 
231 private:
232 
235  XCorrMatrixType xcorr_matrix_;
237 
241 
244 
248 
252 
254  std::vector< std::vector<double> > mi_matrix_;
255 
257  std::vector< std::vector<double> > mi_contrast_matrix_;
258 
260  std::vector< std::vector<double> > mi_precursor_matrix_;
261 
263  std::vector< std::vector<double> > mi_precursor_contrast_matrix_;
265 
267  std::vector< std::vector<double> > mi_precursor_combined_matrix_;
269 
270  };
271 }
272 
std::string String
Definition: MRMScoring.h:86
This class implements different scores for peaks found in SRM/MRM.
Definition: MRMScoring.h:74
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/DataStructures.h:295
std::vector< std::vector< XCorrArrayType > > XCorrMatrixType
Cross Correlation matrix.
Definition: MRMScoring.h:84
std::vector< std::vector< double > > mi_matrix_
the precomputed mutual information matrix
Definition: MRMScoring.h:254
Definition: Scoring.h:61
OpenSwath::SpectrumPtr SpectrumType
Definition: MRMScoring.h:88
Definition: MRMScoring.h:50
boost::shared_ptr< OpenSwath::IFeature > FeatureType
Definition: MRMScoring.h:93
std::vector< std::vector< double > > mi_precursor_contrast_matrix_
the precomputed contrast mutual information matrix against the MS1 trace
Definition: MRMScoring.h:263
XCorrMatrixType xcorr_precursor_matrix_
the precomputed cross correlation matrix of the MS1 trace
Definition: MRMScoring.h:243
std::vector< std::vector< double > > mi_precursor_matrix_
the precomputed mutual information matrix of the MS1 trace
Definition: MRMScoring.h:260
Definition: TransitionExperiment.h:149
Definition: TransitionExperiment.h:46
XCorrMatrixType xcorr_contrast_matrix_
the precomputed contrast cross correlation
Definition: MRMScoring.h:239
Definition: ITransition.h:55
OpenSwath::LightTransition TransitionType
Definition: MRMScoring.h:89
XCorrMatrixType xcorr_precursor_combined_matrix_
the precomputed cross correlation with the MS1 trace
Definition: MRMScoring.h:250
OpenSwath::LightCompound PeptideType
Definition: MRMScoring.h:90
XCorrMatrixType xcorr_precursor_contrast_matrix_
the precomputed cross correlation against the MS1 trace
Definition: MRMScoring.h:246
OpenSwath::LightProtein ProteinType
Definition: MRMScoring.h:91
std::vector< std::vector< double > > mi_contrast_matrix_
the precomputed contrast mutual information matrix
Definition: MRMScoring.h:257
Definition: TransitionExperiment.h:200
std::vector< std::vector< double > > mi_precursor_combined_matrix_
the precomputed contrast mutual information matrix with the MS1 trace
Definition: MRMScoring.h:267