libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
msrunreader.h
Go to the documentation of this file.
1/**
2 * \file pappsomspp/msrun/msrunreader.h
3 * \date 29/05/2018
4 * \author Olivier Langella
5 * \brief base interface to read MSrun files
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2018 Olivier Langella <Olivier.Langella@u-psud.fr>.
10 *
11 * This file is part of the PAPPSOms++ library.
12 *
13 * PAPPSOms++ is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * PAPPSOms++ is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25 *
26 ******************************************************************************/
27
28#pragma once
29
30
31/////////////////////// StdLib includes
32#include <memory>
33#include <map>
34
35
36/////////////////////// Qt includes
37#include <QMutex>
38
39
40/////////////////////// pappsomspp includes
41#include "../trace/maptrace.h"
42
43/////////////////////// Local includes
45#include "msrunreadconfig.h"
46#include "msrunid.h"
50#include "xiccoord/xiccoord.h"
51
52namespace pappso
53{
54
56typedef std::shared_ptr<MsRunReader> MsRunReaderSPtr;
57typedef std::shared_ptr<const MsRunReader> MsRunReaderCstSPtr;
58
59/** @brief base class to read MSrun
60 * the only way to build a MsRunReader object is to use the MsRunReaderFactory
61 */
63{
64
65 friend class MsFileAccessor;
66
67 public:
68 MsRunReader(const MsRunIdCstSPtr &ms_run_id);
69 MsRunReader(const MsRunReader &other);
70 virtual ~MsRunReader();
71
72 const MsRunIdCstSPtr &getMsRunId() const;
73
74 /** @brief get a MassSpectrumSPtr class given its spectrum index
75 */
76 virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) = 0;
78 massSpectrumCstSPtr(std::size_t spectrum_index) = 0;
79
80 /** @brief get a QualifiedMassSpectrum class given its scan number
81 */
83 qualifiedMassSpectrum(std::size_t spectrum_index,
84 bool want_binary_data = true) const = 0;
85
86
87 /** @brief get a xic coordinate object from a given spectrum index
88 */
89 virtual XicCoordSPtr
90 newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index,
91 PrecisionPtr precision) const = 0;
92
93 /** @brief get a xic coordinate object from a given spectrum
94 */
96 const QualifiedMassSpectrum &mass_spectrum,
97 PrecisionPtr precision) const = 0;
98
99 /** @brief get the totat number of spectrum conained in the MSrun data file
100 */
101 virtual std::size_t spectrumListSize() const = 0;
102
103 /** @brief function to visit an MsRunReader and get each Spectrum in a
104 * spectrum collection handler
105 */
106 virtual void
108
109 virtual void
112
113 /** @brief function to visit an MsRunReader and get each Spectrum in a
114 * spectrum collection handler by Ms Levels
115 */
116 virtual void
118 unsigned int ms_level) = 0;
119
120
121 /** @brief if possible, converts a scan number into a spectrum index
122 * This is a convenient function to help transition from the old scan number
123 * (not implemented by all vendors) to more secure spectrum index (not vendor
124 * dependant).
125 * It is better to not rely on this function.
126 */
127 virtual std::size_t scanNumber2SpectrumIndex(std::size_t scan_number);
128
129 /** @brief tells if spectra can be accessed using scan numbers
130 * by default, it returns false. Only overrided functions can check if scan
131 * numbers are available in the current file
132 */
133 virtual bool hasScanNumbers() const;
134
135
136 /** @brief release data back end device
137 * if a the data back end is released, the developper has to use acquireDevice
138 * before using the msrunreader object
139 * @return bool true if done
140 */
141 virtual bool releaseDevice() = 0;
142
143 /** @brief acquire data back end device
144 * @return bool true if done
145 */
146 virtual bool acquireDevice() = 0;
147
148 /** @brief retention timeline
149 * get retention times along the MSrun in seconds
150 * @return vector of retention times (seconds)
151 */
152 virtual std::vector<double> getRetentionTimeLine();
153
154 /** @brief get a TIC chromatogram
155 *
156 * for each retention time, computes the sum of all intensities.
157 * For IM-MS, combines the mobility spectra
158 *
159 * Note that, formally, a TIC chromatogram is computed only for MS1 spectra.
160 *
161 * @return a trace (x=rt, y=intensities)
162 */
163 virtual Trace getTicChromatogram();
164
165
166 /** @brief set only one is_mono_thread to true
167 *
168 * this avoid to use qtconcurrent
169 */
170 void setMonoThread(bool is_mono_thread);
171
172 bool isMonoThread() const;
173
174 protected:
176 MsRunReaderScanNumberMultiMap *mpa_multiMapScanNumber = nullptr;
177
178 virtual void initialize() = 0;
179
180 /** @brief tells if the reader is able to handle this file
181 * must be implemented by private MS run reader, specific of one or more file
182 * format
183 */
184 virtual bool accept(const QString &file_name) const = 0;
185
186 private:
187 bool m_isMonoThread = false;
188};
189
190} // namespace pappso
191
provides a multimap to find quickly spectrum index from scan number
base class to read MSrun the only way to build a MsRunReader object is to use the MsRunReaderFactory
Definition msrunreader.h:63
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index)=0
virtual std::size_t spectrumListSize() const =0
get the totat number of spectrum conained in the MSrun data file
MsRunIdCstSPtr mcsp_msRunId
virtual bool acquireDevice()=0
acquire data back end device
virtual bool accept(const QString &file_name) const =0
tells if the reader is able to handle this file must be implemented by private MS run reader,...
virtual XicCoordSPtr newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index, PrecisionPtr precision) const =0
get a xic coordinate object from a given spectrum index
virtual bool releaseDevice()=0
release data back end device if a the data back end is released, the developper has to use acquireDev...
virtual void initialize()=0
virtual XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum(const QualifiedMassSpectrum &mass_spectrum, PrecisionPtr precision) const =0
get a xic coordinate object from a given spectrum
virtual void readSpectrumCollection2(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)=0
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index)=0
get a MassSpectrumSPtr class given its spectrum index
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler)=0
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const =0
get a QualifiedMassSpectrum class given its scan number
virtual void readSpectrumCollectionByMsLevel(SpectrumCollectionHandlerInterface &handler, unsigned int ms_level)=0
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler by Ms Levels
Class representing a fully specified mass spectrum.
interface to collect spectrums from the MsRunReader class
A simple container of DataPoint instances.
Definition trace.h:148
#define PMSPP_LIB_DECL
Q_DECLARE_METATYPE(pappso::MsRunReaderSPtr)
int msRunReaderSPtrMetaTypeId
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::shared_ptr< MsRunReader > MsRunReaderSPtr
Definition msrunreader.h:56
std::shared_ptr< const MsRunReader > MsRunReaderCstSPtr
Definition msrunreader.h:57
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition msrunid.h:46
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition xiccoord.h:43
XIC coordinate in MSrun.