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 */
105
106 virtual void readSpectrumCollection2(const MsRunReadConfig &config,
108
109 /** @brief function to visit an MsRunReader and get each Spectrum in a
110 * spectrum collection handler by Ms Levels
111 */
113 unsigned int ms_level) = 0;
114
115
116 /** @brief if possible, converts a scan number into a spectrum index
117 * This is a convenient function to help transition from the old scan number
118 * (not implemented by all vendors) to more secure spectrum index (not vendor
119 * dependant).
120 * It is better to not rely on this function.
121 */
122 virtual std::size_t scanNumber2SpectrumIndex(std::size_t scan_number);
123
124 /** @brief tells if spectra can be accessed using scan numbers
125 * by default, it returns false. Only overrided functions can check if scan
126 * numbers are available in the current file
127 */
128 virtual bool hasScanNumbers() const;
129
130 /** @brief if possible, get the spectrum index given a string identifier
131 * throw a not found exception if spectrum identifier is not found
132 * @param spectrum_identifier string identifier of a specific spectrum
133 * @return the spectrum index
134 */
135 virtual std::size_t
136 spectrumStringIdentifier2SpectrumIndex(const QString &spectrum_identifier) = 0;
137
138
139 /** @brief release data back end device
140 * if a the data back end is released, the developper has to use acquireDevice
141 * before using the msrunreader object
142 * @return bool true if done
143 */
144 virtual bool releaseDevice() = 0;
145
146 /** @brief acquire data back end device
147 * @return bool true if done
148 */
149 virtual bool acquireDevice() = 0;
150
151 /** @brief retention timeline
152 * get retention times along the MSrun in seconds
153 * @return vector of retention times (seconds)
154 */
155 virtual std::vector<double> getRetentionTimeLine();
156
157 /** @brief get a TIC chromatogram
158 *
159 * for each retention time, computes the sum of all intensities.
160 * For IM-MS, combines the mobility spectra
161 *
162 * Note that, formally, a TIC chromatogram is computed only for MS1 spectra.
163 *
164 * @return a trace (x=rt, y=intensities)
165 */
166 virtual Trace getTicChromatogram();
167
168
169 /** @brief set only one is_mono_thread to true
170 *
171 * this avoid to use qtconcurrent
172 */
173 void setMonoThread(bool is_mono_thread);
174
175 bool isMonoThread() const;
176
177
178 /** @brief get OboPsiModTerm corresponding to the instrument model name
179 * child of :
180 * [Term]
181id: MS:1000031
182name: instrument model
183def: "Instrument model name not including the vendor's name." [PSI:MS]
184relationship: part_of MS:1000463 ! instrument
185 */
187
188 protected:
191
192 virtual void initialize() = 0;
193
194 /** @brief tells if the reader is able to handle this file
195 * must be implemented by private MS run reader, specific of one or more file
196 * format
197 */
198 virtual bool accept(const QString &file_name) const = 0;
199
200 private:
201 bool m_isMonoThread = false;
202};
203
204} // namespace pappso
205
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
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:148
#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