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 126 of file msrungroup.cpp.

129{
130
131 cbor_output.getCborStreamWriter().startMap();
132 cbor_output.getCborStreamWriter().append(QLatin1String("alignment_id"));
133 cbor_output.getCborStreamWriter().append(align_id);
134 cbor_output.getCborStreamWriter().append(QLatin1String("group_id"));
135 cbor_output.getCborStreamWriter().append(getId());
136 cbor_output.getCborStreamWriter().append(QLatin1String("timestamp1"));
137 cbor_output.getCborStreamWriter().append(QDateTime::currentDateTime().toString(Qt::ISODate));
138
139 // std::shared_ptr<pappso::MsRunRetentionTime<QString>>
140 // retention_time_reference_sp = nullptr;
141 m_uiMonitor.appendText("Starting retention time alignment");
142 alignRetentionTimeBetweenMsRuns(cbor_output, m_uiMonitor);
143 m_uiMonitor.appendText("retention time alignment done");
144
145
146 cbor_output.getCborStreamWriter().append(QLatin1String("timestamp2"));
147 cbor_output.getCborStreamWriter().append(QDateTime::currentDateTime().toString(Qt::ISODate));
148 cbor_output.getCborStreamWriter().endMap();
149}
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.

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

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

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 338 of file msrungroup.cpp.

339{
340 return m_id;
341}

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 326 of file msrungroup.cpp.

327{
329}

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 153 of file msrungroup.cpp.

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

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

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 319 of file msrungroup.cpp.

321{
322 msp_ionMobilityGrid = ion_mobility_grid_sp;
323}

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: