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"
51#include "xiccoord/xiccoord.h"
52
53namespace pappso
54{
55
57typedef std::shared_ptr<MsRunReader> MsRunReaderSPtr;
58typedef std::shared_ptr<const MsRunReader> MsRunReaderCstSPtr;
59
60/** @brief base class to read MSrun
61 * the only way to build a MsRunReader object is to use the MsRunReaderFactory
62 */
64{
65
66 friend class MsFileAccessor;
67
68 public:
69 MsRunReader(const MsRunIdCstSPtr &ms_run_id);
70 MsRunReader(const MsRunReader &other);
71 virtual ~MsRunReader();
72
73 const MsRunIdCstSPtr &getMsRunId() const;
74
75 /** @brief get a MassSpectrumSPtr class given its spectrum index
76 */
77 virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) = 0;
78 virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) = 0;
79
80 /** @brief get a QualifiedMassSpectrum class given its scan number
81 */
82 virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index,
83 bool want_binary_data = true) const = 0;
84
85
86 /** @brief get a xic coordinate object from a given spectrum index
87 */
88 virtual XicCoordSPtr newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index,
89 PrecisionPtr precision) const = 0;
90
91 /** @brief get a xic coordinate object from a given spectrum
92 */
93 virtual XicCoordSPtr
95 PrecisionPtr precision) const = 0;
96
97 /** @brief get the totat number of spectrum conained in the MSrun data file
98 */
99 virtual std::size_t spectrumListSize() const = 0;
100
101 /** @brief function to visit an MsRunReader and get each Spectrum in a
102 * spectrum collection handler
103 */
104 [[deprecated]]
106
107
108 /** @brief function to visit an MsRunReader and get each Spectrum in a
109 * spectrum collection handler
110 */
111 virtual void readSpectrumCollection2(const MsRunReadConfig &config,
113
114 /** @brief function to visit an MsRunReader and get each Spectrum in a
115 * spectrum collection handler by Ms Levels
116 */
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 /** @brief if possible, get the spectrum index given a string identifier
136 * throw a not found exception if spectrum identifier is not found
137 * @param spectrum_identifier string identifier of a specific spectrum
138 * @return the spectrum index
139 */
140 virtual std::size_t
141 spectrumStringIdentifier2SpectrumIndex(const QString &spectrum_identifier) = 0;
142
143
144 /** @brief release data back end device
145 * if a the data back end is released, the developper has to use acquireDevice
146 * before using the msrunreader object
147 * @return bool true if done
148 */
149 virtual bool releaseDevice() = 0;
150
151 /** @brief acquire data back end device
152 * @return bool true if done
153 */
154 virtual bool acquireDevice() = 0;
155
156 /** @brief retention timeline
157 * get retention times along the MSrun in seconds
158 * @return vector of retention times (seconds)
159 */
160 virtual std::vector<double> getRetentionTimeLine();
161
162 /** @brief get a TIC chromatogram
163 *
164 * for each retention time, computes the sum of all intensities.
165 * For IM-MS, combines the mobility spectra
166 *
167 * Note that, formally, a TIC chromatogram is computed only for MS1 spectra.
168 *
169 * @return a trace (x=rt, y=intensities)
170 */
171 virtual Trace getTicChromatogram();
172
173
174 /** @brief set only one is_mono_thread to true
175 *
176 * this avoid to use qtconcurrent
177 */
178 void setMonoThread(bool is_mono_thread);
179
180 bool isMonoThread() const;
181
182
183 /** @brief get OboPsiModTerm corresponding to the instrument model name
184 * child of :
185 * [Term]
186id: MS:1000031
187name: instrument model
188def: "Instrument model name not including the vendor's name." [PSI:MS]
189relationship: part_of MS:1000463 ! instrument
190 */
192
193 protected:
196
197 virtual void initialize() = 0;
198
199 /** @brief tells if the reader is able to handle this file
200 * must be implemented by private MS run reader, specific of one or more file
201 * format
202 */
203 virtual bool accept(const QString &file_name) const = 0;
204
205 private:
206 bool m_isMonoThread = false;
207};
208
209} // namespace pappso
210
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:64
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index)=0
virtual std::size_t spectrumStringIdentifier2SpectrumIndex(const QString &spectrum_identifier)=0
if possible, get the spectrum index given a string identifier throw a not found exception if spectrum...
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 const OboPsiModTerm getOboPsiModTermInstrumentModelName() const
get OboPsiModTerm corresponding to the instrument model name child of : [Term] id: MS:1000031 name: i...
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,...
MsRunReader(const MsRunIdCstSPtr &ms_run_id)
virtual XicCoordSPtr newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index, PrecisionPtr precision) const =0
get a xic coordinate object from a given spectrum index
friend class MsFileAccessor
Definition msrunreader.h:66
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
MsRunReaderScanNumberMultiMap * mpa_multiMapScanNumber
virtual bool hasScanNumbers() const
tells if spectra can be accessed using scan numbers by default, it returns false. Only overrided func...
void setMonoThread(bool is_mono_thread)
set only one is_mono_thread to true
virtual void readSpectrumCollection2(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)=0
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
virtual std::vector< double > getRetentionTimeLine()
retention timeline get retention times along the MSrun in seconds
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index)=0
get a MassSpectrumSPtr class given its spectrum index
virtual std::size_t scanNumber2SpectrumIndex(std::size_t scan_number)
if possible, converts a scan number into a spectrum index This is a convenient function to help trans...
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
bool isMonoThread() const
virtual Trace getTicChromatogram()
get a TIC chromatogram
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
const MsRunIdCstSPtr & getMsRunId() const
Class representing a fully specified mass spectrum.
interface to collect spectrums from the MsRunReader class
A simple container of DataPoint instances.
Definition trace.h:152
#define PMSPP_LIB_DECL
int msRunReaderSPtrMetaTypeId
Q_DECLARE_METATYPE(pappso::MsRunReaderSPtr)
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:57
std::shared_ptr< const MsRunReader > MsRunReaderCstSPtr
Definition msrunreader.h:58
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition msrunid.h:46
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
const PrecisionBase * PrecisionPtr
Definition precision.h:122
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition xiccoord.h:44
base interface to read MSrun files