libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
timsframemobilitytraces.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/vendors/tims/mobilitytraces
3 * \date 05/07/2024
4 * \author Olivier Langella
5 * \brief extracting mobility traces
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2024 Olivier Langella
10 *<Olivier.Langella@universite-paris-saclay.fr>.
11 *
12 * This file is part of the PAPPSOms++ library.
13 *
14 * PAPPSOms++ is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * PAPPSOms++ is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
26 *
27 ******************************************************************************/
28
31#include <QDebug>
32namespace pappso
33{
37
42
46void
48 std::size_t scan_index_begin,
49 std::size_t scan_index_end,
50 std::size_t max_traces)
51{
52 m_tofIndexList.clear();
53 m_ionMobTraceList.clear();
54 m_scanIndexList.clear();
55 mcsp_timsFrameCstSPtr = timsframe_sptr;
56
58 timsframe_sptr.get()->combineScansInTofIndexIntensityMap(
59 raw_spectrum, scan_index_begin, scan_index_end);
60
61 pappso::Trace total_spectrum;
62
63 for(auto index : raw_spectrum.getTofIndexList())
64 {
65
66 total_spectrum.push_back({(double)index, (double)raw_spectrum.readIntensity(index)});
67 }
68 total_spectrum.sortY(Enums::SortOrder::descending);
69
70 qDebug() << total_spectrum.size();
71
72 total_spectrum.sortY(Enums::SortOrder::descending);
73
74 for(std::size_t i = scan_index_begin; i < (scan_index_end + 1); i++)
75 {
76 m_scanIndexList.push_back(i);
77 }
78
79 for(auto &datapoint : total_spectrum)
80 {
81 pappso::Trace trace(
82 timsframe_sptr.get()->getIonMobilityTraceByTofIndexRange(datapoint.x - 1,
83 datapoint.x + 1,
85 scan_index_begin,
86 scan_index_end));
87
88 m_ionMobTraceList.push_back(trace.makeTraceSPtr());
89 m_tofIndexList.push_back(datapoint.x);
90 if(m_ionMobTraceList.size() >= max_traces)
91 break;
92 }
93 qDebug();
94}
95
96const std::vector<pappso::TraceCstSPtr> &
101const std::vector<std::size_t> &
106const std::vector<double>
108{
109 MzCalibrationInterface *mz_calibration_p =
110 mcsp_timsFrameCstSPtr.get()->getMzCalibrationInterfaceSPtr().get();
111 if(mz_calibration_p == nullptr)
112 {
113 throw pappso::ExceptionNotFound(QObject::tr("mz calibration pointer not found"));
114 }
115 std::vector<double> mz_list;
116 for(std::size_t tof : m_tofIndexList)
117 {
118 mz_list.push_back(mz_calibration_p->getMzFromTofIndex((quint32)tof));
119 }
120 return mz_list;
121}
122const std::vector<std::size_t> &
127} // namespace pappso
virtual double getMzFromTofIndex(quint32 tof_index)=0
get m/z from time of flight raw index
replacement for std::map
const std::vector< quint32 > & getTofIndexList() const
std::size_t readIntensity(quint32)
reads intensity for a tof_index
static TimsDataFastMap & getTimsDataFastMapInstance()
void extractMobilityTraces(pappso::TimsFrameCstSPtr timsframe_sptr, std::size_t ion_mob_begin, std::size_t ion_mob_end, std::size_t max_traces)
pappso::TimsFrameCstSPtr mcsp_timsFrameCstSPtr
const std::vector< std::size_t > & getScanIndexList() const
std::vector< std::size_t > m_tofIndexList
std::vector< pappso::TraceCstSPtr > m_ionMobTraceList
const std::vector< double > getMzList() const
std::vector< std::size_t > m_scanIndexList
const std::vector< std::size_t > & getTofIndexList() const
const std::vector< pappso::TraceCstSPtr > & getIonMobTraceList() const
A simple container of DataPoint instances.
Definition trace.h:152
void sortY(Enums::SortOrder sort_order=Enums::SortOrder::ascending)
Definition trace.cpp:1081
TraceSPtr makeTraceSPtr() const
Definition trace.cpp:683
@ sum
sum of intensities
Definition types.h:279
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::shared_ptr< const TimsFrame > TimsFrameCstSPtr
Definition timsframe.h:44