59 auto it_in_list = std::find_if(begin(), end(), [group_id](
const MsMsWindowGroup *group) {
64 if(it_in_list == end())
70 new_group->push_back(window);
76 (*it_in_list)->push_back(window);
80 return (a.ScanNumBegin < b.ScanNumBegin);
96 auto it_in_list = std::find_if(begin(), end(), [window_group_id](
const MsMsWindowGroup *group) {
102 if(it_in_list == end())
105 QObject::tr(
"MsMsWindowGroup %1 not found").arg(window_group_id));
127 if(!query.exec(
"SELECT WindowGroup, ScanNumBegin, ScanNumEnd, IsolationMz, "
128 "IsolationWidth, CollisionEnergy FROM DiaFrameMsMsWindows;"))
131 throw ExceptionNotFound(QObject::tr(
"ERROR : executing %1 :\n%2")
132 .arg(query.lastQuery())
133 .arg(query.lastError().text()));
138 qDebug() << query.size();
139 if(query.size() == 0)
144 throw ExceptionNotFound(
145 QObject::tr(
"ERROR : DiaFrameMsMsWindows table is empty in SqlLite database"));
151 msms_window.WindowGroup = query.value(0).toLongLong();
152 msms_window.ScanNumBegin = query.value(1).toLongLong();
153 msms_window.ScanNumEnd = query.value(2).toLongLong();
154 msms_window.IsolationMz = query.value(3).toDouble();
155 msms_window.IsolationWidth = query.value(4).toDouble();
156 msms_window.CollisionEnergy = query.value(5).toDouble();
159 m_msMsWindowGroupList.addInGroup(msms_window);
167 throw ExceptionNotFound(
168 QObject::tr(
"ERROR : no DiaFrameMsMsWindows in SqlLite database"));
173 std::size_t max_frame_id = 0;
174 if(!query.exec(
"SELECT Frame, WindowGroup FROM DiaFrameMsMsInfo;"))
178 QObject::tr(
"ERROR : no DiaFrameMsMsInfo in SqlLite database"));
182 qDebug() << query.size();
183 if(query.size() == 0)
187 QObject::tr(
"ERROR : no DiaFrameMsMsInfo in SqlLite database"));
192 max_frame_id = query.value(0).toLongLong();
193 m_mapFrame2WindowGroupPtr[query.value(0).toLongLong()] =
194 m_msMsWindowGroupList.getWindowGroupPtrByGroupId(query.value(1).toLongLong());
197 if(m_mapFrame2WindowGroupPtr.size() == 0)
200 throw ExceptionNotFound(QObject::tr(
"ERROR : no DiaFrameMsMsInfo in SqlLite database"));
205 m_frameId2GlobalSliceIndexBegin.resize(max_frame_id + 1);
207 m_ms2frameId2Ms1FrameId.resize(max_frame_id + 1);
208 std::size_t last_ms1 = 0;
209 std::size_t previous_frame = 0;
211 std::size_t cumul_global_slice = 0;
212 m_ms1frameIdList.clear();
213 for(
const std::pair<std::size_t, MsMsWindowGroup *> pair_frame_pgroup : m_mapFrame2WindowGroupPtr)
215 if(previous_frame != pair_frame_pgroup.first - 1)
217 last_ms1 = previous_frame + 1;
218 m_ms1frameIdList.push_back(last_ms1);
220 previous_frame = pair_frame_pgroup.first;
221 qDebug() << pair_frame_pgroup.first <<
" " << m_frameId2GlobalSliceIndexBegin.size();
222 FrameSliceRange slice_range;
223 qDebug() << pair_frame_pgroup.first;
224 slice_range.frame_id = pair_frame_pgroup.first;
225 slice_range.begin_global_slice_index = cumul_global_slice;
226 m_frameId2GlobalSliceIndexBegin[pair_frame_pgroup.first] = cumul_global_slice;
227 m_ms2frameId2Ms1FrameId[pair_frame_pgroup.first] = last_ms1;
229 cumul_global_slice += pair_frame_pgroup.second->size();
231 if(cumul_global_slice > 0)
232 slice_range.end_global_slice_index = cumul_global_slice - 1;
233 m_frameSliceRangeList.push_back(slice_range);
237 m_totalSlicesCount = cumul_global_slice;
244const std::map<std::size_t, TimsDiaSlices::MsMsWindowGroup *> &
274 if(global_slice_index < x.begin_global_slice_index)
276 if(global_slice_index > x.end_global_slice_index)
287 QObject::tr(
"ERROR : GlobalSliceIndex %1 not found").arg(global_slice_index));
299 qDebug() << global_slice_index;
303 qDebug() <<
"range.frame_id=" << range.
frame_id
323 raw_spectrum.
clear();
337 tims_frame.get()->combineScansInTofIndexIntensityMap(
344 throw PappsoException(QObject::tr(
"ERROR in %1 (global_slice_index=%2):\n%3")
346 .arg(global_slice_index)
347 .arg(error.
qwhat()));
349 catch(std::exception &error)
351 qDebug() << QString(
"Failure %1 ").arg(error.
what());
359 std::size_t global_slice_index,
360 bool want_binary_data)
const
375 QString(
"global_slice_index=%1 frame=%2 begin=%3 end=%4 group=%5 slice=%6")
376 .arg(global_slice_index)
428 qDebug() <<
"bindec";
441 tims_frame.get()->getOneOverK0Transformation(window.
ScanNumBegin));
445 tims_frame.get()->getOneOverK0Transformation(window.
ScanNumEnd));
455 raw_spectrum.
clear();
456 tims_frame.get()->combineScansInTofIndexIntensityMap(
467 trace = tims_frame.get()->getTraceFromTofIndexIntensityMap(raw_spectrum);
485 throw PappsoException(QObject::tr(
"ERROR in %1 (global_slice_index=%2):\n%3")
487 .arg(global_slice_index)
488 .arg(error.
qwhat()));
490 catch(std::exception &error)
492 qDebug() << QString(
"Failure %1 ").arg(error.
what());
500 std::size_t global_slice_index,
501 bool want_binary_data,
502 int rt_position)
const
522 long index = (long)i + rt_position;
531 QString(
"global_slice_index=%1 frame=%2 begin=%3 end=%4 group=%5 slice=%6")
532 .arg(global_slice_index)
569 qDebug() <<
"bindec";
581 tims_frame.get()->getOneOverK0Transformation(window.
ScanNumBegin));
585 tims_frame.get()->getOneOverK0Transformation(window.
ScanNumEnd));
597 quint32 tof_index_begin =
598 tims_frame.get()->getMzCalibrationInterfaceSPtr().get()->getTofIndexFromMz(mz);
602 quint32 tof_index_end =
603 tims_frame.get()->getMzCalibrationInterfaceSPtr().get()->getTofIndexFromMz(mz);
605 qDebug() <<
"tof_index_begin=" << tof_index_begin <<
" tof_index_end=" << tof_index_end;
608 raw_spectrum.
clear();
609 tims_frame.get()->combineScansInTofIndexIntensityMap(
620 trace = tims_frame.get()->getTraceFromTofIndexIntensityMap(raw_spectrum);
638 throw PappsoException(QObject::tr(
"ERROR in %1 (global_slice_index=%2):\n%3")
640 .arg(global_slice_index)
641 .arg(error.
qwhat()));
643 catch(std::exception &error)
645 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()
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 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