33 #include "../../pappsoexception.h"
34 #include "../../massspectrum/massspectrum.h"
40 const QDir &temporary_dir)
53 QString(
"%1/msrun_%2_")
79 QObject::tr(
"Error reading file (%1) : %2")
81 .arg(errora.
qwhat()));
83 catch(std::exception &error)
87 QObject::tr(
"Error reading file (%1) using : %2")
98 std::shared_ptr<Xic> msrunxic_sp = std::make_shared<Xic>(
Xic());
100 std::vector<MsRunSliceSPtr> slice_list;
103 if(slice_list.size() == 0)
106 QObject::tr(
"Error getMsRunXicSp slice_list.size() == 0"));
115 if((xic_element.
x < rt_begin) || (xic_element.
x > rt_end))
118 for(
auto &&msrun_slice : slice_list)
120 const MassSpectrum &spectrum = msrun_slice.get()->getSpectrum(i);
121 for(
auto &&peak : spectrum)
127 xic_element.
y += peak.y;
131 if(xic_element.
y < peak.y)
133 xic_element.
y = peak.y;
139 msrunxic_sp.get()->push_back(xic_element);
142 return (msrunxic_sp);
145 std::vector<XicCstSPtr>
147 const std::vector<MzRange> &mz_range_list)
150 std::vector<XicCstSPtr> xic_list_return;
151 for(
auto &range : mz_range_list)
153 xic_list_return.push_back(
getXicCstSPtr(range, 0, 40000000));
155 return xic_list_return;
165 unsigned int slice_number;
166 std::map<unsigned int, MassSpectrum> spectrum_map;
183 spectrum_map.clear();
191 if(p_spectrum->size() > 0)
193 if(p_spectrum->begin()->x <
m_minMz)
195 m_minMz = p_spectrum->begin()->x;
199 if(p_spectrum->back().x >
m_maxMz)
201 m_maxMz = p_spectrum->back().x;
204 for(
auto &peak : *p_spectrum)
207 slice_number = peak.x;
209 std::pair<std::map<unsigned int, MassSpectrum>::iterator,
bool>
210 ret = spectrum_map.insert(std::pair<unsigned int, MassSpectrum>(
213 ret.first->second.push_back(peak);
231 std::map<unsigned int, MassSpectrum> &spectrum_map, std::size_t ipos)
235 for(
auto &&spectrum_pair : spectrum_map)
251 bool new_file =
false;
252 if(!slice_file.exists())
256 if(!slice_file.open(QIODevice::WriteOnly | QIODevice::Append))
259 QObject::tr(
"unable to open file %1").arg(slice_file.fileName()));
261 QDataStream stream(&slice_file);
265 stream << (quint32)slice_number;
269 stream << (quint32)ipos;
283 std::shared_ptr<MsRunSlice> msrun_slice_sp =
288 if(!slice_file.exists())
290 msrun_slice_sp.get()->setSize(
m_rtSize);
291 msrun_slice_sp.get()->setSliceNumber(slice_number);
292 return msrun_slice_sp;
294 if(!slice_file.open(QIODevice::ReadOnly))
297 QObject::tr(
"unable to open file %1 in readonly")
298 .arg(slice_file.fileName()));
300 QDataStream stream(&slice_file);
302 stream >> *(msrun_slice_sp.get());
306 return msrun_slice_sp;
311 QObject::tr(
"error unserializing slice %1:\n%2")
313 .arg(error.
qwhat()));
318 std::vector<MsRunSliceSPtr>
322 std::vector<MsRunSliceSPtr> slice_list;
323 for(
unsigned int i = mz_range.
lower(); i <= mz_range.
upper(); i++)
328 return slice_sp.get()->getSliceNumber() == i;
332 slice_list.push_back(*it);
338 slice_list.push_back(slice_sp);
Class to represent a mass spectrum.
pappso_double lower() const
pappso_double upper() const
bool contains(pappso_double) const
virtual const QString & qwhat() const
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::shared_ptr< MsRunReader > MsRunReaderSPtr
std::shared_ptr< const Xic > XicCstSPtr
std::shared_ptr< const MsRunSlice > MsRunSliceSPtr
double pappso_double
A type definition for doubles.
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr