30#include "../xicextractor/msrunxicextractorfactory.h"
32#include <QtConcurrent>
54 std::size_t spectrum_index,
58 auto it = m_peptideObservationList.insert(
59 {peptide_sp.get(), std::make_shared<pappso::masschroq::PeptideObservation>(peptide_sp)});
61 msp_msRun.get()->getPrecursorSPtrBySpectrumIndex(spectrum_index);
62 it.first->second.get()->addObservation({spectrum_index, charge, precursor_sp,
true, p_label});
64 peptide_sp.get()->addMsRunXicCoordCharge({msp_msRun.get(),
65 precursor_sp.get()->getXicCoordSPtr(),
67 precursor_sp.get()->getIntensity()});
68 qDebug() <<
"m_peptideObservationList.size()=" << m_peptideObservationList.size();
75 std::size_t scan_number,
79 auto it = m_peptideObservationList.insert(
80 {peptide_sp.get(), std::make_shared<pappso::masschroq::PeptideObservation>(peptide_sp)});
82 msp_msRun.get()->getPrecursorSPtrByScanNumber(scan_number);
83 it.first->second.get()->addObservation({scan_number, charge, precursor_sp,
false, p_label});
85 peptide_sp.get()->addMsRunXicCoordCharge({msp_msRun.get(),
86 precursor_sp.get()->getXicCoordSPtr(),
88 precursor_sp.get()->getIntensity()});
89 qDebug() <<
"m_peptideObservationList.size()=" << m_peptideObservationList.size();
94 const QString &tmp_dir,
98 m_peptideMeasurementsList.clear();
100 QString(
"Starting quantification for msrun %1")
101 .arg(msp_msRun.get()->getMsRunReaderSPtr()->getMsRunId().get()->getFileName()));
103 qDebug() << m_peptideObservationList.size();
111 ui_monitor.
appendText(QString(
"Preparing extraction list"));
112 std::vector<pappso::XicCoordSPtr> xic_coord_list =
113 buildXicCoordList(msrun_group_p, quantification_method);
115 ui_monitor.
appendText(QString(
"Preparing extraction list done"));
117 ui_monitor.
appendText(QString(
"Building XIC extractor"));
120 msp_msRun.get()->getMsRunReaderSPtr());
123 extractor_pwiz->setXicExtractMethod(quantification_method.get()->getXicExtractMethod());
127 extractor_pwiz.get()->setRetentionTimeAroundTarget(
128 quantification_method.get()->getXicExtractionRtRange());
134 extractor_pwiz.get()->setPostExtractionTraceFilterCstSPtr(csp_filter_suite);
138 ui_monitor.
appendText(QString(
"Building XIC extractor done"));
140 extractor_pwiz.get()->extractXicCoordSPtrListParallelized(ui_monitor, xic_coord_list);
145 detectQuantifyPeaks(ui_monitor, quantification_method);
149 QString(
"Quantification for msrun %1 done")
150 .arg(msp_msRun.get()->getMsRunReaderSPtr()->getMsRunId().get()->getFileName()));
154std::vector<pappso::XicCoordSPtr>
159 std::vector<pappso::XicCoordSPtr> xic_coord_list;
161 for(
auto pair_peptide : m_peptideObservationList)
165 addPeptideObservation2XicCoordList(
166 msrun_group_p, quantification_method, pair_peptide.second, xic_coord_list);
171 return xic_coord_list;
179 std::vector<pappso::XicCoordSPtr> &xic_coord_list)
182 std::make_shared<pappso::masschroq::PeptideMeasurements>(peptide_events_sp);
184 m_peptideMeasurementsList.push_back(peptide_measurements);
186 peptide_measurements.get()->prepareMeasurements(
187 *(msp_msRun.get()->getMsRunReaderSPtr().get()->getMsRunId().get()),
189 quantification_method);
190 peptide_measurements.get()->pushBackXicCoordList(xic_coord_list);
198 m_uiMonitor.
appendText(QString(
"Detect and quantify peak"));
208 measure->detectQuantifyPeaks(quantification_method);
213 QtConcurrent::map<std::vector<pappso::masschroq::PeptideMeasurementsSp>::iterator>(
214 m_peptideMeasurementsList.begin(), m_peptideMeasurementsList.end(), mapdetectQuantifyPeaks);
215 res.waitForFinished();
218 m_uiMonitor.
appendText(QString(
"Detect and quantify peak done"));
232 for(
auto &measure : m_peptideMeasurementsList)
234 measure.get()->flushXics();
237 for(
auto &mbr_measure : m_mbrPeptideMeasurementsList)
239 mbr_measure.get()->flushXics();
243std::shared_ptr<pappso::MsRunRetentionTime<QString>> &
247 msp_msRunRetentionTime =
248 std::make_shared<pappso::MsRunRetentionTime<QString>>(msp_msRun->getRetentionTimeLine());
250 msp_msRunRetentionTime.get()->setMs2MedianFilter(
252 msp_msRunRetentionTime.get()->setMs2MeanFilter(
254 msp_msRunRetentionTime.get()->setMs1MeanFilter(
258 for(
const auto &observation_pair : m_peptideObservationList)
260 QString peptide_id = observation_pair.first->getId();
262 for(std::uint8_t charge : observation_pair.second->getObservedChargeStates())
265 msp_msRunRetentionTime.get()->addPeptideAsSeamark(
266 QString(
"%1-%2").arg(peptide_id).arg(charge),
267 observation_pair.second.get()->getBestXicCoordSPtrForCharge(charge).get()->rtTarget,
287 msp_msRunRetentionTime.get()->computeSeamarks();
289 return msp_msRunRetentionTime;
301 measures.get()->getPeptideObservationSp().get()->getPeptideSp().get();
303 for(
auto &one_xic_measure : measures.get()->getMeasurementList())
306 *(msp_msRunRetentionTime.get()));
312 QObject::tr(
"error collecting peak retention time in msrun %1 :\n%2")
313 .arg(msp_msRun.get()->getMsRunReaderSPtr()->getMsRunId()->getXmlId())
314 .arg(error.
qwhat()));
331 measures.get()->getPeptideObservationSp().get()->getPeptideSp().get();
334 *(measures.get()->getPeptideObservationSp().get()), *(msp_msRunRetentionTime.get()));
339 QObject::tr(
"error collecting MS2 retention time in msrun %1 :\n%2")
340 .arg(msp_msRun.get()->getMsRunReaderSPtr()->getMsRunId()->getXmlId())
341 .arg(error.
qwhat()));
350 const std::vector<pappso::masschroq::PeptideSp> &peptide_mbr_list,
351 const QString &tmp_dir,
357 m_peptideMeasurementsList.clear();
359 QString(
"Starting quantification for msrun %1 (MBR)")
360 .arg(msp_msRun.get()->getMsRunReaderSPtr()->getMsRunId().get()->getFileName()));
371 QString(
"MBR Preparing extraction list (%1)").arg(peptide_mbr_list.size()));
374 std::vector<pappso::XicCoordSPtr> xic_coord_list;
376 for(
auto &peptide_sp : peptide_mbr_list)
386 addMbrPeptideMeasurementsSp2XicCoordList(
387 msrun_group_p, quantification_method, peptide_sp, xic_coord_list);
392 ui_monitor.
appendText(QString(
"MBR Preparing extraction list done (%1 %2)")
393 .arg(m_mbrPeptideMeasurementsList.size())
394 .arg(xic_coord_list.size()));
396 ui_monitor.
appendText(QString(
"MBR Building XIC extractor"));
399 msp_msRun.get()->getMsRunReaderSPtr());
402 extractor_pwiz->setXicExtractMethod(quantification_method.get()->getXicExtractMethod());
406 extractor_pwiz.get()->setRetentionTimeAroundTarget(
407 quantification_method.get()->getXicExtractionRtRange());
413 extractor_pwiz.get()->setPostExtractionTraceFilterCstSPtr(csp_filter_suite);
417 ui_monitor.
appendText(QString(
"MBR Building XIC extractor done"));
418 ui_monitor.
appendText(QString(
"MBR Extracting"));
419 extractor_pwiz.get()->extractXicCoordSPtrListParallelized(ui_monitor, xic_coord_list);
423 mbrDetectQuantifyPeaks(ui_monitor, quantification_method);
427 QString(
"MBR Quantification for msrun %1 done")
428 .arg(msp_msRun.get()->getMsRunReaderSPtr()->getMsRunId().get()->getFileName()));
433 QObject::tr(
"error in %1 :\n%2").arg(__FUNCTION__).arg(error.
qwhat()));
443 std::vector<pappso::XicCoordSPtr> &xic_coord_list)
446 std::make_shared<pappso::masschroq::MbrPeptideMeasurements>(peptide_sp);
448 m_mbrPeptideMeasurementsList.push_back(mbr_peptide_measurements);
450 mbr_peptide_measurements.get()->prepareMeasurements(
451 *(msp_msRun.get()->getMsRunReaderSPtr().get()->getMsRunId().get()),
453 *(msp_msRunRetentionTime.get()),
454 quantification_method);
455 mbr_peptide_measurements.get()->pushBackXicCoordList(xic_coord_list);
464 m_uiMonitor.
appendText(QString(
"MBR Detect and quantify peak"));
474 measure->detectQuantifyPeaks(quantification_method);
479 QtConcurrent::map<std::vector<pappso::masschroq::MbrPeptideMeasurementsSp>::iterator>(
480 m_mbrPeptideMeasurementsList.begin(),
481 m_mbrPeptideMeasurementsList.end(),
482 mapdetectQuantifyPeaks);
483 res.waitForFinished();
486 m_uiMonitor.
appendText(QString(
"Detect and quantify peak done"));
493 return msp_msRunRetentionTime.get();
498 return msp_msRunRetentionTime.get();
501const std::vector<pappso::masschroq::PeptideMeasurementsSp> &
504 return m_peptideMeasurementsList;
507const std::vector<pappso::masschroq::MbrPeptideMeasurementsSp> &
510 return m_mbrPeptideMeasurementsList;
517 for(
auto &measure : m_peptideMeasurementsList)
519 measure.get()->flushXics();
522 for(
auto &mbr_measure : m_mbrPeptideMeasurementsList)
524 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