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
29namespace pappso
30{
31
32template <class T>
34{
37 double intensity;
38};
39
40
41template <class T>
43{
44 private:
46 {
50 };
51
53 {
54 maximum_intensity,
55 weighted_intensity,
56 last
57 };
58
59 public:
60 MsRunRetentionTime(MsRunReaderSPtr msrun_reader_sp);
63
64 pappso::MsRunReaderSPtr getMsRunReaderSPtr() const;
65 const MsRunId &getMsRunId() const;
66
67 void setMs2MedianFilter(const FilterMorphoMedian &ms2MedianFilter);
68 void setMs2MeanFilter(const FilterMorphoMean &ms2MeanFilter);
69 void setMs1MeanFilter(const FilterMorphoMean &ms1MeanFilter);
70
71 const FilterMorphoMedian &getMs2MedianFilter() const;
72 const FilterMorphoMean &getMs2MeanFilter() const;
73 const FilterMorphoMean &getMs1MeanFilter() const;
74
75 Trace getCommonDeltaRt(
76 const std::vector<MsRunRetentionTimeSeamarkPoint<T>> &other_seamarks) const;
77
78 /** @brief collects all peptide evidences of a given MSrun
79 * seamarks has to be converted to peptide retention time using
80 * computePeptideRetentionTimes
81 *
82 * @param peptide_id unique identifier (whichever type) of a peptide
83 * @param ms2_spectrum_index associated MS2 spectrum index ot this peptide
84 */
85 void addPeptideAsSeamark(const T &peptide_id, std::size_t ms2_spectrum_index);
86
87
88 /** @brief collects all peptide evidences of a given MSrun
89 * seamarks has to be converted to peptide retention time using
90 * computePeptideRetentionTimes
91 *
92 * @param peptide_id unique identifier (whichever type) of a peptide
93 * @param retentionTime retention time of this peptide observation
94 * @param precursorIntensity MS2 precursorIntensity of this peptide
95 */
96 void addPeptideAsSeamark(const T &peptide_id,
97 double retentionTime,
98 double precursorIntensity);
99
100
101 std::size_t getNumberOfCorrectedValues() const;
102
103 /** @brief align the current msrunretentiontime object using the given
104 * reference
105 * @param msrun_retention_time_reference the reference
106 * @return a trace containing aligned MS1 retention times
107 */
108 Trace align(const MsRunRetentionTime<T> &msrun_retention_time_reference);
109
110 /** @brief get common seamarks between msrunretentiontime objects and their
111 * deltart
112 * @param msrun_retention_time_reference the reference
113 * @return a trace containing MS2 common points and their deltart
114 */
115 Trace getCommonSeamarksDeltaRt(
116 const MsRunRetentionTime<T> &msrun_retention_time_reference) const;
117
118 const std::vector<MsRunRetentionTimeSeamarkPoint<T>> &getSeamarks() const;
119
120 /** @brief get aligned retention time vector
121 * @return vector of seconds (as double)
122 */
123 const std::vector<double> &getAlignedRetentionTimeVector() const;
124
125 void setAlignedRetentionTimeVector(const std::vector<double> &aligned_times);
126
127 /** @brief get orginal retention time vector (not aligned)
128 * @return vector of seconds (as double)
129 */
130 const std::vector<double> &getMs1RetentionTimeVector() const;
131
132 bool isAligned() const;
133
134 double
135 translateOriginal2AlignedRetentionTime(double original_retention_time) const;
136
137
138 double
139 translateAligned2OriginalRetentionTime(double aligned_retention_time) const;
140
141 /** @brief convert PeptideMs2Point into Peptide seamarks
142 * this is required before computing alignment
143 */
144 void computeSeamarks();
145
146 protected:
147 double getFrontRetentionTimeReference() const;
148 double getBackRetentionTimeReference() const;
149 const std::vector<MsRunRetentionTimeSeamarkPoint<T>>
150 getSeamarksReferences() const;
151
152 private:
153 /** @brief get a trace of common MS2 retention times (x values) by their
154 * deltart (y values)
155 * @param delta_rt the trace result (common MS2 retention times vs counter
156 * part deltart)
157 * @param other_seamarks seamarks of the counter part (reference)
158 */
159 void getCommonDeltaRt(
160 Trace &delta_rt,
161 const std::vector<MsRunRetentionTimeSeamarkPoint<T>> &other_seamarks) const;
162 void correctNewTimeValues(Trace &ms1_aligned_points,
163 double correction_parameter);
164
165 void linearRegressionMs2toMs1(Trace &ms1_aligned_points,
166 const Trace &common_points);
167
168 private:
174 std::vector<double> m_ms1RetentionTimeVector;
175 std::vector<double> m_alignedRetentionTimeVector;
176
177 std::vector<MsRunRetentionTimeSeamarkPoint<T>> m_seamarks;
178 std::size_t m_valuesCorrected = 0;
179
180 std::vector<PeptideMs2Point> m_allMs2Points;
181
182 ComputeRetentionTimeReference m_retentionTimeReferenceMethod =
183 ComputeRetentionTimeReference::maximum_intensity;
184};
185
186} // namespace pappso
mean filter apply mean of y values inside the window : this results in a kind of smoothing
Definition: filtermorpho.h:210
median filter apply median of y values inside the window
Definition: filtermorpho.h:191
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
Definition: msrunid.h:53
std::vector< double > m_alignedRetentionTimeVector
std::vector< PeptideMs2Point > m_allMs2Points
pappso::MsRunReaderSPtr msp_msrunReader
std::vector< MsRunRetentionTimeSeamarkPoint< T > > m_seamarks
std::vector< double > m_ms1RetentionTimeVector
FilterMorphoMedian m_ms2MedianFilter
pappso::MsRunIdCstSPtr mcsp_msrunId
A simple container of DataPoint instances.
Definition: trace.h:38
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< MsRunReader > MsRunReaderSPtr
Definition: msrunreader.h:184
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition: msrunid.h:45