28#include "../../exception/exceptionnotfound.h"
64 if(it_in_list == end())
70 new_group->push_back(window);
76 (*it_in_list)->push_back(window);
78 std::sort((*it_in_list)->begin(),
81 return (a.ScanNumBegin < b.ScanNumBegin);
95 std::size_t window_group_id)
const
98 auto it_in_list = std::find_if(
105 if(it_in_list == end())
108 QObject::tr(
"MsMsWindowGroup %1 not found").arg(window_group_id));
130 if(!query.exec(
"SELECT WindowGroup, ScanNumBegin, ScanNumEnd, IsolationMz, "
131 "IsolationWidth, CollisionEnergy FROM DiaFrameMsMsWindows;"))
135 QObject::tr(
"ERROR : no DiaFrameMsMsWindows in SqlLite database"));
140 qDebug() << query.size();
141 if(query.size() == 0)
145 QObject::tr(
"ERROR : no DiaFrameMsMsWindows in SqlLite database"));
151 msms_window.
WindowGroup = query.value(0).toLongLong();
153 msms_window.
ScanNumEnd = query.value(2).toLongLong();
154 msms_window.
IsolationMz = query.value(3).toDouble();
166 QObject::tr(
"ERROR : no DiaFrameMsMsWindows in SqlLite database"));
171 std::size_t max_frame_id = 0;
172 if(!query.exec(
"SELECT Frame, WindowGroup FROM DiaFrameMsMsInfo;"))
176 QObject::tr(
"ERROR : no DiaFrameMsMsInfo in SqlLite database"));
180 qDebug() << query.size();
181 if(query.size() == 0)
185 QObject::tr(
"ERROR : no DiaFrameMsMsInfo in SqlLite database"));
190 max_frame_id = query.value(0).toLongLong();
193 query.value(1).toLongLong());
200 QObject::tr(
"ERROR : no DiaFrameMsMsInfo in SqlLite database"));
208 std::size_t last_ms1 = 0;
209 std::size_t previous_frame = 0;
211 std::size_t cumul_global_slice = 0;
213 for(
const std::pair<std::size_t, MsMsWindowGroup *> pair_frame_pgroup :
216 if(previous_frame != pair_frame_pgroup.first - 1)
218 last_ms1 = previous_frame + 1;
221 previous_frame = pair_frame_pgroup.first;
222 qDebug() << pair_frame_pgroup.first <<
" "
225 qDebug() << pair_frame_pgroup.first;
226 slice_range.
frame_id = pair_frame_pgroup.first;
232 cumul_global_slice += pair_frame_pgroup.second->size();
234 if(cumul_global_slice > 0)
247const std::map<std::size_t, TimsDiaSlices::MsMsWindowGroup *> &
271 std::size_t global_slice_index)
const
278 if(global_slice_index < x.begin_global_slice_index)
280 if(global_slice_index > x.end_global_slice_index)
291 .arg(global_slice_index));
302 std::size_t global_slice_index)
const
304 qDebug() << global_slice_index;
308 qDebug() <<
"range.frame_id=" << range.
frame_id
309 <<
" range.begin_global_slice_index="
325 std::size_t global_slice_index)
const
330 raw_spectrum.
clear();
346 tims_frame.get()->combineScansInTofIndexIntensityMap(
354 QObject::tr(
"ERROR in %1 (global_slice_index=%2):\n%3")
356 .arg(global_slice_index)
357 .arg(error.
qwhat()));
359 catch(std::exception &error)
361 qDebug() << QString(
"Failure %1 ").arg(error.
what());
370 std::size_t global_slice_index,
371 bool want_binary_data)
const
389 "global_slice_index=%1 frame=%2 begin=%3 end=%4 group=%5 slice=%6")
390 .arg(global_slice_index)
413 QString(
"frame_id=%1 begin=%2 end=%3 group=%4 slice=%5")
447 qDebug() <<
"bindec";
462 tims_frame.get()->getOneOverK0Transformation(window.
ScanNumBegin));
466 tims_frame.get()->getOneOverK0Transformation(window.
ScanNumEnd));
477 raw_spectrum.
clear();
478 tims_frame.get()->combineScansInTofIndexIntensityMap(
490 tims_frame.get()->getTraceFromTofIndexIntensityMap(raw_spectrum);
510 QObject::tr(
"ERROR in %1 (global_slice_index=%2):\n%3")
512 .arg(global_slice_index)
513 .arg(error.
qwhat()));
515 catch(std::exception &error)
517 qDebug() << QString(
"Failure %1 ").arg(error.
what());
526 std::size_t global_slice_index,
527 bool want_binary_data,
528 int rt_position)
const
550 long index = (long)i + rt_position;
560 "global_slice_index=%1 frame=%2 begin=%3 end=%4 group=%5 slice=%6")
561 .arg(global_slice_index)
600 qDebug() <<
"bindec";
614 tims_frame.get()->getOneOverK0Transformation(window.
ScanNumBegin));
618 tims_frame.get()->getOneOverK0Transformation(window.
ScanNumEnd));
630 quint32 tof_index_begin = tims_frame.get()
631 ->getMzCalibrationInterfaceSPtr()
633 ->getTofIndexFromMz(
mz);
637 quint32 tof_index_end = tims_frame.get()
638 ->getMzCalibrationInterfaceSPtr()
640 ->getTofIndexFromMz(
mz);
642 qDebug() <<
"tof_index_begin=" << tof_index_begin
643 <<
" tof_index_end=" << tof_index_end;
647 raw_spectrum.
clear();
648 tims_frame.get()->combineScansInTofIndexIntensityMap(
664 tims_frame.get()->getTraceFromTofIndexIntensityMap(raw_spectrum);
684 QObject::tr(
"ERROR in %1 (global_slice_index=%2):\n%3")
686 .arg(global_slice_index)
687 .arg(error.
qwhat()));
689 catch(std::exception &error)
691 qDebug() << QString(
"Failure %1 ").arg(error.
what());
void setNativeId(const QString &native_id)
void setMsRunId(MsRunIdCstSPtr other)
void setSpectrumIndex(std::size_t index)
Class to represent a mass spectrum.
const char * what() const noexcept override
virtual const QString & qwhat() const
Class representing a fully specified mass spectrum.
void setPrecursorNativeId(const QString &native_id)
Set the scan native id of the precursor ion.
void setMassSpectrumId(const MassSpectrumId &iD)
Set the MassSpectrumId.
void setMsLevel(uint ms_level)
Set the mass spectrum level.
void setParameterValue(QualifiedMassSpectrumParameter parameter, const QVariant &value)
void setMassSpectrumSPtr(MassSpectrumSPtr massSpectrum)
Set the MassSpectrumSPtr.
void setRtInSeconds(pappso_double rt)
Set the retention time in seconds.
void setEmptyMassSpectrum(bool is_empty_mass_spectrum)
void builtInCentroid()
simple filter to agregate counts on neigbhor mobility slots (+1)
static TimsDataFastMap & getTimsDataFastMapInstance()
TimsFrameCstSPtr getTimsFrameCstSPtrCached(std::size_t timsId)
get a Tims frame with his database ID but look in the cache first
TimsFrameBaseCstSPtr getTimsFrameBaseCstSPtrCached(std::size_t timsId)
std::vector< std::size_t > m_ms2frameId2Ms1FrameId
TimsDataFastMap & getCombinedMs2ScansByGlobalSliceIndex(std::size_t global_slice_index) const
std::size_t getGlobalSliceIndexBeginByFrameId(std::size_t frame_id) const
std::size_t getLastMs1FrameIdByMs2FrameId(std::size_t frame_id) const
const FrameSliceRange & getFrameSliceRangeByGlobalSliceIndex(std::size_t global_slice_index) const
MsMsWindowGroupList m_msMsWindowGroupList
const MsMsWindow & getMsMsWindowByGlobalSliceIndex(std::size_t global_slice_index) const
bool m_builtinMs2Centroid
enable builtin centroid on raw tims integers by default
std::vector< std::size_t > m_ms1frameIdList
std::map< std::size_t, MsMsWindowGroup * > m_mapFrame2WindowGroupPtr
std::size_t m_totalSlicesCount
std::size_t getFrameIdByGlobalSliceIndex(std::size_t global_slice_id) const
std::vector< std::size_t > m_frameId2GlobalSliceIndexBegin
void getMs2QualifiedSpectrumByGlobalSliceIndex(const MsRunIdCstSPtr &msrun_id, QualifiedMassSpectrum &mass_spectrum, std::size_t global_slice_index, bool want_binary_data) const
const std::map< std::size_t, MsMsWindowGroup * > & getMapFrame2WindowGroupPtr() const
void getMs1QualifiedSpectrumByGlobalSliceIndex(const MsRunIdCstSPtr &msrun_id, QualifiedMassSpectrum &mass_spectrum, std::size_t global_slice_index, bool want_binary_data, int rt_position=0) const
get MS1 spectrum corresponding to the given slice extract MS1 mz range and mobility range correspondi...
TimsDiaSlices(QSqlQuery &query, TimsData *tims_data_origin)
std::vector< FrameSliceRange > m_frameSliceRangeList
std::size_t getTotalSlicesCount() const
get the number of DIA MS2 slices analyzed by PASEF
const MsMsWindowGroupList & getMsMsWindowGroupList() const
TimsData * mp_timsDataOrigin
A simple container of DataPoint instances.
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::shared_ptr< const TimsFrameBase > TimsFrameBaseCstSPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
@ IsolationMzWidth
m/z isolation window width (left + right)
@ TimsFrameIonMobScanIndexBegin
@ TimsFrameIonMobScanIndexEnd
@ CollisionEnergy
Bruker's timsTOF collision energy.
@ IonMobOneOverK0Begin
1/K0 range's begin value
@ IonMobOneOverK0End
1/K0 range's end value
@ IsolationMz
Isolation m/z value.
std::shared_ptr< const TimsFrame > TimsFrameCstSPtr
std::size_t end_global_slice_index
std::size_t begin_global_slice_index
MsMsWindowGroup * getWindowGroupPtrByGroupId(std::size_t window_group_id) const
void addInGroup(const MsMsWindow &window)
bool isMzInRange(double mz) const
tell if given mz is in range for this window
handle specific data for DIA MS runs