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")
97 std::vector<XicCoordSPtr>::iterator it_xic_coord_list_begin,
98 std::vector<XicCoordSPtr>::iterator it_xic_coord_list_end)
101 std::sort(it_xic_coord_list_begin,
102 it_xic_coord_list_end,
104 return a.get()->mzRange.getMz() <
b.get()->mzRange.getMz();
107 for(
auto it = it_xic_coord_list_begin; it != it_xic_coord_list_end; it++)
117 std::shared_ptr<Xic> msrunxic_sp = xic_coord.
xicSptr;
123 std::vector<MsRunSliceSPtr> slice_list;
126 if(slice_list.size() == 0)
129 QObject::tr(
"Error getMsRunXicSp slice_list.size() == 0"));
138 if((xic_element.
x < rt_begin) || (xic_element.
x > rt_end))
141 for(
auto &&msrun_slice : slice_list)
143 const MassSpectrum &spectrum = msrun_slice.get()->getSpectrum(i);
144 for(
auto &&peak : spectrum)
150 xic_element.
y += peak.y;
154 if(xic_element.
y < peak.y)
156 xic_element.
y = peak.y;
162 msrunxic_sp.get()->push_back(xic_element);
173 unsigned int slice_number;
174 std::map<unsigned int, MassSpectrum> spectrum_map;
191 spectrum_map.clear();
199 if(p_spectrum->size() > 0)
201 if(p_spectrum->begin()->x <
m_minMz)
203 m_minMz = p_spectrum->begin()->x;
207 if(p_spectrum->back().x >
m_maxMz)
209 m_maxMz = p_spectrum->back().x;
212 for(
auto &peak : *p_spectrum)
215 slice_number = peak.x;
217 std::pair<std::map<unsigned int, MassSpectrum>::iterator,
bool>
218 ret = spectrum_map.insert(std::pair<unsigned int, MassSpectrum>(
221 ret.first->second.push_back(peak);
239 std::map<unsigned int, MassSpectrum> &spectrum_map, std::size_t ipos)
243 for(
auto &&spectrum_pair : spectrum_map)
259 bool new_file =
false;
260 if(!slice_file.exists())
264 if(!slice_file.open(QIODevice::WriteOnly | QIODevice::Append))
267 QObject::tr(
"unable to open file %1").arg(slice_file.fileName()));
269 QDataStream stream(&slice_file);
273 stream << (quint32)slice_number;
277 stream << (quint32)ipos;
291 std::shared_ptr<MsRunSlice> msrun_slice_sp =
296 if(!slice_file.exists())
298 msrun_slice_sp.get()->setSize(
m_rtSize);
299 msrun_slice_sp.get()->setSliceNumber(slice_number);
300 return msrun_slice_sp;
302 if(!slice_file.open(QIODevice::ReadOnly))
305 QObject::tr(
"unable to open file %1 in readonly")
306 .arg(slice_file.fileName()));
308 QDataStream stream(&slice_file);
310 stream >> *(msrun_slice_sp.get());
314 return msrun_slice_sp;
319 QObject::tr(
"error unserializing slice %1:\n%2")
321 .arg(error.
qwhat()));
326 std::vector<MsRunSliceSPtr>
330 std::vector<MsRunSliceSPtr> slice_list;
331 for(
unsigned int i = mz_range.
lower(); i <= mz_range.
upper(); i++)
336 return slice_sp.get()->getSliceNumber() == i;
340 slice_list.push_back(*it);
346 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
virtual void count()=0
count steps report when a step is computed in an algorithm
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 MsRunSlice > MsRunSliceSPtr
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
coordinates of the XIC to extract and the resulting XIC after extraction
XicSPtr xicSptr
extracted xic
double rtTarget
the targeted retention time to extract around intended in seconds, and related to one msrun....
MzRange mzRange
the mass to extract