libpappsomspp
Library for mass spectrometry
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"
34
40
46
50
51void
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
95 *the_peptide_p, quantification_method, best_xic_coord, charge, best_rt);
96 }
97}
98
99
100void
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
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
Definition msrunid.h:54
const std::shared_ptr< pappso::IonMobilityGrid > & getIonMobilityGridSp() const
virtual void prepareMeasurementsForPeptide(Peptide &the_peptide, const QuantificationMethodSp &quantification_method, const pappso::XicCoordSPtr &best_xic_coord, std::uint8_t charge, double best_rt) final
const PeptideObservationSp & getPeptideObservationSp() const
PeptideMeasurements(const PeptideObservationSp &peptide_observations)
virtual void detectQuantifyPeaks(const QuantificationMethodSp &quantification_method) override
void prepareMeasurements(const pappso::MsRunId &targeted_msrun, const MsRunGroup *msrun_group_p, const QuantificationMethodSp &quantification_method)
const std::vector< std::uint8_t > & getAllObservedChargeStateList() const
Definition peptide.cpp:116
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:348
const pappso::TraceDetectionInterfaceCstSPtr & getTraceDetectionInterfaceCstSPtr() const
std::shared_ptr< QuantificationMethod > QuantificationMethodSp
@ a
peak detected using a single direct MS2 observation
Definition types.h:46
@ missed
no peak found at all
Definition types.h:60
@ aa
best possible : more than one direct MS2 fragmentation in same MSRUN
Definition types.h:45
std::shared_ptr< PeptideObservation > PeptideObservationSp
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
std::shared_ptr< XicCoord > XicCoordSPtr
Definition xiccoord.h:44