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")
99 QObject::tr(
"extracting %1 XICs").arg(xic_coord_list.size()));
102 std::sort(xic_coord_list.begin(),
103 xic_coord_list.end(),
105 return a.get()->mzRange.getMz() < b.get()->mzRange.getMz();
118 std::shared_ptr<Xic> msrunxic_sp = xic_coord.
xicSptr;
124 std::vector<MsRunSliceSPtr> slice_list;
127 if(slice_list.size() == 0)
130 QObject::tr(
"Error getMsRunXicSp slice_list.size() == 0"));
139 if((xic_element.
x < rt_begin) || (xic_element.
x > rt_end))
142 for(
auto &&msrun_slice : slice_list)
144 const MassSpectrum &spectrum = msrun_slice.get()->getSpectrum(i);
145 for(
auto &&peak : spectrum)
151 xic_element.
y += peak.y;
155 if(xic_element.
y < peak.y)
157 xic_element.
y = peak.y;
163 msrunxic_sp.get()->push_back(xic_element);
174 unsigned int slice_number;
175 std::map<unsigned int, MassSpectrum> spectrum_map;
192 spectrum_map.clear();
200 if(p_spectrum->size() > 0)
202 if(p_spectrum->begin()->x <
m_minMz)
204 m_minMz = p_spectrum->begin()->x;
208 if(p_spectrum->back().x >
m_maxMz)
210 m_maxMz = p_spectrum->back().x;
213 for(
auto &peak : *p_spectrum)
216 slice_number = peak.x;
218 std::pair<std::map<unsigned int, MassSpectrum>::iterator,
bool>
219 ret = spectrum_map.insert(std::pair<unsigned int, MassSpectrum>(
222 ret.first->second.push_back(peak);
240 std::map<unsigned int, MassSpectrum> &spectrum_map, std::size_t ipos)
244 for(
auto &&spectrum_pair : spectrum_map)
260 bool new_file =
false;
261 if(!slice_file.exists())
265 if(!slice_file.open(QIODevice::WriteOnly | QIODevice::Append))
268 QObject::tr(
"unable to open file %1").arg(slice_file.fileName()));
270 QDataStream stream(&slice_file);
274 stream << (quint32)slice_number;
278 stream << (quint32)ipos;
292 std::shared_ptr<MsRunSlice> msrun_slice_sp =
297 if(!slice_file.exists())
299 msrun_slice_sp.get()->setSize(
m_rtSize);
300 msrun_slice_sp.get()->setSliceNumber(slice_number);
301 return msrun_slice_sp;
303 if(!slice_file.open(QIODevice::ReadOnly))
306 QObject::tr(
"unable to open file %1 in readonly")
307 .arg(slice_file.fileName()));
309 QDataStream stream(&slice_file);
311 stream >> *(msrun_slice_sp.get());
315 return msrun_slice_sp;
320 QObject::tr(
"error unserializing slice %1:\n%2")
322 .arg(error.
qwhat()));
327 std::vector<MsRunSliceSPtr>
331 std::vector<MsRunSliceSPtr> slice_list;
332 for(
unsigned int i = mz_range.
lower(); i <= mz_range.
upper(); i++)
337 return slice_sp.get()->getSliceNumber() == i;
341 slice_list.push_back(*it);
347 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 setStatus(const QString &status)=0
current status of the process
virtual void setTotalSteps(std::size_t total_number_of_steps)
use it if the number of steps is known in an algorithm the total number of steps is usefull to report...
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