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

#include <msrunxicextractor.h>

Inheritance diagram for pappso::MsRunXicExtractor:
pappso::MsRunXicExtractorInterface pappso::MsRunXicExtractorDisk pappso::MsRunXicExtractorDiskBuffer

Classes

struct  MsRunXicExtractorPoints
class  MsRunXicExtractorReadPoints
 class to read retention time points of MsRun More...

Public Member Functions

 MsRunXicExtractor (const MsRunXicExtractor &other)
virtual ~MsRunXicExtractor ()
Public Member Functions inherited from pappso::MsRunXicExtractorInterface
void setXicExtractMethod (Enums::XicExtractMethod method)
 set the XIC extraction method
void setRetentionTimeAroundTarget (double range_in_seconds)
 set the retention time range in seconds around the target rt
virtual void extractXicCoordSPtrList (UiMonitorInterface &monitor, std::vector< XicCoordSPtr > &xic_coord_list) final
 extract a list of XIC given a list of xic coordinates to extract
virtual void extractXicCoordSPtrListParallelized (UiMonitorInterface &monitor, std::vector< XicCoordSPtr > &xic_coord_list) final
 multithreaded XIC extraction
const MsRunIdCstSPtrgetMsRunId () const
const MsRunReaderSPtrgetMsRunReaderSPtr () const
 get the msrunreader currently used for XIC extraction
void setPostExtractionTraceFilterCstSPtr (pappso::FilterInterfaceCstSPtr &filter)
 filter interface to apply just after XIC extration on each trace

Protected Member Functions

 MsRunXicExtractor (MsRunReaderSPtr &msrun_reader)
virtual void getXicFromPwizMSDataFile (std::vector< Xic * > &xic_list, const std::vector< MzRange > &mass_range_list, pappso::pappso_double rt_begin, pappso::pappso_double rt_end)
virtual void protectedExtractXicCoordSPtrList (UiMonitorInterface &monitor, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_begin, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_end) override
Protected Member Functions inherited from pappso::MsRunXicExtractorInterface
 MsRunXicExtractorInterface (MsRunReaderSPtr &msrun_reader)
 constructor is private, use the MsRunXicExtractorFactory
 MsRunXicExtractorInterface (const MsRunXicExtractorInterface &other)
virtual ~MsRunXicExtractorInterface ()
virtual void postExtractionProcess (UiMonitorInterface &monitor, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_begin, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_end)
 possible post extraction process, eventually trace filters

Protected Attributes

std::vector< MsRunXicExtractorPointsm_msrun_points
Protected Attributes inherited from pappso::MsRunXicExtractorInterface
MsRunReaderSPtr msp_msrun_reader
Enums::XicExtractMethod m_xicExtractMethod = Enums::XicExtractMethod::max
double m_retentionTimeAroundTarget = std::numeric_limits<double>::max()
pappso::FilterInterfaceCstSPtr mcsp_postExtractionTraceFilter = nullptr

Private Member Functions

void extractOneXicCoord (XicCoord &xic_coord)

Private Attributes

friend MsRunXicExtractorFactory

Detailed Description

Definition at line 42 of file msrunxicextractor.h.

Constructor & Destructor Documentation

◆ MsRunXicExtractor() [1/2]

pappso::MsRunXicExtractor::MsRunXicExtractor ( const MsRunXicExtractor & other)

Definition at line 73 of file msrunxicextractor.cpp.

75{
76 m_msrun_points = other.m_msrun_points;
77}
MsRunXicExtractorInterface(MsRunReaderSPtr &msrun_reader)
constructor is private, use the MsRunXicExtractorFactory
std::vector< MsRunXicExtractorPoints > m_msrun_points

References MsRunXicExtractor(), pappso::MsRunXicExtractorInterface::MsRunXicExtractorInterface(), and m_msrun_points.

Referenced by MsRunXicExtractor(), pappso::MsRunXicExtractorDisk::MsRunXicExtractorDisk(), and pappso::MsRunXicExtractorDisk::MsRunXicExtractorDisk().

◆ ~MsRunXicExtractor()

pappso::MsRunXicExtractor::~MsRunXicExtractor ( )
virtual

Definition at line 68 of file msrunxicextractor.cpp.

69{
70}

◆ MsRunXicExtractor() [2/2]

pappso::MsRunXicExtractor::MsRunXicExtractor ( MsRunReaderSPtr & msrun_reader)
protected

Definition at line 43 of file msrunxicextractor.cpp.

44 : pappso::MsRunXicExtractorInterface(msrun_reader)
45{
46
48
49
50 pappso::MsRunReadConfig config;
51 config.setNeedPeakList(true);
52 config.setMsLevels({1});
53
54 msp_msrun_reader.get()->readSpectrumCollection2(config, get_msrun_points);
55
56 std::sort(
57 m_msrun_points.begin(),
58 m_msrun_points.end(),
59 [](const MsRunXicExtractorPoints &a, const MsRunXicExtractorPoints &b) { return a.rt < b.rt; });
60
61
62 if(m_msrun_points.size() == 0)
63 {
64 throw pappso::PappsoException(
65 QObject::tr("error extracting XIC: no MS level 1 in data file"));
66 }
67}
void setNeedPeakList(bool need_peak_list)
void setMsLevels(std::vector< std::size_t > ms_levels)
class to read retention time points of MsRun

References pappso::MsRunXicExtractorInterface::MsRunXicExtractorInterface(), pappso::a, pappso::b, m_msrun_points, pappso::MsRunXicExtractorInterface::msp_msrun_reader, pappso::MsRunReadConfig::setMsLevels(), and pappso::MsRunReadConfig::setNeedPeakList().

Member Function Documentation

◆ extractOneXicCoord()

void pappso::MsRunXicExtractor::extractOneXicCoord ( XicCoord & xic_coord)
private

Definition at line 106 of file msrunxicextractor.cpp.

107{
108 FilterResampleKeepXRange keep_range(xic_coord.mzRange.lower(), xic_coord.mzRange.upper());
109 std::shared_ptr<Xic> msrunxic_sp = xic_coord.xicSptr;
110
111 double rt_begin = xic_coord.rtTarget - m_retentionTimeAroundTarget;
112 double rt_end = xic_coord.rtTarget + m_retentionTimeAroundTarget;
113
114
115 auto itpoints = m_msrun_points.begin();
116
117 // find startint retention time :
118 while((itpoints != m_msrun_points.end()) && (itpoints->rt < rt_begin))
119 {
120 itpoints++;
121 }
122 MassSpectrumSPtr spectrum;
123 DataPoint peak;
124 while((itpoints != m_msrun_points.end()) && (itpoints->rt <= rt_end))
125 {
126 spectrum = msp_msrun_reader.get()->massSpectrumSPtr(itpoints->spectrum_index);
127 // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
128 // << spectrum->size(); spectrum->debugPrintValues();
129
130 qDebug() << " spectrum->size()=" << spectrum->size();
131 keep_range.filter(*(spectrum.get()));
132 qDebug() << " spectrum->size()=" << spectrum->size();
133
134 peak.x = itpoints->rt;
135
137 {
138 peak.y = 0;
139 if(spectrum->size() > 0)
140 {
141 peak.y = maxYDataPoint(spectrum->begin(), spectrum->end())->y;
142
143 qDebug() << " peak.y=" << peak.y << " spectrum->size()=" << spectrum->size();
144 }
145 }
146 else
147 {
148 peak.y = sumYTrace(spectrum->begin(), spectrum->end(), 0);
149 }
150 msrunxic_sp->push_back(peak);
151
152 itpoints++;
153 }
154}
@ max
maximum of intensities
Definition types.h:280
std::vector< DataPoint >::const_iterator maxYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
Definition trace.cpp:174
double sumYTrace(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end, double init)
calculate the sum of y value of a trace
Definition trace.cpp:231
std::shared_ptr< MassSpectrum > MassSpectrumSPtr

References pappso::FilterResampleKeepXRange::filter(), pappso::MzRange::lower(), m_msrun_points, pappso::MsRunXicExtractorInterface::m_retentionTimeAroundTarget, pappso::MsRunXicExtractorInterface::m_xicExtractMethod, pappso::Enums::max, pappso::maxYDataPoint(), pappso::MsRunXicExtractorInterface::msp_msrun_reader, pappso::XicCoord::mzRange, pappso::XicCoord::rtTarget, pappso::sumYTrace(), pappso::MzRange::upper(), pappso::DataPoint::x, pappso::XicCoord::xicSptr, and pappso::DataPoint::y.

Referenced by protectedExtractXicCoordSPtrList().

◆ getXicFromPwizMSDataFile()

void pappso::MsRunXicExtractor::getXicFromPwizMSDataFile ( std::vector< Xic * > & xic_list,
const std::vector< MzRange > & mass_range_list,
pappso::pappso_double rt_begin,
pappso::pappso_double rt_end )
protectedvirtual

Definition at line 157 of file msrunxicextractor.cpp.

161{
162 qDebug();
163
164 std::vector<DataPoint> peak_for_mass;
165 for(const MzRange &mass_range : mass_range_list)
166 {
167 peak_for_mass.push_back(DataPoint());
168 qDebug() << " mass_range=" << mass_range.getMz();
169 }
170
171
172 qDebug();
173
174 auto itpoints = m_msrun_points.begin();
175
176 while((itpoints != m_msrun_points.end()) && (itpoints->rt < rt_begin))
177 {
178 itpoints++;
179 }
180
181 MassSpectrumCstSPtr spectrum;
182 while((itpoints != m_msrun_points.end()) && (itpoints->rt <= rt_end))
183 {
184 spectrum = msp_msrun_reader.get()->massSpectrumCstSPtr(itpoints->spectrum_index);
185
186 for(DataPoint &peak : peak_for_mass)
187 {
188 peak.x = itpoints->rt;
189 peak.y = 0;
190 }
191
192
193 // iterate through the m/z-intensity pairs
194 for(auto &&spectrum_point : *(spectrum.get()))
195 {
196 // qDebug() << "getXicFromPwizMSDataFile it->mz " << it->mz <<
197 // " it->intensity" << it->intensity;
198 for(std::size_t i = 0; i < mass_range_list.size(); i++)
199 {
200 if(mass_range_list[i].contains(spectrum_point.x))
201 {
203 {
204 if(peak_for_mass[i].y < spectrum_point.y)
205 {
206 peak_for_mass[i].y = spectrum_point.y;
207 }
208 }
209 else
210 {
211 peak_for_mass[i].y += spectrum_point.y;
212 }
213 }
214 }
215 }
216
217 for(std::size_t i = 0; i < mass_range_list.size(); i++)
218 {
219 // qDebug() << "getXicFromPwizMSDataFile push_back " <<
220 // peak_for_mass[i].rt;
221 xic_list[i]->push_back(peak_for_mass[i]);
222 }
223
224 itpoints++;
225 }
226
227
228 qDebug();
229} // namespace pappso
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr

References m_msrun_points, pappso::MsRunXicExtractorInterface::m_xicExtractMethod, pappso::Enums::max, pappso::MsRunXicExtractorInterface::msp_msrun_reader, and pappso::y.

◆ protectedExtractXicCoordSPtrList()

void pappso::MsRunXicExtractor::protectedExtractXicCoordSPtrList ( UiMonitorInterface & monitor,
std::vector< XicCoordSPtr >::iterator it_xic_coord_list_begin,
std::vector< XicCoordSPtr >::iterator it_xic_coord_list_end )
overrideprotectedvirtual

Implements pappso::MsRunXicExtractorInterface.

Reimplemented in pappso::MsRunXicExtractorDisk.

Definition at line 81 of file msrunxicextractor.cpp.

85{
86
87 // sort xic by mz:
88 std::sort(it_xic_coord_list_begin, it_xic_coord_list_end, [](XicCoordSPtr &a, XicCoordSPtr &b) {
89 return a.get()->rtTarget < b.get()->rtTarget;
90 });
91
92 for(auto it = it_xic_coord_list_begin; it != it_xic_coord_list_end; it++)
93 {
94 // XicCoord *p_xic_coord = sp_xic_coord.get();
95 extractOneXicCoord(*(it->get()));
96 monitor.count();
97 if(monitor.shouldIstop())
98 {
99 throw pappso::ExceptionInterrupted(QObject::tr("Xic extraction process interrupted"));
100 }
101 }
102}
void extractOneXicCoord(XicCoord &xic_coord)
std::shared_ptr< XicCoord > XicCoordSPtr
Definition xiccoord.h:44

References pappso::a, pappso::b, pappso::UiMonitorInterface::count(), extractOneXicCoord(), and pappso::UiMonitorInterface::shouldIstop().

Member Data Documentation

◆ m_msrun_points

std::vector<MsRunXicExtractorPoints> pappso::MsRunXicExtractor::m_msrun_points
protected

◆ MsRunXicExtractorFactory

friend pappso::MsRunXicExtractor::MsRunXicExtractorFactory
private

Definition at line 44 of file msrunxicextractor.h.


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