libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
peptidemeasurements.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/masschroq/peptidemeasurements.cpp
3
* \date 26/09/2024
4
* \author Olivier Langella
5
* \brief peptide extracted measures model in masschroqlite
6
*/
7
8
/*******************************************************************************
9
* Copyright (c) 2024 Olivier Langella
10
*<Olivier.Langella@universite-paris-saclay.fr>.
11
*
12
* This file is part of MassChroQ.
13
*
14
* MassChroQ is free software: you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License as published by
16
* the Free Software Foundation, either version 3 of the License, or
17
* (at your option) any later version.
18
*
19
* MassChroQ is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
23
*
24
* You should have received a copy of the GNU General Public License
25
* along with MassChroQ. If not, see <http://www.gnu.org/licenses/>.
26
*
27
******************************************************************************/
28
29
#include "
peptidemeasurements.h
"
30
#include "
peptideobservation.h
"
31
#include "
msrungroup.h
"
32
#include "
pappsomspp/core/processing/detection/tracepeaklist.h
"
33
#include "
pappsomspp/core/pappsoexception.h
"
34
35
pappso::masschroq::PeptideMeasurements::PeptideMeasurements
(
36
const
pappso::masschroq::PeptideObservationSp
&peptide)
37
{
38
msp_peptideObservation
= peptide;
39
}
40
41
pappso::masschroq::PeptideMeasurements::PeptideMeasurements
(
const
PeptideMeasurements
&other)
42
:
PeptideMeasurementsBase
(other)
43
{
44
msp_peptideObservation
= other.
msp_peptideObservation
;
45
}
46
47
pappso::masschroq::PeptideMeasurements::~PeptideMeasurements
()
48
{
49
}
50
51
void
52
pappso::masschroq::PeptideMeasurements::prepareMeasurements
(
53
const
pappso::MsRunId
&targeted_msrun,
54
const
pappso::masschroq::MsRunGroup
*msrun_group_p,
55
const
QuantificationMethodSp
&quantification_method)
56
{
57
// for one peptide
58
pappso::masschroq::Peptide
*the_peptide_p =
msp_peptideObservation
.get()->getPeptideSp().get();
59
// 1) charge states
60
// 2) isotope list
61
std::vector<std::uint8_t> charge_states = the_peptide_p->
getAllObservedChargeStateList
();
62
63
double
best_rt =
msp_peptideObservation
.get()->getBestRtOverallChargeStates();
64
65
66
pappso::XicCoordSPtr
best_xic_coord =
msp_peptideObservation
.get()->getBestXicCoord();
67
68
if
(best_xic_coord.get() ==
nullptr
)
69
{
70
throw
pappso::PappsoException
(
"best_xic_coord.get() == nullptr"
);
71
}
72
73
for
(std::uint8_t charge : charge_states)
74
{
75
76
if
(msrun_group_p->
getIonMobilityGridSp
().get() !=
nullptr
)
77
{
78
// Ion mobility TimsTOF coordinates
79
best_xic_coord =
msp_peptideObservation
.get()->getBestXicCoordSPtrForCharge(charge);
80
81
if
(best_xic_coord.get() ==
nullptr
)
82
{
83
// now in this ms run, we do not have ion mobility index for
84
// this charge we must chek out in other msrun for this charge
85
best_xic_coord = the_peptide_p->
getBestIonMobilityXicCoordToExtractOverallMsRunGroup
(
86
*msrun_group_p, targeted_msrun, charge);
87
}
88
if
(best_xic_coord.get() ==
nullptr
)
89
continue
;
90
91
best_xic_coord.get()->rtTarget = best_rt;
92
}
93
94
prepareMeasurementsForPeptide
(
95
*the_peptide_p, quantification_method, best_xic_coord, charge, best_rt);
96
}
97
}
98
99
100
void
101
pappso::masschroq::PeptideMeasurements::detectQuantifyPeaks
(
102
const
QuantificationMethodSp
&quantification_method)
103
{
104
105
qDebug();
106
pappso::TracePeakList
peak_list;
107
std::vector<double> observed_rt_list =
108
msp_peptideObservation
.get()->getObservedRetentionTimesOverallChargeStates();
109
110
std::vector<std::uint8_t> observed_charge_states =
111
msp_peptideObservation
->getObservedChargeStates();
112
113
for
(
auto
&measure_one :
m_measurementList
)
114
{
115
qDebug();
116
pappso::Xic
*xic_p = measure_one.msp_xicCoord.get()->xicSptr.get();
117
if
(xic_p ==
nullptr
)
118
{
119
throw
pappso::PappsoException
(QObject::tr(
"xic_p == nullptr"
));
120
}
121
peak_list.clear();
122
std::size_t nb_peaks = 0;
123
quantification_method.get()->
getTraceDetectionInterfaceCstSPtr
().get()->detect(
124
*xic_p, peak_list,
false
);
125
126
qDebug();
127
auto
it_best_matched_peak =
findBestTracePeakGivenRtList
(
128
peak_list.begin(), peak_list.end(), observed_rt_list, nb_peaks);
129
130
qDebug();
131
measure_one.m_peakQualityCategory =
PeakQualityCategory::missed
;
132
bool
direct_charge_observation_in_msrun =
true
;
133
if
(observed_charge_states.end() ==
134
find(observed_charge_states.begin(), observed_charge_states.end(), measure_one.m_charge))
135
{
136
direct_charge_observation_in_msrun =
false
;
137
}
138
if
(it_best_matched_peak != peak_list.end())
139
{
140
measure_one.m_tracePeakSp = it_best_matched_peak->makeTracePeakCstSPtr();
141
if
(nb_peaks == 1)
142
{
143
144
measure_one.m_peakQualityCategory =
PeakQualityCategory::za
;
145
if
(direct_charge_observation_in_msrun)
146
measure_one.m_peakQualityCategory =
PeakQualityCategory::a
;
147
148
if
(observed_rt_list.size() > 1)
149
{
150
measure_one.m_peakQualityCategory =
PeakQualityCategory::zaa
;
151
if
(direct_charge_observation_in_msrun)
152
measure_one.m_peakQualityCategory =
PeakQualityCategory::aa
;
153
}
154
}
155
else
if
(nb_peaks > 1)
156
{
157
measure_one.m_peakQualityCategory =
PeakQualityCategory::zab
;
158
if
(direct_charge_observation_in_msrun)
159
measure_one.m_peakQualityCategory =
PeakQualityCategory::ab
;
160
}
161
}
162
}
163
}
164
165
const
pappso::masschroq::PeptideObservationSp
&
166
pappso::masschroq::PeptideMeasurements::getPeptideObservationSp
()
const
167
{
168
return
msp_peptideObservation
;
169
}
pappso::MsRunId
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
Definition
msrunid.h:54
pappso::PappsoException
Definition
pappsoexception.h:41
pappso::TracePeakList
Definition
tracepeaklist.h:43
pappso::Xic
Definition
xic.h:44
pappso::masschroq::MsRunGroup
Definition
msrungroup.h:48
pappso::masschroq::MsRunGroup::getIonMobilityGridSp
const std::shared_ptr< pappso::IonMobilityGrid > & getIonMobilityGridSp() const
Definition
msrungroup.cpp:334
pappso::masschroq::PeptideMeasurementsBase::m_measurementList
std::vector< Measurement > m_measurementList
Definition
peptidemeasurementsbase.h:117
pappso::masschroq::PeptideMeasurementsBase::PeptideMeasurementsBase
PeptideMeasurementsBase()
Definition
peptidemeasurementsbase.cpp:34
pappso::masschroq::PeptideMeasurementsBase::prepareMeasurementsForPeptide
virtual void prepareMeasurementsForPeptide(Peptide &the_peptide, const QuantificationMethodSp &quantification_method, const pappso::XicCoordSPtr &best_xic_coord, std::uint8_t charge, double best_rt) final
Definition
peptidemeasurementsbase.cpp:89
pappso::masschroq::PeptideMeasurements::msp_peptideObservation
PeptideObservationSp msp_peptideObservation
Definition
peptidemeasurements.h:88
pappso::masschroq::PeptideMeasurements::getPeptideObservationSp
const PeptideObservationSp & getPeptideObservationSp() const
Definition
peptidemeasurements.cpp:166
pappso::masschroq::PeptideMeasurements::~PeptideMeasurements
virtual ~PeptideMeasurements()
Definition
peptidemeasurements.cpp:47
pappso::masschroq::PeptideMeasurements::PeptideMeasurements
PeptideMeasurements(const PeptideObservationSp &peptide_observations)
Definition
peptidemeasurements.cpp:35
pappso::masschroq::PeptideMeasurements::detectQuantifyPeaks
virtual void detectQuantifyPeaks(const QuantificationMethodSp &quantification_method) override
Definition
peptidemeasurements.cpp:101
pappso::masschroq::PeptideMeasurements::prepareMeasurements
void prepareMeasurements(const pappso::MsRunId &targeted_msrun, const MsRunGroup *msrun_group_p, const QuantificationMethodSp &quantification_method)
Definition
peptidemeasurements.cpp:52
pappso::masschroq::Peptide
Definition
peptide.h:58
pappso::masschroq::Peptide::getAllObservedChargeStateList
const std::vector< std::uint8_t > & getAllObservedChargeStateList() const
Definition
peptide.cpp:116
pappso::masschroq::Peptide::getBestIonMobilityXicCoordToExtractOverallMsRunGroup
pappso::XicCoordSPtr getBestIonMobilityXicCoordToExtractOverallMsRunGroup(const MsRunGroup &msrun_group, const pappso::MsRunId &targeted_msrun, std::uint8_t charge) const
get ion mobility coordinates corrected against other MSruns in the group
Definition
peptide.cpp:351
pappso::masschroq::QuantificationMethod::getTraceDetectionInterfaceCstSPtr
const pappso::TraceDetectionInterfaceCstSPtr & getTraceDetectionInterfaceCstSPtr() const
Definition
quantificationmethod.cpp:199
msrungroup.h
pappso::masschroq::QuantificationMethodSp
std::shared_ptr< QuantificationMethod > QuantificationMethodSp
Definition
quantificationmethod.h:46
pappso::masschroq::PeakQualityCategory::a
@ a
peak detected using a single direct MS2 observation
Definition
types.h:46
pappso::masschroq::PeakQualityCategory::ab
@ ab
Definition
types.h:47
pappso::masschroq::PeakQualityCategory::missed
@ missed
no peak found at all
Definition
types.h:60
pappso::masschroq::PeakQualityCategory::aa
@ aa
best possible : more than one direct MS2 fragmentation in same MSRUN
Definition
types.h:45
pappso::masschroq::PeakQualityCategory::zab
@ zab
Definition
types.h:51
pappso::masschroq::PeakQualityCategory::za
@ za
Definition
types.h:50
pappso::masschroq::PeakQualityCategory::zaa
@ zaa
Definition
types.h:49
pappso::masschroq::PeptideObservationSp
std::shared_ptr< PeptideObservation > PeptideObservationSp
Definition
peptidemeasurements.h:45
pappso::findBestTracePeakGivenRtList
PMSPP_LIB_DECL std::vector< TracePeak >::iterator findBestTracePeakGivenRtList(std::vector< TracePeak >::iterator begin, std::vector< TracePeak >::iterator end, const std::vector< double > &rt_list, std::size_t &nb_peaks)
find the best peak matching a list of retention times
Definition
tracepeaklist.cpp:54
pappso::XicCoordSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition
xiccoord.h:44
pappsoexception.h
peptidemeasurements.h
peptideobservation.h
tracepeaklist.h
pappsomspp
core
masschroq
peptidemeasurements.cpp
Generated on
for libpappsomspp by
1.17.0