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
30#include "../../../exception/exceptionnotfound.h"
31#include <QDebug>
32namespace pappso
33{
37
42
46void
48 pappso::TimsFrameCstSPtr timsframe_sptr,
49 std::size_t scan_index_begin,
50 std::size_t scan_index_end,
51 std::size_t max_traces)
52{
53 m_tofIndexList.clear();
54 m_ionMobTraceList.clear();
55 m_scanIndexList.clear();
56 mcsp_timsFrameCstSPtr = timsframe_sptr;
57
58 pappso::TimsDataFastMap raw_spectrum =
60 timsframe_sptr.get()->combineScansInTofIndexIntensityMap(
61 raw_spectrum, scan_index_begin, scan_index_end);
62
63 pappso::Trace total_spectrum;
64
65 for(auto index : raw_spectrum.getTofIndexList())
66 {
67
68 total_spectrum.push_back(
69 {(double)index, (double)raw_spectrum.readIntensity(index)});
70 }
71 total_spectrum.sortY(SortOrder::descending);
72
73 qDebug() << total_spectrum.size();
74
76
77 for(std::size_t i = scan_index_begin; i < (scan_index_end + 1); i++)
78 {
79 m_scanIndexList.push_back(i);
80 }
81
82 for(auto &datapoint : total_spectrum)
83 {
84 pappso::Trace trace(
85 timsframe_sptr.get()->getIonMobilityTraceByTofIndexRange(
86 datapoint.x - 1,
87 datapoint.x + 1,
89 scan_index_begin,
90 scan_index_end));
91
92 m_ionMobTraceList.push_back(trace.makeTraceSPtr());
93 m_tofIndexList.push_back(datapoint.x);
94 if(m_ionMobTraceList.size() >= max_traces)
95 break;
96 }
97 qDebug();
98}
99
100const std::vector<pappso::TraceCstSPtr> &
105const std::vector<std::size_t> &
110const std::vector<double>
112{
113 MzCalibrationInterface *mz_calibration_p =
114 mcsp_timsFrameCstSPtr.get()->getMzCalibrationInterfaceSPtr().get();
115 if(mz_calibration_p == nullptr)
116 {
118 QObject::tr("mz calibration pointer not found"));
119 }
120 std::vector<double> mz_list;
121 for(std::size_t tof : m_tofIndexList)
122 {
123 mz_list.push_back(mz_calibration_p->getMzFromTofIndex((quint32)tof));
124 }
125 return mz_list;
126}
127const std::vector<std::size_t> &
132} // 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:148
void sortY(SortOrder sort_order=SortOrder::ascending)
Definition trace.cpp:1100
TraceSPtr makeTraceSPtr() const
Definition trace.cpp:674
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
@ sum
sum of intensities
std::shared_ptr< const TimsFrame > TimsFrameCstSPtr
Definition timsframe.h:43