libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::masschroq::MsRunGroup Class Reference

#include <msrungroup.h>

Public Member Functions

 MsRunGroup (const QString &id, const std::vector< MsRunPeptideListSp > &msrun_list)
 MsRunGroup (const MsRunGroup &other)
virtual ~MsRunGroup ()
void setIonMobilityGridSp (const std::shared_ptr< pappso::IonMobilityGrid > &ion_mobility_grid_sp)
void align (CborOutputStream &cbor_output, const QString &align_id, pappso::UiMonitorInterface &m_uiMonitor) const
void quantify (CborOutputStream &cbor_output, const QString &quantify_id, const QString &tmp_dir, pappso::UiMonitorInterface &m_uiMonitor, const QuantificationMethodSp &quantification_method, const std::vector< PeptideSp > &peptide_sp_list) const
void setAlignmentMethodSp (const AlignmentMethodSp &alignment_method_sp, const QString &msrun_ref_id)
bool contains (const MsRun *msrun_p) const
bool hasTimsTofMobilityIndex () const
const std::shared_ptr< pappso::IonMobilityGrid > & getIonMobilityGridSp () const
const QString & getId () const

Private Member Functions

void alignRetentionTimeBetweenMsRuns (CborOutputStream &cbor_output, pappso::UiMonitorInterface &m_uiMonitor) const

Private Attributes

const QString m_id
const std::vector< MsRunPeptideListSpm_msRunPeptideListSpList
AlignmentMethodSp msp_alignmentMethod
MsRunPeptideListSp msp_msRunPeptideListAlignmentReference
bool m_hasTimsTofMobilityIndex = false
std::shared_ptr< pappso::IonMobilityGridmsp_ionMobilityGrid

Detailed Description

Todo
write docs

Definition at line 47 of file msrungroup.h.

Constructor & Destructor Documentation

◆ MsRunGroup() [1/2]

pappso::masschroq::MsRunGroup::MsRunGroup ( const QString & id,
const std::vector< MsRunPeptideListSp > & msrun_list )

Default constructor

Definition at line 32 of file msrungroup.cpp.

34 : m_id(id), m_msRunPeptideListSpList(msrun_list)
35{
36 if(m_msRunPeptideListSpList.size() > 0)
37 {
39 m_msRunPeptideListSpList.front().get()->getMsRunSp().get()->hasTimsTofMobilityIndex();
40 }
41}
const std::vector< MsRunPeptideListSp > m_msRunPeptideListSpList
Definition msrungroup.h:99

References m_id, and m_msRunPeptideListSpList.

◆ MsRunGroup() [2/2]

pappso::masschroq::MsRunGroup::MsRunGroup ( const MsRunGroup & other)

Copy constructor

Parameters
otherTODO

Definition at line 43 of file msrungroup.cpp.

44 : m_id(other.m_id), m_msRunPeptideListSpList(other.m_msRunPeptideListSpList)
45{
46 m_hasTimsTofMobilityIndex = other.m_hasTimsTofMobilityIndex;
47}

References m_hasTimsTofMobilityIndex, m_id, and m_msRunPeptideListSpList.

◆ ~MsRunGroup()

pappso::masschroq::MsRunGroup::~MsRunGroup ( )
virtual

Destructor

Definition at line 49 of file msrungroup.cpp.

50{
51}

Member Function Documentation

◆ align()

void pappso::masschroq::MsRunGroup::align ( CborOutputStream & cbor_output,
const QString & align_id,
pappso::UiMonitorInterface & m_uiMonitor ) const

Definition at line 128 of file msrungroup.cpp.

131{
132
133 cbor_output.getCborStreamWriter().startMap();
134 cbor_output.getCborStreamWriter().append(QLatin1String("alignment_id"));
135 cbor_output.getCborStreamWriter().append(align_id);
136 cbor_output.getCborStreamWriter().append(QLatin1String("group_id"));
137 cbor_output.getCborStreamWriter().append(getId());
138 cbor_output.getCborStreamWriter().append(QLatin1String("timestamp1"));
139 cbor_output.getCborStreamWriter().append(QDateTime::currentDateTime().toString(Qt::ISODate));
140
141 // std::shared_ptr<pappso::MsRunRetentionTime<QString>>
142 // retention_time_reference_sp = nullptr;
143 m_uiMonitor.appendText("Starting retention time alignment");
144 alignRetentionTimeBetweenMsRuns(cbor_output, m_uiMonitor);
145 m_uiMonitor.appendText("retention time alignment done");
146
147
148 cbor_output.getCborStreamWriter().append(QLatin1String("timestamp2"));
149 cbor_output.getCborStreamWriter().append(QDateTime::currentDateTime().toString(Qt::ISODate));
150 cbor_output.getCborStreamWriter().endMap();
151}
virtual void appendText(const QString &text)=0
append a text to a long report
const QString & getId() const
void alignRetentionTimeBetweenMsRuns(CborOutputStream &cbor_output, pappso::UiMonitorInterface &m_uiMonitor) const

References alignRetentionTimeBetweenMsRuns(), pappso::UiMonitorInterface::appendText(), pappso::masschroq::CborOutputStream::getCborStreamWriter(), and getId().

◆ alignRetentionTimeBetweenMsRuns()

void pappso::masschroq::MsRunGroup::alignRetentionTimeBetweenMsRuns ( CborOutputStream & cbor_output,
pappso::UiMonitorInterface & m_uiMonitor ) const
private

Definition at line 54 of file msrungroup.cpp.

57{
59 {
60 throw pappso::PappsoException(QObject::tr("match between run requires an MSrun reference"));
61 }
62 cbor_output.getCborStreamWriter().append(QLatin1String("alignment"));
63 cbor_output.getCborStreamWriter().startMap();
64 cbor_output.getCborStreamWriter().append(QLatin1String("msrun_ref"));
65 cbor_output.getCborStreamWriter().append(msp_msRunPeptideListAlignmentReference.get()
66 ->getMsRunSp()
67 .get()
68 ->getMsRunReaderSPtr()
69 .get()
70 ->getMsRunId()
71 .get()
72 ->getXmlId());
73 // "alignment": {
74 // "msrun_ref": "msruna2",
75
77 {
78 msrun_peptide_list.get()->buildMsRunRetentionTimeSpOnPeptideObservations(msp_alignmentMethod);
79 }
80 const pappso::MsRunRetentionTime<QString> *reference_msrun_retetiontime_p =
81 msp_msRunPeptideListAlignmentReference.get()->getMsRunRetentionTimeConstPtr();
82
83 cbor_output.getCborStreamWriter().append(QLatin1String("corrections"));
84
85 cbor_output.getCborStreamWriter().startMap();
86 // "corrections": {
88 {
89
90 if(msrun_peptide_list.get() == msp_msRunPeptideListAlignmentReference.get())
91 continue;
92
93
94 /*
95 "msruna1": {
96 "original": [1,2,3,4.5],
97 "aligned":[1,2,3,4.5]
98 },
99 "msruna2": {
100 "original": [1,2,3,4.5],
101 "aligned":[1,2,3,4.5]
102 }*/
103 msrun_peptide_list.get()->getMsRunRetentionTimePtr()->align(*reference_msrun_retetiontime_p);
104
105 pappso::Trace report_common_MS2_delta_rt =
106 msrun_peptide_list.get()->getMsRunRetentionTimePtr()->getCommonDeltaRt(
107 reference_msrun_retetiontime_p->getSeamarks());
108
109 cbor_output.getCborStreamWriter().append(msrun_peptide_list.get()
110 ->getMsRunSp()
111 .get()
112 ->getMsRunReaderSPtr()
113 .get()
114 ->getMsRunId()
115 .get()
116 ->getXmlId());
117 cbor_output.writeMsRunRetentionTime(report_common_MS2_delta_rt,
118 *msrun_peptide_list.get()->getMsRunRetentionTimePtr());
119 }
120
121
122 cbor_output.getCborStreamWriter().endMap();
123 cbor_output.getCborStreamWriter().endMap();
124}
const std::vector< MsRunRetentionTimeSeamarkPoint< T > > & getSeamarks() const
MsRunPeptideListSp msp_msRunPeptideListAlignmentReference
Definition msrungroup.h:101
AlignmentMethodSp msp_alignmentMethod
Definition msrungroup.h:100
std::shared_ptr< MsRunPeptideList > MsRunPeptideListSp

References pappso::masschroq::CborOutputStream::getCborStreamWriter(), pappso::MsRunRetentionTime< T >::getSeamarks(), m_msRunPeptideListSpList, msp_alignmentMethod, msp_msRunPeptideListAlignmentReference, and pappso::masschroq::CborOutputStream::writeMsRunRetentionTime().

Referenced by align().

◆ contains()

bool pappso::masschroq::MsRunGroup::contains ( const MsRun * msrun_p) const

Definition at line 310 of file msrungroup.cpp.

311{
312 auto it = find_if(m_msRunPeptideListSpList.begin(),
314 [msrun_p](const pappso::masschroq::MsRunPeptideListSp &msrun) {
315 return (msrun.get()->getMsRunSp().get() == msrun_p);
316 });
317 return (it != m_msRunPeptideListSpList.end());
318}

References m_msRunPeptideListSpList.

Referenced by pappso::masschroq::Peptide::getBestIonMobilityXicCoordToExtractOverallMsRunGroup(), and pappso::masschroq::Peptide::getBestXicCoordSPtrForChargeInMsRunGroup().

◆ getId()

const QString & pappso::masschroq::MsRunGroup::getId ( ) const

Definition at line 340 of file msrungroup.cpp.

341{
342 return m_id;
343}

References m_id.

Referenced by align(), and quantify().

◆ getIonMobilityGridSp()

const std::shared_ptr< pappso::IonMobilityGrid > & pappso::masschroq::MsRunGroup::getIonMobilityGridSp ( ) const

◆ hasTimsTofMobilityIndex()

bool pappso::masschroq::MsRunGroup::hasTimsTofMobilityIndex ( ) const

Definition at line 328 of file msrungroup.cpp.

329{
331}

References m_hasTimsTofMobilityIndex.

◆ quantify()

void pappso::masschroq::MsRunGroup::quantify ( CborOutputStream & cbor_output,
const QString & quantify_id,
const QString & tmp_dir,
pappso::UiMonitorInterface & m_uiMonitor,
const QuantificationMethodSp & quantification_method,
const std::vector< PeptideSp > & peptide_sp_list ) const

Definition at line 155 of file msrungroup.cpp.

162{
163
164 bool match_between_run = quantification_method.get()->getMatchBetweenRun();
165
166 cbor_output.getCborStreamWriter().startMap();
167 cbor_output.getCborStreamWriter().append("quantify_id");
168 cbor_output.getCborStreamWriter().append(quantify_id);
169 cbor_output.getCborStreamWriter().append("group_id");
170 cbor_output.getCborStreamWriter().append(getId());
171 cbor_output.getCborStreamWriter().append(QLatin1String("timestamp1"));
172 cbor_output.getCborStreamWriter().append(QDateTime::currentDateTime().toString(Qt::ISODate));
173
174 cbor_output.getCborStreamWriter().append("first_pass");
175 cbor_output.getCborStreamWriter().startMap(m_msRunPeptideListSpList.size());
176
177
178 const pappso::MsRunRetentionTime<QString> *msrun_rt_reference_p = nullptr;
179 if(match_between_run)
180 {
181
182 if(msp_msRunPeptideListAlignmentReference.get() == nullptr)
183 {
184 throw pappso::PappsoException(
185 QObject::tr("group %1 is not aligned, match between run is not possible").arg(getId()));
186 }
187 msrun_rt_reference_p =
188 msp_msRunPeptideListAlignmentReference.get()->getMsRunRetentionTimeConstPtr();
189 }
190
191
193 {
194 msrun_peptide_list.get()->quantify(this, tmp_dir, m_uiMonitor, quantification_method);
195
196
197 if(match_between_run)
198 {
199
200
201 const pappso::MsRunRetentionTime<QString> *msrun_rt_p =
202 msrun_peptide_list.get()->getMsRunRetentionTimeConstPtr();
203
204
205 if((msrun_rt_reference_p == nullptr) || (msrun_rt_p == nullptr) ||
206 ((!msrun_rt_p->isAligned()) && (msrun_rt_reference_p != msrun_rt_p)))
207 {
208 throw pappso::PappsoException(
209 QObject::tr("msrun %1 is not aligned, match between run is not possible")
210 .arg(msrun_peptide_list.get()
211 ->getMsRunSp()
212 .get()
213 ->getMsRunReaderSPtr()
214 .get()
215 ->getMsRunId()
216 .get()
217 ->getXmlId()));
218 }
219 m_uiMonitor.appendText("Collecting peak apex");
220 msrun_peptide_list.get()->collectPeptidePeakRetentionTime(msrun_rt_reference_p);
221 msrun_peptide_list.get()->collectPeptideMs2RetentionTime(msrun_rt_reference_p);
222 }
223
224 cbor_output.writeQrDataBlock(m_uiMonitor, *msrun_peptide_list.get(), false);
225
226
227 msrun_peptide_list.get()->clearMeasurements();
228 }
229
230 cbor_output.getCborStreamWriter().endMap();
231
232 cbor_output.getCborStreamWriter().append(QLatin1String("timestamp2"));
233 cbor_output.getCborStreamWriter().append(QDateTime::currentDateTime().toString(Qt::ISODate));
234 if(match_between_run)
235 {
236 if(msrun_rt_reference_p != nullptr)
237 { // second pass
238
239 m_uiMonitor.appendText(
240 QObject::tr("Computing consensus retention time (%1)").arg(peptide_sp_list.size()));
241 for(const pappso::masschroq::PeptideSp &peptide_sp : peptide_sp_list)
242 {
243 peptide_sp.get()->computeConsensusRetentionTime();
244 }
245
246 cbor_output.getCborStreamWriter().append("second_pass");
247 cbor_output.getCborStreamWriter().startMap(m_msRunPeptideListSpList.size());
248 for(const pappso::masschroq::MsRunPeptideListSp &msrun_peptide_list :
250 {
251 const pappso::masschroq::MsRun *msrun_p =
252 msrun_peptide_list.get()->getMsRunSp().get();
253 std::vector<pappso::masschroq::PeptideSp> peptide_mbr_list;
254 for(const pappso::masschroq::PeptideSp &peptide_sp : peptide_sp_list)
255 {
256 if(!peptide_sp.get()->isObservedInMsRunSp(msrun_p))
257 {
258 peptide_mbr_list.push_back(peptide_sp);
259 }
260 }
261 msrun_peptide_list.get()->quantifyMatchBetweenRun(
262 this, peptide_mbr_list, tmp_dir, m_uiMonitor, quantification_method);
263
264
265 cbor_output.writeQrDataBlock(m_uiMonitor, *msrun_peptide_list.get(), true);
266
267 msrun_peptide_list.get()->clearMeasurements();
268 }
269
270 cbor_output.getCborStreamWriter().endMap();
271 }
272 }
273
274 cbor_output.getCborStreamWriter().append(QLatin1String("timestamp3"));
275 cbor_output.getCborStreamWriter().append(QDateTime::currentDateTime().toString(Qt::ISODate));
276 cbor_output.getCborStreamWriter().endMap();
277}
std::shared_ptr< Peptide > PeptideSp
Definition peptide.h:46

References pappso::UiMonitorInterface::appendText(), pappso::masschroq::CborOutputStream::getCborStreamWriter(), getId(), pappso::masschroq::QuantificationMethod::getMatchBetweenRun(), pappso::MsRunRetentionTime< T >::isAligned(), m_msRunPeptideListSpList, msp_msRunPeptideListAlignmentReference, and pappso::masschroq::CborOutputStream::writeQrDataBlock().

◆ setAlignmentMethodSp()

void pappso::masschroq::MsRunGroup::setAlignmentMethodSp ( const AlignmentMethodSp & alignment_method_sp,
const QString & msrun_ref_id )

Definition at line 280 of file msrungroup.cpp.

282{
283 auto it = find_if(m_msRunPeptideListSpList.begin(),
285 [msrun_ref_id](const pappso::masschroq::MsRunPeptideListSp &msrun) {
286 if(msrun.get()
287 ->getMsRunSp()
288 .get()
289 ->getMsRunReaderSPtr()
290 .get()
291 ->getMsRunId()
292 .get()
293 ->getXmlId() == msrun_ref_id)
294 return true;
295 return false;
296 });
297 if(it != m_msRunPeptideListSpList.end())
298 {
299 msp_alignmentMethod = alignment_method_sp;
301 }
302 else
303 {
304 throw pappso::ExceptionNotFound(
305 QObject::tr("msrun_id %1 not found in group %2").arg(msrun_ref_id).arg(m_id));
306 }
307}

References m_id, m_msRunPeptideListSpList, msp_alignmentMethod, and msp_msRunPeptideListAlignmentReference.

◆ setIonMobilityGridSp()

void pappso::masschroq::MsRunGroup::setIonMobilityGridSp ( const std::shared_ptr< pappso::IonMobilityGrid > & ion_mobility_grid_sp)

Definition at line 321 of file msrungroup.cpp.

323{
324 msp_ionMobilityGrid = ion_mobility_grid_sp;
325}

References msp_ionMobilityGrid.

Member Data Documentation

◆ m_hasTimsTofMobilityIndex

bool pappso::masschroq::MsRunGroup::m_hasTimsTofMobilityIndex = false
private

Definition at line 102 of file msrungroup.h.

Referenced by MsRunGroup(), and hasTimsTofMobilityIndex().

◆ m_id

const QString pappso::masschroq::MsRunGroup::m_id
private

Definition at line 98 of file msrungroup.h.

Referenced by MsRunGroup(), MsRunGroup(), getId(), and setAlignmentMethodSp().

◆ m_msRunPeptideListSpList

const std::vector<MsRunPeptideListSp> pappso::masschroq::MsRunGroup::m_msRunPeptideListSpList
private

◆ msp_alignmentMethod

AlignmentMethodSp pappso::masschroq::MsRunGroup::msp_alignmentMethod
private

Definition at line 100 of file msrungroup.h.

Referenced by alignRetentionTimeBetweenMsRuns(), and setAlignmentMethodSp().

◆ msp_ionMobilityGrid

std::shared_ptr<pappso::IonMobilityGrid> pappso::masschroq::MsRunGroup::msp_ionMobilityGrid
private

Definition at line 103 of file msrungroup.h.

Referenced by getIonMobilityGridSp(), and setIonMobilityGridSp().

◆ msp_msRunPeptideListAlignmentReference

MsRunPeptideListSp pappso::masschroq::MsRunGroup::msp_msRunPeptideListAlignmentReference
private

Definition at line 101 of file msrungroup.h.

Referenced by alignRetentionTimeBetweenMsRuns(), quantify(), and setAlignmentMethodSp().


The documentation for this class was generated from the following files: