30#include "../xicextractor/msrunxicextractorfactory.h"
32#include <QtConcurrent>
53 std::size_t spectrum_index,
57 auto it = m_peptideObservationList.insert(
58 {peptide_sp.get(), std::make_shared<pappso::masschroq::PeptideObservation>(peptide_sp)});
60 msp_msRun.get()->getPrecursorSPtrBySpectrumIndex(spectrum_index);
61 it.first->second.get()->addObservation({spectrum_index, charge, precursor_sp,
true, p_label});
63 peptide_sp.get()->addMsRunXicCoordCharge({msp_msRun.get(),
64 precursor_sp.get()->getXicCoordSPtr(),
66 precursor_sp.get()->getIntensity()});
67 qDebug() <<
"m_peptideObservationList.size()=" << m_peptideObservationList.size();
74 std::size_t scan_number,
78 auto it = m_peptideObservationList.insert(
79 {peptide_sp.get(), std::make_shared<pappso::masschroq::PeptideObservation>(peptide_sp)});
81 msp_msRun.get()->getPrecursorSPtrByScanNumber(scan_number);
82 it.first->second.get()->addObservation({scan_number, charge, precursor_sp,
false, p_label});
84 peptide_sp.get()->addMsRunXicCoordCharge({msp_msRun.get(),
85 precursor_sp.get()->getXicCoordSPtr(),
87 precursor_sp.get()->getIntensity()});
88 qDebug() <<
"m_peptideObservationList.size()=" << m_peptideObservationList.size();
93 const QString &tmp_dir,
97 m_peptideMeasurementsList.clear();
99 QString(
"Starting quantification for msrun %1")
100 .arg(msp_msRun.get()->getMsRunReaderSPtr()->getMsRunId().get()->getFileName()));
102 qDebug() << m_peptideObservationList.size();
110 ui_monitor.
appendText(QString(
"Preparing extraction list"));
111 std::vector<pappso::XicCoordSPtr> xic_coord_list =
112 buildXicCoordList(msrun_group_p, quantification_method);
114 ui_monitor.
appendText(QString(
"Preparing extraction list done"));
116 ui_monitor.
appendText(QString(
"Building XIC extractor"));
119 msp_msRun.get()->getMsRunReaderSPtr());
122 extractor_pwiz->setXicExtractMethod(quantification_method.get()->getXicExtractMethod());
126 extractor_pwiz.get()->setRetentionTimeAroundTarget(
127 quantification_method.get()->getXicExtractionRtRange());
133 extractor_pwiz.get()->setPostExtractionTraceFilterCstSPtr(csp_filter_suite);
137 ui_monitor.
appendText(QString(
"Building XIC extractor done"));
139 extractor_pwiz.get()->extractXicCoordSPtrListParallelized(ui_monitor, xic_coord_list);
144 detectQuantifyPeaks(ui_monitor, quantification_method);
148 QString(
"Quantification for msrun %1 done")
149 .arg(msp_msRun.get()->getMsRunReaderSPtr()->getMsRunId().get()->getFileName()));
153std::vector<pappso::XicCoordSPtr>
158 std::vector<pappso::XicCoordSPtr> xic_coord_list;
160 for(
auto pair_peptide : m_peptideObservationList)
164 addPeptideObservation2XicCoordList(
165 msrun_group_p, quantification_method, pair_peptide.second, xic_coord_list);
170 return xic_coord_list;
178 std::vector<pappso::XicCoordSPtr> &xic_coord_list)
181 std::make_shared<pappso::masschroq::PeptideMeasurements>(peptide_events_sp);
183 m_peptideMeasurementsList.push_back(peptide_measurements);
185 peptide_measurements.get()->prepareMeasurements(
186 *(msp_msRun.get()->getMsRunReaderSPtr().get()->getMsRunId().get()),
188 quantification_method);
189 peptide_measurements.get()->pushBackXicCoordList(xic_coord_list);
197 m_uiMonitor.
appendText(QString(
"Detect and quantify peak"));
207 measure->detectQuantifyPeaks(quantification_method);
212 QtConcurrent::map<std::vector<pappso::masschroq::PeptideMeasurementsSp>::iterator>(
213 m_peptideMeasurementsList.begin(), m_peptideMeasurementsList.end(), mapdetectQuantifyPeaks);
214 res.waitForFinished();
217 m_uiMonitor.
appendText(QString(
"Detect and quantify peak done"));
231 for(
auto &measure : m_peptideMeasurementsList)
233 measure.get()->flushXics();
236 for(
auto &mbr_measure : m_mbrPeptideMeasurementsList)
238 mbr_measure.get()->flushXics();
242std::shared_ptr<pappso::MsRunRetentionTime<QString>> &
246 msp_msRunRetentionTime =
247 std::make_shared<pappso::MsRunRetentionTime<QString>>(msp_msRun->getRetentionTimeLine());
249 msp_msRunRetentionTime.get()->setMs2MedianFilter(
251 msp_msRunRetentionTime.get()->setMs2MeanFilter(
253 msp_msRunRetentionTime.get()->setMs1MeanFilter(
257 for(
const auto &observation_pair : m_peptideObservationList)
259 QString peptide_id = observation_pair.first->getId();
261 for(std::uint8_t charge : observation_pair.second->getObservedChargeStates())
264 msp_msRunRetentionTime.get()->addPeptideAsSeamark(
265 QString(
"%1-%2").arg(peptide_id).arg(charge),
266 observation_pair.second.get()->getBestXicCoordSPtrForCharge(charge).get()->rtTarget,
286 msp_msRunRetentionTime.get()->computeSeamarks();
288 return msp_msRunRetentionTime;
300 measures.get()->getPeptideObservationSp().get()->getPeptideSp().get();
302 for(
auto &one_xic_measure : measures.get()->getMeasurementList())
305 *(msp_msRunRetentionTime.get()));
311 QObject::tr(
"error collecting peak retention time in msrun %1 :\n%2")
312 .arg(msp_msRun.get()->getMsRunReaderSPtr()->getMsRunId()->getXmlId())
313 .arg(error.
qwhat()));
330 measures.get()->getPeptideObservationSp().get()->getPeptideSp().get();
333 *(measures.get()->getPeptideObservationSp().get()), *(msp_msRunRetentionTime.get()));
338 QObject::tr(
"error collecting MS2 retention time in msrun %1 :\n%2")
339 .arg(msp_msRun.get()->getMsRunReaderSPtr()->getMsRunId()->getXmlId())
340 .arg(error.
qwhat()));
349 const std::vector<pappso::masschroq::PeptideSp> &peptide_mbr_list,
350 const QString &tmp_dir,
356 m_peptideMeasurementsList.clear();
358 QString(
"Starting quantification for msrun %1 (MBR)")
359 .arg(msp_msRun.get()->getMsRunReaderSPtr()->getMsRunId().get()->getFileName()));
370 QString(
"MBR Preparing extraction list (%1)").arg(peptide_mbr_list.size()));
373 std::vector<pappso::XicCoordSPtr> xic_coord_list;
375 for(
auto &peptide_sp : peptide_mbr_list)
385 addMbrPeptideMeasurementsSp2XicCoordList(
386 msrun_group_p, quantification_method, peptide_sp, xic_coord_list);
391 ui_monitor.
appendText(QString(
"MBR Preparing extraction list done (%1 %2)")
392 .arg(m_mbrPeptideMeasurementsList.size())
393 .arg(xic_coord_list.size()));
395 ui_monitor.
appendText(QString(
"MBR Building XIC extractor"));
398 msp_msRun.get()->getMsRunReaderSPtr());
401 extractor_pwiz->setXicExtractMethod(quantification_method.get()->getXicExtractMethod());
405 extractor_pwiz.get()->setRetentionTimeAroundTarget(
406 quantification_method.get()->getXicExtractionRtRange());
412 extractor_pwiz.get()->setPostExtractionTraceFilterCstSPtr(csp_filter_suite);
416 ui_monitor.
appendText(QString(
"MBR Building XIC extractor done"));
417 ui_monitor.
appendText(QString(
"MBR Extracting"));
418 extractor_pwiz.get()->extractXicCoordSPtrListParallelized(ui_monitor, xic_coord_list);
422 mbrDetectQuantifyPeaks(ui_monitor, quantification_method);
426 QString(
"MBR Quantification for msrun %1 done")
427 .arg(msp_msRun.get()->getMsRunReaderSPtr()->getMsRunId().get()->getFileName()));
432 QObject::tr(
"error in %1 :\n%2").arg(__FUNCTION__).arg(error.
qwhat()));
442 std::vector<pappso::XicCoordSPtr> &xic_coord_list)
445 std::make_shared<pappso::masschroq::MbrPeptideMeasurements>(peptide_sp);
447 m_mbrPeptideMeasurementsList.push_back(mbr_peptide_measurements);
449 mbr_peptide_measurements.get()->prepareMeasurements(
450 *(msp_msRun.get()->getMsRunReaderSPtr().get()->getMsRunId().get()),
452 *(msp_msRunRetentionTime.get()),
453 quantification_method);
454 mbr_peptide_measurements.get()->pushBackXicCoordList(xic_coord_list);
463 m_uiMonitor.
appendText(QString(
"MBR Detect and quantify peak"));
473 measure->detectQuantifyPeaks(quantification_method);
478 QtConcurrent::map<std::vector<pappso::masschroq::MbrPeptideMeasurementsSp>::iterator>(
479 m_mbrPeptideMeasurementsList.begin(),
480 m_mbrPeptideMeasurementsList.end(),
481 mapdetectQuantifyPeaks);
482 res.waitForFinished();
485 m_uiMonitor.
appendText(QString(
"Detect and quantify peak done"));
492 return msp_msRunRetentionTime.get();
497 return msp_msRunRetentionTime.get();
500const std::vector<pappso::masschroq::PeptideMeasurementsSp> &
503 return m_peptideMeasurementsList;
506const std::vector<pappso::masschroq::MbrPeptideMeasurementsSp> &
509 return m_mbrPeptideMeasurementsList;
516 for(
auto &measure : m_peptideMeasurementsList)
518 measure.get()->flushXics();
521 for(
auto &mbr_measure : m_mbrPeptideMeasurementsList)
523 mbr_measure.get()->flushXics();
mean filter apply mean of y values inside the window : this results in a kind of smoothing
virtual const QString & qwhat() const
virtual void appendText(const QString &text)=0
append a text to a long report
void addMbrPeptideMeasurementsSp2XicCoordList(const MsRunGroup *msrun_group_p, const QuantificationMethodSp &quantification_method, const PeptideSp &peptide, std::vector< pappso::XicCoordSPtr > &xic_coord_list)
void quantify(const MsRunGroup *msrun_group_p, const QString &tmp_dir, pappso::UiMonitorInterface &m_uiMonitor, const QuantificationMethodSp &quantification_method)
void detectQuantifyPeaks(pappso::UiMonitorInterface &m_uiMonitor, const QuantificationMethodSp &quantification_method)
void quantifyMatchBetweenRun(const MsRunGroup *msrun_group_p, const std::vector< PeptideSp > &peptide_mbr_list, const QString &tmp_dir, pappso::UiMonitorInterface &m_uiMonitor, const QuantificationMethodSp &quantification_method)
const std::vector< MbrPeptideMeasurementsSp > & getMbrPeptideMeasurementsList() const
const MsRunSp & getMsRunSp() const
MsRunPeptideList(MsRunSp msrun)
std::vector< pappso::XicCoordSPtr > buildXicCoordList(const MsRunGroup *msrun_group_p, const QuantificationMethodSp &quantification_method)
virtual ~MsRunPeptideList()
void collectPeptideMs2RetentionTime(const pappso::MsRunRetentionTime< QString > *msrun_retention_time_reference_p) const
collect ms2 retention times collect all MS2 events retention times and convert it to the reference ti...
void addPeptideScanNumberObservation(PeptideSp peptide_sp, PeptideLabel *p_label, std::size_t spectrum_index, std::uint8_t charge)
std::shared_ptr< pappso::MsRunRetentionTime< QString > > & buildMsRunRetentionTimeSpOnPeptideObservations(const AlignmentMethodSp &alignment_method)
build a retention time vector with seamarks using MS2 best intensities
void flushChromatogramTraces()
void addPeptideObservation2XicCoordList(const MsRunGroup *msrun_group_p, const QuantificationMethodSp &quantification_method, const PeptideObservationSp &peptide_events_sp, std::vector< pappso::XicCoordSPtr > &xic_coord_list)
pappso::MsRunRetentionTime< QString > * getMsRunRetentionTimePtr() const
void addPeptideSpectrumIndexObservation(PeptideSp peptide_sp, PeptideLabel *p_label, std::size_t spectrum_index, std::uint8_t charge)
void mbrDetectQuantifyPeaks(pappso::UiMonitorInterface &m_uiMonitor, const QuantificationMethodSp &quantification_method)
void clearMeasurements()
clear all measurements MBR or not Clearing measurements also removes every chromatogram
const std::vector< PeptideMeasurementsSp > & getPeptideMeasurementsList() const
const pappso::MsRunRetentionTime< QString > * getMsRunRetentionTimeConstPtr() const
void collectPeptidePeakRetentionTime(const pappso::MsRunRetentionTime< QString > *msrun_retention_time_reference_p) const
collect peak retention times collect all quantified peptides retention times and convert it to the re...
void setReferenceMsRunRetentionTimePtr(const pappso::MsRunRetentionTime< QString > *msrun_retention_time_reference_p)
sets the current msrun retention time reference
void addAlignedPeptideObservation(const PeptideObservation &peptide_observation, const pappso::MsRunRetentionTime< QString > &msrun_retention_time)
accumulate retention time information for MS2 observation convenient function used while collecting d...
void addAlignedPeakMeasurement(const PeptideMeasurements::Measurement &one_xic_measure, const pappso::MsRunRetentionTime< QString > &msrun_retention_time)
accumulate retention time information for MS1 peak measurement
std::shared_ptr< QuantificationMethod > QuantificationMethodSp
std::shared_ptr< PeptideMeasurements > PeptideMeasurementsSp
std::shared_ptr< AlignmentMethod > AlignmentMethodSp
std::shared_ptr< MbrPeptideMeasurements > MbrPeptideMeasurementsSp
std::shared_ptr< Peptide > PeptideSp
std::shared_ptr< Precursor > PrecursorSp
std::shared_ptr< PeptideObservation > PeptideObservationSp
std::shared_ptr< MsRun > MsRunSp
std::shared_ptr< const FilterInterface > FilterInterfaceCstSPtr
std::shared_ptr< MsRunXicExtractorInterface > MsRunXicExtractorInterfaceSp