33 #include "../../pappsoexception.h"
34 #include "../../processing/filters/filterresample.h"
41 :
pappso::MsRunXicExtractorInterface(msrun_reader)
44 MsRunXicExtractorReadPoints get_msrun_points(m_msrun_points);
45 msp_msrun_reader.get()->readSpectrumCollection(get_msrun_points);
47 std::sort(m_msrun_points.begin(),
49 [](
const MsRunXicExtractorPoints &a,
50 const MsRunXicExtractorPoints &b) { return a.rt < b.rt; });
53 if(m_msrun_points.size() == 0)
56 QObject::tr(
"error extracting XIC: no MS level 1 in data file"));
75 FilterResampleKeepXRange keep_range(mz_range.lower(), mz_range.upper());
76 std::shared_ptr<Xic> msrunxic_sp = std::make_shared<Xic>(Xic());
81 while((itpoints !=
m_msrun_points.end()) && (itpoints->rt < rt_begin))
87 while((itpoints !=
m_msrun_points.end()) && (itpoints->rt <= rt_end))
94 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__
95 <<
" spectrum->size()=" << spectrum->size();
96 keep_range.filter(*(spectrum.get()));
97 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__
98 <<
" spectrum->size()=" << spectrum->size();
100 peak.
x = itpoints->rt;
105 if(spectrum->size() > 0)
109 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__
110 <<
" peak.y=" << peak.
y
111 <<
" spectrum->size()=" << spectrum->size();
116 peak.
y =
sumYTrace(spectrum->begin(), spectrum->end(), 0);
118 msrunxic_sp->push_back(peak);
124 return (msrunxic_sp);
127 std::vector<XicCstSPtr>
131 std::vector<std::shared_ptr<Xic>> xic_list_return;
132 std::vector<Xic *> xic_list;
133 for(std::size_t i = 0; i < mz_range_list.size(); i++)
135 xic_list_return.push_back(std::make_shared<Xic>(Xic()));
136 xic_list.push_back(xic_list_return.back().get());
140 std::vector<XicCstSPtr> xic_list_return_b;
141 for(
auto &xic : xic_list_return)
143 xic_list_return_b.push_back(xic);
145 return xic_list_return_b;
150 std::vector<Xic *> &xic_list,
151 const std::vector<MzRange> &mass_range_list,
155 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__;
157 std::vector<DataPoint> peak_for_mass;
158 for(
const MzRange &mass_range : mass_range_list)
161 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__
162 <<
" mass_range=" << mass_range.getMz();
166 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__;
176 while((itpoints !=
m_msrun_points.end()) && (itpoints->rt <= rt_end))
183 peak.
x = itpoints->rt;
189 for(
auto &&spectrum_point : *(spectrum.get()))
193 for(std::size_t i = 0; i < mass_range_list.size(); i++)
195 if(mass_range_list[i].contains(spectrum_point.x))
199 if(peak_for_mass[i].y < spectrum_point.y)
201 peak_for_mass[i].y = spectrum_point.y;
206 peak_for_mass[i].y += spectrum_point.y;
212 for(std::size_t i = 0; i < mass_range_list.size(); i++)
216 xic_list[i]->push_back(peak_for_mass[i]);
223 qDebug() << __FILE__ <<
" " << __FUNCTION__ <<
" " << __LINE__;