libpappsomspp
Library for mass spectrometry
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 (XicExtractMethod method)
 set the XIC extraction method More...
 
void setRetentionTimeAroundTarget (double range_in_seconds)
 set the retention time range in seconds around the target rt More...
 
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 More...
 
virtual void extractXicCoordSPtrListParallelized (UiMonitorInterface &monitor, std::vector< XicCoordSPtr > &xic_coord_list) final
 multithreaded XIC extraction More...
 
const MsRunIdCstSPtrgetMsRunId () const
 
const MsRunReaderSPtrgetMsRunReaderSPtr () const
 get the msrunreader currently used for XIC extraction More...
 
void setPostExtractionTraceFilterCstSPtr (pappso::FilterInterfaceCstSPtr &filter)
 filter interface to apply just after XIC extration on each trace More...
 

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 More...
 
 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 More...
 
virtual void protectedExtractXicCoordSPtrList (UiMonitorInterface &monitor, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_begin, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_end)=0
 

Protected Attributes

std::vector< MsRunXicExtractorPointsm_msrun_points
 
- Protected Attributes inherited from pappso::MsRunXicExtractorInterface
MsRunReaderSPtr msp_msrun_reader
 
XicExtractMethod m_xicExtractMethod = 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 41 of file msrunxicextractor.h.

Constructor & Destructor Documentation

◆ MsRunXicExtractor() [1/2]

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

Definition at line 65 of file msrunxicextractor.cpp.

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

References m_msrun_points.

◆ ~MsRunXicExtractor()

pappso::MsRunXicExtractor::~MsRunXicExtractor ( )
virtual

Definition at line 60 of file msrunxicextractor.cpp.

61{
62}

◆ MsRunXicExtractor() [2/2]

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

Definition at line 41 of file msrunxicextractor.cpp.

43{
44
45 MsRunXicExtractorReadPoints get_msrun_points(m_msrun_points);
46 msp_msrun_reader.get()->readSpectrumCollection(get_msrun_points);
47
48 std::sort(m_msrun_points.begin(),
49 m_msrun_points.end(),
50 [](const MsRunXicExtractorPoints &a,
51 const MsRunXicExtractorPoints &b) { return a.rt < b.rt; });
52
53
54 if(m_msrun_points.size() == 0)
55 {
57 QObject::tr("error extracting XIC: no MS level 1 in data file"));
58 }
59}

References pappso::a, pappso::b, m_msrun_points, and pappso::MsRunXicExtractorInterface::msp_msrun_reader.

Member Function Documentation

◆ extractOneXicCoord()

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

Definition at line 101 of file msrunxicextractor.cpp.

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

References pappso::FilterResampleKeepXRange::filter(), pappso::MzRange::lower(), m_msrun_points, pappso::MsRunXicExtractorInterface::m_retentionTimeAroundTarget, pappso::MsRunXicExtractorInterface::m_xicExtractMethod, pappso::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 155 of file msrunxicextractor.cpp.

160{
161 qDebug();
162
163 std::vector<DataPoint> peak_for_mass;
164 for(const MzRange &mass_range : mass_range_list)
165 {
166 peak_for_mass.push_back(DataPoint());
167 qDebug() << " mass_range=" << mass_range.getMz();
168 }
169
170
171 qDebug();
172
173 auto itpoints = m_msrun_points.begin();
174
175 while((itpoints != m_msrun_points.end()) && (itpoints->rt < rt_begin))
176 {
177 itpoints++;
178 }
179
180 MassSpectrumCstSPtr spectrum;
181 while((itpoints != m_msrun_points.end()) && (itpoints->rt <= rt_end))
182 {
183 spectrum =
184 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
Definition: massspectrum.h:55

References m_msrun_points, pappso::MsRunXicExtractorInterface::m_xicExtractMethod, pappso::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 73 of file msrunxicextractor.cpp.

77{
78
79 // sort xic by mz:
80 std::sort(it_xic_coord_list_begin,
81 it_xic_coord_list_end,
82 [](XicCoordSPtr &a, XicCoordSPtr &b) {
83 return a.get()->rtTarget < b.get()->rtTarget;
84 });
85
86 for(auto it = it_xic_coord_list_begin; it != it_xic_coord_list_end; it++)
87 {
88 // XicCoord *p_xic_coord = sp_xic_coord.get();
89 extractOneXicCoord(*(it->get()));
90 monitor.count();
91 if(monitor.shouldIstop())
92 {
94 QObject::tr("Xic extraction process interrupted"));
95 }
96 }
97}
void extractOneXicCoord(XicCoord &xic_coord)
std::shared_ptr< XicCoord > XicCoordSPtr
Definition: xiccoord.h:43

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 43 of file msrunxicextractor.h.


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