libpappsomspp
Library for mass spectrometry
msrunretentiontime.h
Go to the documentation of this file.
1 
2 /*******************************************************************************
3  * Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.fr>.
4  *
5  * This file is part of the PAPPSOms++ library.
6  *
7  * PAPPSOms++ is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * PAPPSOms++ is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
19  *
20  ******************************************************************************/
21 
22 #pragma once
23 
24 #include "../msrunid.h"
25 #include "../msrunreader.h"
26 #include <vector>
27 #include "../../processing/filters/filtermorpho.h"
28 
29 namespace pappso
30 {
31 
32 struct RtPoint
33 {
34  double retentionTime;
35  std::size_t spectrumIndex;
36 };
37 
38 
39 template <class T>
41 {
43  double retentionTime;
44  double intensity;
45 };
46 
47 
48 template <class T>
50 {
51  private:
53  {
54  double retentionTime;
57  };
58 
60  {
61  maximum_intensity,
62  weighted_intensity,
63  last
64  };
65 
66  public:
67  MsRunRetentionTime(MsRunReaderSPtr msrun_reader_sp);
70 
71  pappso::MsRunReaderSPtr getMsRunReaderSPtr() const;
72 
73  void setMs2MedianFilter(const FilterMorphoMedian &ms2MedianFilter);
74  void setMs2MeanFilter(const FilterMorphoMean &ms2MeanFilter);
75  void setMs1MeanFilter(const FilterMorphoMean &ms1MeanFilter);
76 
77  Trace getCommonDeltaRt(
78  const std::vector<MsRunRetentionTimeSeamarkPoint<T>> &other_seamarks) const;
79 
80  /** @brief collects all peptide evidences of a given MSrun
81  * seamarks has to be converted to peptide retention time using
82  * computePeptideRetentionTimes
83  */
84  void addPeptideAsSeamark(const T &peptide_str,
85  std::size_t ms2_spectrum_index);
86 
87  /** @brief convert Peptide seamarks into PeptideMs2Point
88  * this is required before computing alignment
89  */
90  void computePeptideRetentionTimes();
91 
92  std::size_t getNumberOfCorrectedValues() const;
93 
94  Trace align(const MsRunRetentionTime<T> &msrun_retention_time_reference);
95 
96  const std::vector<MsRunRetentionTimeSeamarkPoint<T>> &getSeamarks() const;
97  const std::vector<double> &getAlignedRetentionTimeVector() const;
98  const std::vector<RtPoint> &getMs1RetentionTimeVector() const;
99 
100  bool isAligned() const;
101 
102  double
103  translateOriginal2AlignedRetentionTime(double original_retention_time) const;
104 
105  protected:
106  double getFrontRetentionTimeReference() const;
107  double getBackRetentionTimeReference() const;
108  const std::vector<MsRunRetentionTimeSeamarkPoint<T>>
109  getSeamarksReferences() const;
110 
111  private:
112  void getCommonDeltaRt(
113  Trace &delta_rt,
114  const std::vector<MsRunRetentionTimeSeamarkPoint<T>> &other_seamarks) const;
115  void correctNewTimeValues(Trace &ms1_aligned_points,
116  double correction_parameter);
117 
118  void linearRegressionMs2toMs1(Trace &ms1_aligned_points,
119  const Trace &common_points);
120 
121  private:
127  std::vector<RtPoint> m_ms1RetentionTimeVector;
128  std::vector<double> m_alignedRetentionTimeVector;
129 
130  std::vector<MsRunRetentionTimeSeamarkPoint<T>> m_seamarks;
131  std::size_t m_valuesCorrected = 0;
132 
133  std::vector<PeptideMs2Point> m_allMs2Points;
134 
135  ComputeRetentionTimeReference m_retentionTimeReferenceMethod =
136  ComputeRetentionTimeReference::maximum_intensity;
137 };
138 
139 } // namespace pappso
pappso::MsRunRetentionTime::PeptideMs2Point::precursorIntensity
double precursorIntensity
Definition: msrunretentiontime.h:55
pappso::MsRunRetentionTime::msp_msrunReader
pappso::MsRunReaderSPtr msp_msrunReader
Definition: msrunretentiontime.h:125
pappso::MsRunRetentionTime::PeptideMs2Point
Definition: msrunretentiontime.h:53
pappso::MsRunRetentionTime::PeptideMs2Point::retentionTime
double retentionTime
Definition: msrunretentiontime.h:54
pappso::MsRunRetentionTimeSeamarkPoint::retentionTime
double retentionTime
Definition: msrunretentiontime.h:43
pappso::FilterMorphoMedian
median filter apply median of y values inside the window
Definition: filtermorpho.h:178
pappso::MsRunRetentionTimeSeamarkPoint::intensity
double intensity
Definition: msrunretentiontime.h:44
pappso::MsRunRetentionTimeSeamarkPoint::entityHash
T entityHash
Definition: msrunretentiontime.h:42
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition: exportinmportconfig.h:14
pappso::MsRunRetentionTime::m_allMs2Points
std::vector< PeptideMs2Point > m_allMs2Points
Definition: msrunretentiontime.h:133
pappso::RtPoint::spectrumIndex
std::size_t spectrumIndex
Definition: msrunretentiontime.h:35
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks
Definition: aa.cpp:39
pappso::MsRunReaderSPtr
std::shared_ptr< MsRunReader > MsRunReaderSPtr
Definition: msrunreader.h:151
pappso::MsRunIdCstSPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition: msrunid.h:44
pappso::QualifiedMassSpectrumParameter::OneOverK0
@ OneOverK0
1/kO of a simple scan
pappso::MsRunRetentionTime::m_ms2MeanFilter
FilterMorphoMean m_ms2MeanFilter
Definition: msrunretentiontime.h:123
pappso::MsRunRetentionTime::m_ms1RetentionTimeVector
std::vector< RtPoint > m_ms1RetentionTimeVector
Definition: msrunretentiontime.h:127
pappso::MsRunRetentionTimeSeamarkPoint
Definition: msrunretentiontime.h:41
pappso::MsRunRetentionTime::m_ms2MedianFilter
FilterMorphoMedian m_ms2MedianFilter
Definition: msrunretentiontime.h:122
pappso::Trace
A simple container of DataPoint instances.
Definition: trace.h:132
pappso::MsRunRetentionTime
Definition: msrunretentiontime.h:50
pappso::RtPoint
Definition: msrunretentiontime.h:33
pappso::FilterMorphoMean
mean filter apply mean of y values inside the window : this results in a kind of smoothing
Definition: filtermorpho.h:197
pappso::RtPoint::retentionTime
double retentionTime
Definition: msrunretentiontime.h:34
pappso::MsRunRetentionTime::ComputeRetentionTimeReference
ComputeRetentionTimeReference
Definition: msrunretentiontime.h:60
pappso::MsRunRetentionTime::m_ms1MeanFilter
FilterMorphoMean m_ms1MeanFilter
Definition: msrunretentiontime.h:124
pappso::MsRunRetentionTime::m_alignedRetentionTimeVector
std::vector< double > m_alignedRetentionTimeVector
Definition: msrunretentiontime.h:128
pappso::MsRunRetentionTime::mcsp_msrunId
pappso::MsRunIdCstSPtr mcsp_msrunId
Definition: msrunretentiontime.h:126
pappso::MsRunRetentionTime::PeptideMs2Point::entityHash
T entityHash
Definition: msrunretentiontime.h:56
pappso::MsRunRetentionTime::m_seamarks
std::vector< MsRunRetentionTimeSeamarkPoint< T > > m_seamarks
Definition: msrunretentiontime.h:130